dart format
This commit is contained in:
@@ -27,9 +27,18 @@ class AppModule {
|
||||
BreakerArea breakerArea;
|
||||
Widget Function() create;
|
||||
|
||||
AppModule(this.module, {required this.name, required this.icon, this.breakerArea = BreakerArea.global, required this.create});
|
||||
AppModule(
|
||||
this.module, {
|
||||
required this.name,
|
||||
required this.icon,
|
||||
this.breakerArea = BreakerArea.global,
|
||||
required this.create,
|
||||
});
|
||||
|
||||
static Map<Modules, AppModule> modules(BuildContext context, {bool showFiltered = false}) {
|
||||
static Map<Modules, AppModule> modules(
|
||||
BuildContext context, {
|
||||
bool showFiltered = false,
|
||||
}) {
|
||||
final settings = context.read<SettingsCubit>();
|
||||
var available = {
|
||||
Modules.timetable: AppModule(
|
||||
@@ -45,8 +54,12 @@ class AppModule {
|
||||
icon: () => BlocBuilder<ChatListBloc, LoadableState<ChatListState>>(
|
||||
builder: (context, state) {
|
||||
final rooms = state.data?.rooms;
|
||||
if (rooms == null || rooms.data.isEmpty) return const Icon(Icons.chat);
|
||||
final messages = rooms.data.map((e) => e.unreadMessages).reduce((a, b) => a + b);
|
||||
if (rooms == null || rooms.data.isEmpty) {
|
||||
return const Icon(Icons.chat);
|
||||
}
|
||||
final messages = rooms.data
|
||||
.map((e) => e.unreadMessages)
|
||||
.reduce((a, b) => a + b);
|
||||
return badges.Badge(
|
||||
showBadge: messages > 0,
|
||||
position: badges.BadgePosition.topEnd(top: -3, end: -3),
|
||||
@@ -56,7 +69,14 @@ class AppModule {
|
||||
badgeColor: Theme.of(context).primaryColor,
|
||||
elevation: 1,
|
||||
),
|
||||
badgeContent: Text('$messages', style: const TextStyle(color: Colors.white, fontSize: 10, fontWeight: FontWeight.bold)),
|
||||
badgeContent: Text(
|
||||
'$messages',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
child: const Icon(Icons.chat),
|
||||
);
|
||||
},
|
||||
@@ -108,9 +128,19 @@ class AppModule {
|
||||
),
|
||||
};
|
||||
|
||||
if (!showFiltered) available.removeWhere((key, value) => settings.val().modulesSettings.hiddenModules.contains(key));
|
||||
if (!showFiltered) {
|
||||
available.removeWhere(
|
||||
(key, value) =>
|
||||
settings.val().modulesSettings.hiddenModules.contains(key),
|
||||
);
|
||||
}
|
||||
|
||||
return { for (var element in settings.val().modulesSettings.moduleOrder.where((element) => available.containsKey(element))) element : available[element]! };
|
||||
return {
|
||||
for (var element in settings.val().modulesSettings.moduleOrder.where(
|
||||
(element) => available.containsKey(element),
|
||||
))
|
||||
element: available[element]!,
|
||||
};
|
||||
}
|
||||
|
||||
static const int minBottomBarSlots = 3;
|
||||
@@ -150,26 +180,45 @@ class AppModule {
|
||||
return all.skip(slots).toList();
|
||||
}
|
||||
|
||||
Widget toListTile(BuildContext context, {Key? key, bool isReorder = false, Function()? onVisibleChange, bool isVisible = true}) => ListTile(
|
||||
Widget toListTile(
|
||||
BuildContext context, {
|
||||
Key? key,
|
||||
bool isReorder = false,
|
||||
Function()? onVisibleChange,
|
||||
bool isVisible = true,
|
||||
}) => ListTile(
|
||||
key: key,
|
||||
leading: CenteredLeading(icon()),
|
||||
title: Text(name),
|
||||
onTap: isReorder ? null : () => AppRoutes.openModule(context, this),
|
||||
trailing: isReorder
|
||||
? Row(mainAxisSize: MainAxisSize.min, children: [
|
||||
IconButton(onPressed: onVisibleChange, icon: Icon(isVisible ? Icons.visibility_outlined : Icons.visibility_off_outlined)),
|
||||
Icon(Icons.drag_handle_outlined)
|
||||
])
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: onVisibleChange,
|
||||
icon: Icon(
|
||||
isVisible
|
||||
? Icons.visibility_outlined
|
||||
: Icons.visibility_off_outlined,
|
||||
),
|
||||
),
|
||||
Icon(Icons.drag_handle_outlined),
|
||||
],
|
||||
)
|
||||
: const Icon(Icons.arrow_right),
|
||||
);
|
||||
|
||||
PersistentTabConfig toBottomTab(BuildContext context, {Widget Function(IconData icon)? iconBuilder}) => PersistentTabConfig(
|
||||
PersistentTabConfig toBottomTab(
|
||||
BuildContext context, {
|
||||
Widget Function(IconData icon)? iconBuilder,
|
||||
}) => PersistentTabConfig(
|
||||
screen: Breaker(breaker: breakerArea, child: create()),
|
||||
item: ItemConfig(
|
||||
activeForegroundColor: Theme.of(context).primaryColor,
|
||||
inactiveForegroundColor: Theme.of(context).colorScheme.secondary,
|
||||
icon: icon(),
|
||||
title: name
|
||||
activeForegroundColor: Theme.of(context).primaryColor,
|
||||
inactiveForegroundColor: Theme.of(context).colorScheme.secondary,
|
||||
icon: icon(),
|
||||
title: name,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user