This commit is contained in:
Christien Rioux 2023-09-23 22:19:53 -04:00
parent 95e5306eb3
commit cd8f5aebcb
6 changed files with 121 additions and 109 deletions

View File

@ -24,65 +24,41 @@ class ContactListWidget extends ConsumerWidget {
@override @override
// ignore: prefer_expression_function_bodies // ignore: prefer_expression_function_bodies
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final theme = Theme.of(context); return SizedBox.expand(
final textTheme = theme.textTheme; child: styledTitleContainer(
final scale = theme.extension<ScaleScheme>()!; context: context,
title: translate('contact_list.title'),
return Container( child: SizedBox.expand(
width: double.infinity, child: (contactList.isEmpty)
decoration: ShapeDecoration( ? const EmptyContactListWidget()
color: scale.primaryScale.subtleBorder, : SearchableList<proto.Contact>(
shape: RoundedRectangleBorder( autoFocusOnSearch: false,
borderRadius: BorderRadius.circular(16), shrinkWrap: true,
)), initialList: contactList.toList(),
constraints: const BoxConstraints( builder: (l, i, c) => ContactItemWidget(contact: c),
minHeight: 64, filter: (value) {
), final lowerValue = value.toLowerCase();
child: Column(children: [ return contactList
Text( .where((element) =>
translate('contact_list.title'), element.editedProfile.name
style: textTheme.titleMedium! .toLowerCase()
.copyWith(color: scale.primaryScale.subtleText), .contains(lowerValue) ||
).paddingLTRB(4, 4, 4, 0), element.editedProfile.title
Container( .toLowerCase()
width: double.infinity, .contains(lowerValue))
decoration: ShapeDecoration( .toList();
color: scale.primaryScale.subtleBackground, },
shape: RoundedRectangleBorder( inputDecoration: InputDecoration(
borderRadius: BorderRadius.circular(16), labelText: translate('contact_list.search'),
side: BorderSide( fillColor: Colors.white,
color: scale.primaryScale.subtleBorder, width: 4))), focusedBorder: OutlineInputBorder(
child: (contactList.isEmpty) borderSide: const BorderSide(
? const EmptyContactListWidget().toCenter() color: Colors.blue,
: SearchableList<proto.Contact>( ),
autoFocusOnSearch: false, borderRadius: BorderRadius.circular(10),
initialList: contactList.toList(), ),
builder: (l, i, c) => ContactItemWidget(contact: c),
filter: (value) {
final lowerValue = value.toLowerCase();
return contactList
.where((element) =>
element.editedProfile.name
.toLowerCase()
.contains(lowerValue) ||
element.editedProfile.title
.toLowerCase()
.contains(lowerValue))
.toList();
},
inputDecoration: InputDecoration(
labelText: translate('contact_list.search'),
fillColor: Colors.white,
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Colors.blue,
), ),
borderRadius: BorderRadius.circular(10),
), ),
), ))).paddingLTRB(8, 0, 8, 8);
),
).expanded()
]),
).paddingLTRB(8, 0, 8, 8);
} }
} }

View File

