sliver refactor

This commit is contained in:
Christien Rioux 2024-07-11 23:04:08 -04:00
parent 67812b3c6f
commit 2fa3cbd21c
25 changed files with 710 additions and 387 deletions

View file

@ -143,7 +143,7 @@ class _DrawerMenuState extends State<DrawerMenu> {
(scaleConfig.preferBorders || scaleConfig.useVisualIndicators)
? activeBorder
: null,
borderRadius: 16 * scaleConfig.borderRadiusScale,
borderRadius: 12 * scaleConfig.borderRadiusScale,
callback: callback,
footerButtonIcon: loggedIn ? Icons.edit_outlined : null,
footerCallback: footerCallback,
@ -197,11 +197,11 @@ class _DrawerMenuState extends State<DrawerMenu> {
loading: () => _wrapInBox(
child: buildProgressIndicator(),
color: scaleScheme.grayScale.subtleBorder,
borderRadius: 16 * scaleConfig.borderRadiusScale),
borderRadius: 12 * scaleConfig.borderRadiusScale),
error: (err, st) => _wrapInBox(
child: errorPage(err, st),
color: scaleScheme.errorScale.subtleBorder,
borderRadius: 16 * scaleConfig.borderRadiusScale),
borderRadius: 12 * scaleConfig.borderRadiusScale),
);
loggedInAccounts.add(loggedInAccount.paddingLTRB(0, 0, 0, 8));
} else {
@ -254,7 +254,7 @@ class _DrawerMenuState extends State<DrawerMenu> {
return IconButton(
icon: icon,
color: border,
constraints: const BoxConstraints.expand(height: 64, width: 64),
constraints: const BoxConstraints.expand(height: 48, width: 48),
style: ButtonStyle(
backgroundColor: WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.hovered)) {
@ -269,18 +269,18 @@ class _DrawerMenuState extends State<DrawerMenu> {
return RoundedRectangleBorder(
side: BorderSide(color: hoverBorder, width: 2),
borderRadius: BorderRadius.all(
Radius.circular(16 * scaleConfig.borderRadiusScale)));
Radius.circular(12 * scaleConfig.borderRadiusScale)));
}
if (states.contains(WidgetState.focused)) {
return RoundedRectangleBorder(
side: BorderSide(color: activeBorder, width: 2),
borderRadius: BorderRadius.all(
Radius.circular(16 * scaleConfig.borderRadiusScale)));
Radius.circular(12 * scaleConfig.borderRadiusScale)));
}
return RoundedRectangleBorder(
side: BorderSide(color: border, width: 2),
borderRadius: BorderRadius.all(
Radius.circular(16 * scaleConfig.borderRadiusScale)));
Radius.circular(12 * scaleConfig.borderRadiusScale)));
})),
tooltip: tooltip,
onPressed: onPressed);
@ -413,12 +413,18 @@ class _DrawerMenuState extends State<DrawerMenu> {
_getBottomButtons(),
Row(children: [
Text('${translate('menu.version')} $packageInfoVersion',
style: theme.textTheme.labelMedium!
.copyWith(color: scale.tertiaryScale.hoverBorder)),
style: theme.textTheme.labelMedium!.copyWith(
color: scaleConfig.preferBorders
? scale.tertiaryScale.hoverBorder
: scale.tertiaryScale.subtleBackground)),
const Spacer(),
SignalStrengthMeterWidget(
color: scale.tertiaryScale.hoverBorder,
inactiveColor: scale.tertiaryScale.border,
color: scaleConfig.preferBorders
? scale.tertiaryScale.hoverBorder
: scale.tertiaryScale.subtleBackground,
inactiveColor: scaleConfig.preferBorders
? scale.tertiaryScale.border
: scale.tertiaryScale.elementBackground,
),
])
]).paddingAll(16),

View file

