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.
HMG_Patient_App/lib/pages/DrawerPages/notifications_page.dart

90 lines
3.1 KiB
Dart

import 'package:diplomaticquarterapp/core/viewModels/notifications_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
class NotificationsPage extends StatelessWidget {
getDateForm(String date) {
DateTime d = DateUtil.convertStringToDate(date);
String monthName = DateUtil.getMonth(d.month).toString();
TimeOfDay timeOfDay = TimeOfDay(hour: d.hour, minute: d.minute);
String minute = timeOfDay.minute < 10
? timeOfDay.minute.toString().padLeft(2, '0')
: timeOfDay.minute.toString();
String hour = '${timeOfDay.hourOfPeriod}:$minute';
if (timeOfDay.period == DayPeriod.am) {
hour = hour + "AM";
} else {
{
hour = hour + "PM";
}
}
//DayPeriod.am
return monthName + ',${d.day},${d.year}, $hour';
}
@override
Widget build(BuildContext context) {
var prescriptionReport;
return BaseView<NotificationViewModel>(
onModelReady: (model) => model.getNotifications(),
builder: (_, model, widget) => AppScaffold(
isShowAppBar: true,
appBarTitle: TranslationBase.of(context).notifications,
baseViewModel: model,
body: ListView.builder(
itemBuilder: (context, index) => Container(
width: double.infinity,
margin: EdgeInsets.only(top: 5, left: 10, right: 10, bottom: 5),
padding: EdgeInsets.all(8.0),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(10.0),
),
border: Border.all(
color: model.notifications[index].isRead
? Colors.grey[200]
: Theme.of(context).primaryColor,
width: 0.5),
),
child: Row(
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Texts(
getDateForm(model.notifications[index].createdOn)),
SizedBox(
height: 5,
),
Texts(model.notifications[index].message),
SizedBox(
height: 5,
),
Texts(model.notifications[index].notificationType),
],
),
),
),
SizedBox(
width: 15,
),
],
),
),
itemCount: model.notifications.length,
),
),
);
}
}