App bar leading icon for drawer

This commit is contained in:
LittleSheep 2024-07-12 22:31:45 +08:00
parent 1a26880719
commit a2db9a7ae4
16 changed files with 80 additions and 7 deletions

View File

@ -7,6 +7,7 @@ import 'package:solian/models/realm.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/router.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/app_bar_leading.dart';
import 'package:solian/widgets/app_bar_title.dart';
import 'package:solian/widgets/attachments/attachment_publish.dart';
import 'package:solian/widgets/feed/feed_tags_field.dart';
@ -129,6 +130,7 @@ class _ArticlePublishScreenState extends State<ArticlePublishScreen> {
color: Theme.of(context).colorScheme.surface,
child: Scaffold(
appBar: AppBar(
leading: const AppBarLeadingButton(),
title: AppBarTitle('articlePublish'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),

View File

@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:solian/providers/content/call.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/app_bar_leading.dart';
import 'package:solian/widgets/chat/call/call_controls.dart';
import 'package:solian/widgets/chat/call/call_participant.dart';
@ -55,6 +56,7 @@ class _CallScreenState extends State<CallScreen> {
color: Theme.of(context).colorScheme.surface,
child: Scaffold(
appBar: AppBar(
leading: const AppBarLeadingButton(),
centerTitle: true,
toolbarHeight: SolianTheme.toolbarHeight(context),
title: RichText(

View File

@ -17,6 +17,7 @@ import 'package:solian/providers/content/channel.dart';
import 'package:solian/router.dart';
import 'package:solian/screens/channel/channel_detail.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/app_bar_leading.dart';
import 'package:solian/widgets/app_bar_title.dart';
import 'package:solian/widgets/chat/call/call_prejoin.dart';
import 'package:solian/widgets/chat/call/chat_call_action.dart';
@ -192,6 +193,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
return Scaffold(
appBar: AppBar(
leading: const AppBarLeadingButton(),
title: AppBarTitle(title),
centerTitle: false,
titleSpacing: SolianTheme.titleSpacing(context),

View File

@ -8,6 +8,7 @@ import 'package:solian/router.dart';
import 'package:solian/screens/account/notification.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/account/signin_required_overlay.dart';
import 'package:solian/widgets/app_bar_leading.dart';
import 'package:solian/widgets/app_bar_title.dart';
import 'package:solian/widgets/channel/channel_list.dart';
import 'package:solian/widgets/chat/call/chat_call_indicator.dart';
@ -43,6 +44,7 @@ class _ChatScreenState extends State<ChatScreen> {
color: Theme.of(context).colorScheme.surface,
child: Scaffold(
appBar: AppBar(
leading: const AppBarLeadingButton(),
title: AppBarTitle('chat'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),

View File

@ -8,6 +8,7 @@ import 'package:solian/models/post.dart';
import 'package:solian/providers/content/feed.dart';
import 'package:solian/screens/home.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/app_bar_leading.dart';
import 'package:solian/widgets/app_bar_title.dart';
import 'package:solian/widgets/articles/article_action.dart';
import 'package:solian/widgets/articles/article_owned_list.dart';
@ -62,6 +63,7 @@ class _DraftBoxScreenState extends State<DraftBoxScreen> {
color: Theme.of(context).colorScheme.surface,
child: Scaffold(
appBar: AppBar(
leading: const AppBarLeadingButton(),
title: AppBarTitle('draftBox'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),

View File

@ -10,6 +10,7 @@ import 'package:solian/screens/account/notification.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/app_bar_title.dart';
import 'package:solian/widgets/current_state_action.dart';
import 'package:solian/widgets/app_bar_leading.dart';
import 'package:solian/widgets/feed/feed_list.dart';
class HomeScreen extends StatefulWidget {
@ -63,6 +64,7 @@ class _HomeScreenState extends State<HomeScreen> {
centerTitle: false,
floating: true,
toolbarHeight: SolianTheme.toolbarHeight(context),
leading: const AppBarLeadingButton(),
actions: [
const BackgroundStateWidget(),
const NotificationButton(),

View File

@ -8,6 +8,7 @@ import 'package:solian/models/realm.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/router.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/app_bar_leading.dart';
import 'package:solian/widgets/app_bar_title.dart';
import 'package:solian/widgets/attachments/attachment_publish.dart';
import 'package:solian/widgets/posts/post_item.dart';
@ -133,6 +134,7 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
color: Theme.of(context).colorScheme.surface,
child: Scaffold(
appBar: AppBar(
leading: const AppBarLeadingButton(),
title: AppBarTitle('postPublish'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),

View File

@ -9,6 +9,7 @@ import 'package:solian/router.dart';
import 'package:solian/screens/account/notification.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/account/signin_required_overlay.dart';
import 'package:solian/widgets/app_bar_leading.dart';
import 'package:solian/widgets/app_bar_title.dart';
import 'package:solian/widgets/current_state_action.dart';
import 'package:solian/widgets/sized_container.dart';
@ -47,7 +48,6 @@ class _RealmListScreenState extends State<RealmListScreen> {
@override
void initState() {
super.initState();
getRealms();
}
@ -59,6 +59,7 @@ class _RealmListScreenState extends State<RealmListScreen> {
color: Theme.of(context).colorScheme.surface,
child: Scaffold(
appBar: AppBar(
leading: const AppBarLeadingButton(),
title: AppBarTitle('realm'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),

View File

@ -6,6 +6,7 @@ import 'package:solian/models/realm.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/router.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/app_bar_leading.dart';
import 'package:solian/widgets/app_bar_title.dart';
import 'package:uuid/uuid.dart';
@ -98,6 +99,7 @@ class _RealmOrganizeScreenState extends State<RealmOrganizeScreen> {
color: Theme.of(context).colorScheme.surface,
child: Scaffold(
appBar: AppBar(
leading: const AppBarLeadingButton(),
title: AppBarTitle('realmOrganizing'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),

View File

@ -14,6 +14,7 @@ import 'package:solian/router.dart';
import 'package:solian/screens/channel/channel_organize.dart';
import 'package:solian/screens/posts/post_editor.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/app_bar_leading.dart';
import 'package:solian/widgets/channel/channel_list.dart';
import 'package:solian/widgets/posts/post_list.dart';
@ -90,6 +91,7 @@ class _RealmViewScreenState extends State<RealmViewScreen> {
handle:
NestedScrollView.sliverOverlapAbsorberHandleFor(context),
sliver: SliverAppBar(
leading: const AppBarLeadingButton(),
title: Text(_realm?.name ?? 'loading'.tr),
centerTitle: false,
actions: [

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:go_router/go_router.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/app_bar_leading.dart';
import 'package:solian/widgets/app_bar_title.dart';
class CenteredShell extends StatelessWidget {
@ -21,6 +22,7 @@ class CenteredShell extends StatelessWidget {
return Scaffold(
appBar: showAppBar
? AppBar(
leading: const AppBarLeadingButton(),
title: AppBarTitle(state.topRoute?.name?.tr ?? 'page'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:go_router/go_router.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/app_bar_leading.dart';
import 'package:solian/widgets/app_bar_title.dart';
import 'package:solian/widgets/sidebar/sidebar_placeholder.dart';
@ -43,6 +44,7 @@ class SidebarShell extends StatelessWidget {
return Scaffold(
appBar: showAppBar
? AppBar(
leading: const AppBarLeadingButton(),
title: AppBarTitle(state.topRoute?.name?.tr ?? 'page'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),

View File

@ -3,6 +3,7 @@ import 'package:get/get.dart';
import 'package:go_router/go_router.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/app_bar_title.dart';
import 'package:solian/widgets/app_bar_leading.dart';
class TitleShell extends StatelessWidget {
final bool showAppBar;
@ -21,6 +22,7 @@ class TitleShell extends StatelessWidget {
return Scaffold(
appBar: showAppBar
? AppBar(
leading: const AppBarLeadingButton(),
title: AppBarTitle(state.topRoute?.name?.tr ?? 'page'.tr),
centerTitle: false,
toolbarHeight: SolianTheme.toolbarHeight(context),

View File

@ -0,0 +1,22 @@
import 'package:flutter/material.dart';
import 'package:solian/shells/root_shell.dart';
class AppBarLeadingButton extends StatelessWidget {
const AppBarLeadingButton({super.key});
@override
Widget build(BuildContext context) {
if (Navigator.canPop(context)) {
return BackButton(
onPressed: () => Navigator.pop(context),
);
}
if (rootScaffoldKey.currentState!.hasDrawer) {
return DrawerButton(
onPressed: () => rootScaffoldKey.currentState!.openDrawer(),
);
} else {
return const SizedBox();
}
}
}

View File

@ -11,6 +11,7 @@ class ChannelListWidget extends StatefulWidget {
final bool isDense;
final bool noCategory;
final bool useReplace;
final Function(Channel)? onSelected;
const ChannelListWidget({
super.key,
@ -19,6 +20,7 @@ class ChannelListWidget extends StatefulWidget {
this.isDense = false,
this.noCategory = false,
this.useReplace = false,
this.onSelected,
});
@override
@ -80,12 +82,16 @@ class _ChannelListWidgetState extends State<ChannelListWidget> {
},
);
}
if (widget.onSelected != null) {
widget.onSelected!(item);
}
}
Widget buildItem(Channel item) {
final padding = widget.isDense
? const EdgeInsets.symmetric(horizontal: 20)
: const EdgeInsets.symmetric(horizontal: 24);
: const EdgeInsets.symmetric(horizontal: 16);
if (item.type == 1) {
final otherside = item.members!
@ -95,7 +101,7 @@ class _ChannelListWidgetState extends State<ChannelListWidget> {
return ListTile(
leading: AccountAvatar(
content: otherside.account.avatar,
radius: widget.isDense ? 12 : 24,
radius: widget.isDense ? 12 : 20,
bgColor: Colors.indigo,
feColor: Colors.white,
),
@ -120,7 +126,7 @@ class _ChannelListWidgetState extends State<ChannelListWidget> {
leading: CircleAvatar(
backgroundColor:
item.realmId == null ? Colors.indigo : Colors.transparent,
radius: widget.isDense ? 12 : 24,
radius: widget.isDense ? 12 : 20,
child: FaIcon(
FontAwesomeIcons.hashtag,
color: item.realmId == null ? Colors.white : Colors.indigo,
@ -163,9 +169,18 @@ class _ChannelListWidgetState extends State<ChannelListWidget> {
SliverList.list(
children: _inRealms.entries.map((element) {
return ExpansionTile(
tilePadding: const EdgeInsets.symmetric(horizontal: 24),
tilePadding: const EdgeInsets.symmetric(horizontal: 20),
minTileHeight: 48,
title: Text(element.value.first.realm!.name),
leading: CircleAvatar(
backgroundColor: Colors.teal,
radius: widget.isDense ? 12 : 24,
child: Icon(
Icons.workspaces,
color: Colors.white,
size: widget.isDense ? 12 : 16,
),
),
children: element.value.map((x) => buildItem(x)).toList(),
);
}).toList(),

View File

@ -89,7 +89,11 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
return ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
title: Text(snapshot.data!.body['nick']),
title: Text(
snapshot.data!.body['nick'],
maxLines: 1,
overflow: TextOverflow.fade,
),
subtitle: Builder(
builder: (context) {
if (_accountStatus == null) {
@ -98,7 +102,11 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
final info = StatusProvider.determineStatus(
_accountStatus!,
);
return Text(info.$3);
return Text(
info.$3,
maxLines: 1,
overflow: TextOverflow.fade,
);
},
),
leading: Builder(builder: (context) {
@ -177,6 +185,9 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
selfId: selfId,
isDense: true,
useReplace: true,
onSelected: (_) {
closeDrawer();
},
),
),
),