@ -8,7 +8,6 @@ import 'package:veilid_support/veilid_support.dart';
import '../../account_manager/account_manager.dart';
import '../../theme/theme.dart';
import '../../tools/tools.dart';
import 'drawer_menu/drawer_menu.dart';
import 'home_account_invalid.dart';
import 'home_account_locked.dart';
@ -37,9 +36,6 @@ class HomeScreenState extends State<HomeScreen>
.indexWhere((x) => x.superIdentity.recordKey == activeLocalAccount);
final canClose = activeIndex != -1;
await changeWindowSetup(
TitleBarStyle.normal, OrientationCapability.normal);
if (!canClose) {
await _zoomDrawerController.open!();
}
@ -129,7 +125,6 @@ class HomeScreenState extends State<HomeScreen>
final canClose = activeIndex != -1;
return SafeArea(
bottom: false,
child: DefaultTextStyle(
style: theme.textTheme.bodySmall!,
child: ZoomDrawer(

View file

@ -1,86 +0,0 @@
import 'package:awesome_extensions/awesome_extensions.dart';
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_translate/flutter_translate.dart';
import '../../../contact_invitation/contact_invitation.dart';
import '../../../contacts/contacts.dart';
import '../../../theme/theme.dart';
class AccountPage extends StatefulWidget {
const AccountPage({
super.key,
});
@override
AccountPageState createState() => AccountPageState();
}
class AccountPageState extends State<AccountPage> {
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
// ignore: prefer_expression_function_bodies
Widget build(BuildContext context) {
final theme = Theme.of(context);
final textTheme = theme.textTheme;
final scale = theme.extension<ScaleScheme>()!;
final scaleConfig = theme.extension<ScaleConfig>()!;
final cilState = context.watch<ContactInvitationListCubit>().state;
final cilBusy = cilState.busy;
final contactInvitationRecordList =
cilState.state.asData?.value.map((x) => x.value).toIList() ??
const IListConst([]);
final ciState = context.watch<ContactListCubit>().state;
final ciBusy = ciState.busy;
final contactList =
ciState.state.asData?.value.map((x) => x.value).toIList() ??
const IListConst([]);
return SizedBox(
child: Column(children: <Widget>[
if (contactInvitationRecordList.isNotEmpty)
ExpansionTile(
tilePadding: const EdgeInsets.fromLTRB(8, 0, 8, 0),
backgroundColor: scale.primaryScale.border,
collapsedBackgroundColor: scale.primaryScale.border,
dense: true,
minTileHeight: 16,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(16 * scaleConfig.borderRadiusScale),
),
collapsedShape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(16 * scaleConfig.borderRadiusScale),
),
title: Text(
translate('account_page.contact_invitations'),
textAlign: TextAlign.center,
style: textTheme.titleSmall!
.copyWith(color: scale.primaryScale.borderText),
),
iconColor: scale.primaryScale.borderText,
collapsedIconColor: scale.primaryScale.borderText,
initiallyExpanded: true,
children: [
ContactInvitationListWidget(
contactInvitationRecordList: contactInvitationRecordList,
disabled: cilBusy)
],
).paddingLTRB(8, 0, 8, 8),
ContactListWidget(contactList: contactList, disabled: ciBusy).expanded(),
]));
}
}

View file

@ -1,4 +1,3 @@
import 'package:awesome_extensions/awesome_extensions.dart';
import 'package:flutter/material.dart';
import '../../../chat_list/chat_list.dart';
@ -24,8 +23,6 @@ class ChatsPageState extends State<ChatsPage> {
@override
// ignore: prefer_expression_function_bodies
Widget build(BuildContext context) {
return Column(children: <Widget>[
const ChatListWidget().expanded(),
]);
return const ChatListWidget();
}
}

View file

@ -0,0 +1,59 @@
import 'package:awesome_extensions/awesome_extensions.dart';
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../contact_invitation/contact_invitation.dart';
import '../../../contacts/contacts.dart';
class ContactsPage extends StatefulWidget {
const ContactsPage({
super.key,
});
@override
ContactsPageState createState() => ContactsPageState();
}
class ContactsPageState extends State<ContactsPage> {
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
// ignore: prefer_expression_function_bodies
Widget build(BuildContext context) {
// final theme = Theme.of(context);
// final textTheme = theme.textTheme;
// final scale = theme.extension<ScaleScheme>()!;
// final scaleConfig = theme.extension<ScaleConfig>()!;
final cilState = context.watch<ContactInvitationListCubit>().state;
final cilBusy = cilState.busy;
final contactInvitationRecordList =
cilState.state.asData?.value.map((x) => x.value).toIList() ??
const IListConst([]);
final ciState = context.watch<ContactListCubit>().state;
final ciBusy = ciState.busy;
final contactList =
ciState.state.asData?.value.map((x) => x.value).toIList() ??
const IListConst([]);
return CustomScrollView(slivers: [
if (contactInvitationRecordList.isNotEmpty)
SliverPadding(
padding: const EdgeInsets.only(bottom: 8),
sliver: ContactInvitationListWidget(
contactInvitationRecordList: contactInvitationRecordList,
disabled: cilBusy)),
ContactListWidget(contactList: contactList, disabled: ciBusy),
]).paddingLTRB(8, 0, 8, 8);
}
}

View file

@ -13,9 +13,9 @@ import 'package:provider/provider.dart';
import '../../../chat/chat.dart';
import '../../../contact_invitation/contact_invitation.dart';
import '../../../theme/theme.dart';
import 'account_page.dart';
import 'bottom_sheet_action_button.dart';
import 'chats_page.dart';
import 'contacts_page.dart';
class MainPager extends StatefulWidget {
const MainPager({super.key});
@ -41,25 +41,6 @@ class MainPagerState extends State<MainPager> with TickerProviderStateMixin {
super.dispose();
}
bool _onScrollNotification(ScrollNotification notification) {
if (notification is UserScrollNotification &&
notification.metrics.axis == Axis.vertical) {
switch (notification.direction) {
case ScrollDirection.forward:
// _hideBottomBarAnimationController.reverse();
// _fabAnimationController.forward(from: 0);
break;
case ScrollDirection.reverse:
// _hideBottomBarAnimationController.forward();
// _fabAnimationController.reverse(from: 1);
break;
case ScrollDirection.idle:
break;
}
}
return false;
}
Future<void> scanContactInvitationDialog(BuildContext context) async {
await showDialog<void>(
context: context,
@ -162,21 +143,19 @@ class MainPagerState extends State<MainPager> with TickerProviderStateMixin {
return Scaffold(
//extendBody: true,
backgroundColor: Colors.transparent,
body: NotificationListener<ScrollNotification>(
onNotification: _onScrollNotification,
child: PreloadPageView(
key: _pageViewKey,
controller: pageController,
preloadPagesCount: 2,
onPageChanged: (index) {
setState(() {
currentPage = index;
});
},
children: const [
AccountPage(),
ChatsPage(),
])),
body: PreloadPageView(
key: _pageViewKey,
controller: pageController,
preloadPagesCount: 2,
onPageChanged: (index) {
setState(() {
currentPage = index;
});
},
children: const [
ContactsPage(),
ChatsPage(),
]),
// appBar: AppBar(
// toolbarHeight: 24,
// title: Text(
@ -240,7 +219,7 @@ class MainPagerState extends State<MainPager> with TickerProviderStateMixin {
// ];
final _fabIconList = <IconData>[
Icons.person_add_sharp,
Icons.add_comment_sharp,
Icons.chat,
];
final _bottomLabelList = <String>[
translate('pager.contacts'),