added guardian letters with chat and multiple answer functionalities
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'package:badges/badges.dart' as badges;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:persistent_bottom_nav_bar_v2/persistent_bottom_nav_bar_v2.dart';
|
||||
@@ -16,14 +15,18 @@ import '../../../view/pages/holidays/holidays_view.dart';
|
||||
import '../../../view/pages/marianum_dates/marianum_dates_view.dart';
|
||||
import '../../../view/pages/marianum_message/marianum_message_list_view.dart';
|
||||
import '../../../view/pages/more/roomplan/roomplan.dart';
|
||||
import '../../../view/pages/parent_letters/parent_letters_view.dart';
|
||||
import '../../../view/pages/talk/chat_list.dart';
|
||||
import '../../../view/pages/ticker/ticker_view.dart';
|
||||
import '../../../view/pages/timetable/timetable.dart';
|
||||
import '../../../widget/breaker/breaker.dart';
|
||||
import '../../../widget/centered_leading.dart';
|
||||
import '../../../widget/module_badge_icon.dart';
|
||||
import '../infrastructure/loadable_state/loadable_state.dart';
|
||||
import 'chat_list/bloc/chat_list_bloc.dart';
|
||||
import 'chat_list/bloc/chat_list_state.dart';
|
||||
import 'parent_letters/bloc/parent_letters_bloc.dart';
|
||||
import 'parent_letters/bloc/parent_letters_state.dart';
|
||||
import 'settings/bloc/settings_cubit.dart';
|
||||
|
||||
class AppModule {
|
||||
@@ -46,6 +49,7 @@ class AppModule {
|
||||
static const Map<Modules, Set<AccessRequirement>> requirements = {
|
||||
Modules.talk: {AccessRequirement.nextcloud},
|
||||
Modules.files: {AccessRequirement.nextcloud},
|
||||
Modules.parentLetters: {AccessRequirement.guardian},
|
||||
};
|
||||
|
||||
static bool isAvailableFor(Modules module, Session? session) =>
|
||||
@@ -64,6 +68,18 @@ class AppModule {
|
||||
breakerArea: BreakerArea.timetable,
|
||||
create: Timetable.new,
|
||||
),
|
||||
Modules.parentLetters: AppModule(
|
||||
Modules.parentLetters,
|
||||
name: 'Elternbriefe',
|
||||
icon: () =>
|
||||
BlocBuilder<ParentLettersBloc, LoadableState<ParentLettersState>>(
|
||||
builder: (context, state) => ModuleBadgeIcon(
|
||||
icon: Icons.mail_outline,
|
||||
count: state.data?.unreadCount ?? 0,
|
||||
),
|
||||
),
|
||||
create: ParentLettersView.new,
|
||||
),
|
||||
Modules.ticker: AppModule(
|
||||
Modules.ticker,
|
||||
name: 'Ticker',
|
||||
@@ -77,34 +93,15 @@ class AppModule {
|
||||
Modules.talk,
|
||||
name: 'Talk',
|
||||
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);
|
||||
return badges.Badge(
|
||||
showBadge: messages > 0,
|
||||
position: badges.BadgePosition.topEnd(top: -3, end: -3),
|
||||
stackFit: StackFit.loose,
|
||||
badgeStyle: badges.BadgeStyle(
|
||||
padding: const EdgeInsets.all(3),
|
||||
badgeColor: Theme.of(context).primaryColor,
|
||||
elevation: 1,
|
||||
),
|
||||
badgeContent: Text(
|
||||
'$messages',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
child: const Icon(Icons.chat),
|
||||
);
|
||||
},
|
||||
builder: (context, state) => ModuleBadgeIcon(
|
||||
icon: Icons.chat,
|
||||
count:
|
||||
state.data?.rooms?.data.fold<int>(
|
||||
0,
|
||||
(sum, room) => sum + room.unreadMessages,
|
||||
) ??
|
||||
0,
|
||||
),
|
||||
),
|
||||
breakerArea: BreakerArea.talk,
|
||||
create: ChatList.new,
|
||||
@@ -299,6 +296,7 @@ class AppModule {
|
||||
|
||||
enum Modules {
|
||||
timetable,
|
||||
parentLetters,
|
||||
ticker,
|
||||
talk,
|
||||
files,
|
||||
|
||||
Reference in New Issue
Block a user