App bar leading icon for drawer

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

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();
},
),
),
),