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,38 +24,16 @@ 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,
decoration: ShapeDecoration(
color: scale.primaryScale.subtleBorder,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
)),
constraints: const BoxConstraints(
minHeight: 64,
),
child: Column(children: [
Text(
translate('contact_list.title'),
style: textTheme.titleMedium!
.copyWith(color: scale.primaryScale.subtleText),
).paddingLTRB(4, 4, 4, 0),
Container(
width: double.infinity,
decoration: ShapeDecoration(
color: scale.primaryScale.subtleBackground,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: BorderSide(
color: scale.primaryScale.subtleBorder, width: 4))),
child: (contactList.isEmpty) child: (contactList.isEmpty)
? const EmptyContactListWidget().toCenter() ? const EmptyContactListWidget()
: SearchableList<proto.Contact>( : SearchableList<proto.Contact>(
autoFocusOnSearch: false, autoFocusOnSearch: false,
shrinkWrap: true,
initialList: contactList.toList(), initialList: contactList.toList(),
builder: (l, i, c) => ContactItemWidget(contact: c), builder: (l, i, c) => ContactItemWidget(contact: c),
filter: (value) { filter: (value) {
@ -81,8 +59,6 @@ class ContactListWidget extends ConsumerWidget {
), ),
), ),
), ),
).expanded() ))).paddingLTRB(8, 0, 8, 8);
]),
).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)))));
}