@ -15,6 +15,7 @@ class EmptyContactListWidget extends ConsumerWidget {
final scale = theme.extension<ScaleScheme>()!; final scale = theme.extension<ScaleScheme>()!;
return Column( return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Icon( Icon(

View File

@ -23,38 +23,10 @@ class PasteInviteDialog extends ConsumerStatefulWidget {
PasteInviteDialogState createState() => PasteInviteDialogState(); PasteInviteDialogState createState() => PasteInviteDialogState();
static Future<void> show(BuildContext context) async { static Future<void> show(BuildContext context) async {
final theme = Theme.of(context); await showStyledDialog<void>(
final scale = theme.extension<ScaleScheme>()!;
final textTheme = theme.textTheme;
await showDialog<void>(
context: context, context: context,
// ignore: prefer_expression_function_bodies title: translate('paste_invite_dialog.title'),
builder: (context) { child: const PasteInviteDialog());
return AlertDialog(
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: const BorderRadius.all(Radius.circular(16)),
side: BorderSide(width: 4, color: scale.primaryScale.border),
),
contentPadding: EdgeInsets.zero,
backgroundColor: scale.primaryScale.border,
title: Text(
translate('paste_invite_dialog.title'),
style: textTheme.titleMedium,
textAlign: TextAlign.center,
),
titlePadding: EdgeInsets.fromLTRB(4, 4, 4, 0),
content: DecoratedBox(
decoration: ShapeDecoration(
color: scale.primaryScale.subtleBackground,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: BorderSide(
width: 4, color: scale.primaryScale.border),
)),
child: const PasteInviteDialog().paddingAll(4)));
});
} }
} }

View File

@ -22,23 +22,10 @@ class SendInviteDialog extends ConsumerStatefulWidget {
SendInviteDialogState createState() => SendInviteDialogState(); SendInviteDialogState createState() => SendInviteDialogState();
static Future<void> show(BuildContext context) async { static Future<void> show(BuildContext context) async {
await showDialog<void>( await showStyledDialog<void>(
context: context, context: context,
// ignore: prefer_expression_function_bodies title: translate('send_invite_dialog.title'),
builder: (context) { child: const SendInviteDialog());
return AlertDialog(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20)),
),
contentPadding: const EdgeInsets.only(
top: 10,
),
title: Text(
translate('send_invite_dialog.title'),
style: const TextStyle(fontSize: 24),
),
content: const SendInviteDialog());
});
} }
} }
@ -146,11 +133,16 @@ class SendInviteDialogState extends ConsumerState<SendInviteDialog> {
@override @override
// ignore: prefer_expression_function_bodies // ignore: prefer_expression_function_bodies
Widget build(BuildContext context) { Widget build(BuildContext context) {
final windowSize = MediaQuery.of(context).size;
final maxDialogHeight = windowSize.height - 64;
final maxDialogWidth = windowSize.width - 64;
final theme = Theme.of(context); final theme = Theme.of(context);
//final scale = theme.extension<ScaleScheme>()!; //final scale = theme.extension<ScaleScheme>()!;
final textTheme = theme.textTheme; final textTheme = theme.textTheme;
return SizedBox( return ConstrainedBox(
height: 400, constraints:
BoxConstraints(maxHeight: maxDialogHeight, maxWidth: maxDialogWidth),
child: SingleChildScrollView( child: SingleChildScrollView(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: Column( child: Column(

View File

@ -11,6 +11,7 @@ import '../../entities/proto.dart' as proto;
import '../../providers/contact.dart'; import '../../providers/contact.dart';
import '../../providers/contact_invite.dart'; import '../../providers/contact_invite.dart';
import '../../tools/theme_service.dart'; import '../../tools/theme_service.dart';
import '../../tools/tools.dart';
import '../../veilid_support/veilid_support.dart'; import '../../veilid_support/veilid_support.dart';
class AccountPage extends ConsumerStatefulWidget { class AccountPage extends ConsumerStatefulWidget {
@ -56,7 +57,8 @@ class AccountPageState extends ConsumerState<AccountPage> {
final contactList = ref.watch(fetchContactListProvider).asData?.value ?? final contactList = ref.watch(fetchContactListProvider).asData?.value ??
const IListConst([]); const IListConst([]);
return Column(children: <Widget>[ return SizedBox(
child: Column(children: <Widget>[
if (contactInvitationRecordList.isNotEmpty) if (contactInvitationRecordList.isNotEmpty)
ExpansionTile( ExpansionTile(
tilePadding: EdgeInsets.fromLTRB(8, 0, 8, 0), tilePadding: EdgeInsets.fromLTRB(8, 0, 8, 0),
@ -81,6 +83,6 @@ class AccountPageState extends ConsumerState<AccountPage> {
], ],
).paddingLTRB(8, 0, 8, 8), ).paddingLTRB(8, 0, 8, 8),
ContactListWidget(contactList: contactList).expanded(), ContactListWidget(contactList: contactList).expanded(),
]); ]));
} }
} }

View File

@ -1,3 +1,4 @@
import 'package:awesome_extensions/awesome_extensions.dart';
import 'package:blurry_modal_progress_hud/blurry_modal_progress_hud.dart'; import 'package:blurry_modal_progress_hud/blurry_modal_progress_hud.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart';
@ -66,3 +67,71 @@ void showInfoToast(BuildContext context, String message) {
description: Text(message), description: Text(message),
).show(context); ).show(context);
} }
Widget styledTitleContainer(
{required BuildContext context,
required String title,
required Widget child}) {
final theme = Theme.of(context);
final scale = theme.extension<ScaleScheme>()!;
final textTheme = theme.textTheme;
return Container(
decoration: ShapeDecoration(
color: scale.primaryScale.subtleBorder,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
)),
child: Column(children: [
Text(
title,
style: textTheme.titleMedium!
.copyWith(color: scale.primaryScale.subtleText),
).paddingLTRB(4, 4, 4, 0),
DecoratedBox(
decoration: ShapeDecoration(
color: scale.primaryScale.subtleBackground,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
)),
child: child)
.paddingAll(4)
.expanded()
]));
}
Future<T?> showStyledDialog<T>(
{required BuildContext context,
required String title,
required Widget child}) async {
final theme = Theme.of(context);
final scale = theme.extension<ScaleScheme>()!;
final textTheme = theme.textTheme;
return showDialog<T>(
context: context,
builder: (context) => AlertDialog(
elevation: 0,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(16)),
),
contentPadding: const EdgeInsets.all(4),
backgroundColor: scale.primaryScale.border,
title: Text(
title,
style: textTheme.titleMedium,
textAlign: TextAlign.center,
),
titlePadding: const EdgeInsets.fromLTRB(4, 4, 4, 4),
content: DecoratedBox(
decoration: ShapeDecoration(
color: scale.primaryScale.border,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16))),
child: DecoratedBox(
decoration: ShapeDecoration(
color: scale.primaryScale.subtleBackground,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12))),
child: child.paddingAll(0)))));
}