You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudsolutions-atoms/lib/views/pages/user/notifications/notifications_page.dart

100 lines
3.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../../../controllers/localization/localization.dart';
import '../../../../controllers/providers/api/notifications_provider.dart';
import '../../../../controllers/providers/api/user_provider.dart';
import '../../../../controllers/providers/settings/setting_provider.dart';
import '../../../../models/subtitle.dart';
import '../../../../models/user.dart';
import '../../../app_style/colors.dart';
import '../../../widgets/buttons/app_back_button.dart';
import '../../../widgets/loaders/loading_manager.dart';
import 'notifications_list.dart';
class NotificationsPage extends StatefulWidget {
static final String id = "/notifications";
@override
_NotificationsPageState createState() => _NotificationsPageState();
}
class _NotificationsPageState extends State<NotificationsPage>
with TickerProviderStateMixin{
NotificationsProvider? _notificationsProvider;
UserProvider? _userProvider;
SettingProvider? _settingProvider;
Subtitle? _subtitle;
@override
Widget build(BuildContext context) {
_notificationsProvider = Provider.of<NotificationsProvider>(context);
_userProvider = Provider.of<UserProvider>(context);
_settingProvider = Provider.of<SettingProvider>(context);
_subtitle = AppLocalization.of(context)?.subtitle;
return Scaffold(
body: SafeArea(
child: LoadingManager(
isLoading: _notificationsProvider?.isLoading??false,
isFailedLoading: _notificationsProvider?.notifications == null,
stateCode: _notificationsProvider?.stateCode??0,
onRefresh: () async {
_notificationsProvider?.reset();
await _notificationsProvider?.getNotifications(
user: _userProvider?.user??User(),
host: _settingProvider?.host??"",
hospitalId: _userProvider?.user?.hospital?.id??"",
);
},
child: Stack(
children: [
Column(
children: [
Container(
color:AColors.primaryColor,
padding: const EdgeInsets.symmetric(horizontal: 0,vertical: 4),
child: Column(
children: [
Row(
children: [
ABackButton(),
Expanded(
child: Center(
child: Text(
_subtitle?.notifications??"",
style: Theme.of(context).textTheme.headline6?.copyWith(
color: AColors.white,
fontStyle: FontStyle.italic
),
),
),
),
SizedBox(width: 48,)
],
),
],
),
),
Expanded(
child: NotificationsList(
nextPage: _notificationsProvider?.nextPage,
onLazyLoad: () async {
await _notificationsProvider?.getNotifications(
user: _userProvider?.user??User(),
host: _settingProvider?.host??"",
hospitalId: _userProvider?.user?.hospital?.id??"",
);
},
notifications: _notificationsProvider?.notifications,
),
),
],
),
],
),
),
),
);
}
}