9/20/1
This commit is contained in:
@@ -7,6 +7,7 @@ import 'package:SEFER/controller/notification/ride_available_controller.dart';
|
||||
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||
import 'package:SEFER/views/widgets/my_scafold.dart';
|
||||
import 'package:SEFER/views/widgets/mycircular.dart';
|
||||
import 'package:SEFER/views/widgets/mydialoug.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
@@ -119,20 +120,26 @@ class AvailableRidesPage extends StatelessWidget {
|
||||
// .then((value) {
|
||||
// var json = jsonDecode(res);
|
||||
if (res == "failure") {
|
||||
Get.defaultDialog(
|
||||
title:
|
||||
"This ride is already taken by another driver."
|
||||
.tr,
|
||||
middleText: '',
|
||||
titleStyle: AppStyle.title,
|
||||
middleTextStyle: AppStyle.title,
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok'.tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
// Get.back();
|
||||
// Get.back();
|
||||
}));
|
||||
MyDialog().getDialog(
|
||||
"This ride is already taken by another driver."
|
||||
.tr,
|
||||
'', () {
|
||||
Get.back();
|
||||
});
|
||||
// Get.defaultDialog(
|
||||
// title:
|
||||
// "This ride is already taken by another driver."
|
||||
// .tr,
|
||||
// middleText: '',
|
||||
// titleStyle: AppStyle.title,
|
||||
// middleTextStyle: AppStyle.title,
|
||||
// confirm: MyElevatedButton(
|
||||
// title: 'Ok'.tr,
|
||||
// onPressed: () {
|
||||
// Get.back();
|
||||
// // Get.back();
|
||||
// // Get.back();
|
||||
// }));
|
||||
} else if (jsonDecode(res)['status'] ==
|
||||
"success") {
|
||||
List<String> bodyToPassenger = [
|
||||
|
||||
@@ -1,77 +1,88 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:SEFER/constant/style.dart';
|
||||
import 'package:SEFER/controller/notification/notification_captain_controller.dart';
|
||||
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||
import 'package:SEFER/views/widgets/my_scafold.dart';
|
||||
import 'package:SEFER/views/widgets/mycircular.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class NotificationCaptain extends StatelessWidget {
|
||||
const NotificationCaptain({super.key});
|
||||
const NotificationCaptain({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Get.put(NotificationCaptainController());
|
||||
|
||||
return MyScafolld(
|
||||
title: 'Notifications'.tr,
|
||||
body: [
|
||||
GetBuilder<NotificationCaptainController>(
|
||||
builder: (notificationCaptainController) =>
|
||||
notificationCaptainController.isLoading
|
||||
? const MyCircularProgressIndicator()
|
||||
: SafeArea(
|
||||
child: ListView.builder(
|
||||
itemCount: notificationCaptainController
|
||||
.notificationData['message'].length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
if (notificationCaptainController
|
||||
.notificationData['message'] ==
|
||||
"No notification data found") {
|
||||
Get.defaultDialog();
|
||||
}
|
||||
var res = notificationCaptainController
|
||||
.notificationData['message'][index];
|
||||
return Card(
|
||||
elevation: 4,
|
||||
child: ListTile(
|
||||
onTap: () {
|
||||
Get.defaultDialog(
|
||||
title: res['title'],
|
||||
titleStyle: AppStyle.title.copyWith(
|
||||
fontWeight: FontWeight.bold),
|
||||
content: SizedBox(
|
||||
width: Get.width * .8,
|
||||
height: Get.height * .4,
|
||||
child: Text(
|
||||
res['body'],
|
||||
style: AppStyle.subtitle,
|
||||
),
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok',
|
||||
onPressed: () {
|
||||
//todo sql readen
|
||||
notificationCaptainController
|
||||
.updateNotification(res['id']);
|
||||
}));
|
||||
},
|
||||
leading:
|
||||
const Icon(Icons.notification_important),
|
||||
title: Text(
|
||||
res['title'],
|
||||
style: AppStyle.title,
|
||||
),
|
||||
subtitle: Text(
|
||||
res['body'],
|
||||
style: AppStyle.subtitle,
|
||||
),
|
||||
),
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
middle: Text('Notifications'.tr),
|
||||
leading: CupertinoNavigationBarBackButton(
|
||||
onPressed: () => Get.back(),
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: GetBuilder<NotificationCaptainController>(
|
||||
builder: (notificationCaptainController) =>
|
||||
notificationCaptainController.isLoading
|
||||
? const Center(child: CupertinoActivityIndicator())
|
||||
: ListView.builder(
|
||||
itemCount: notificationCaptainController
|
||||
.notificationData['message'].length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
if (notificationCaptainController
|
||||
.notificationData['message'] ==
|
||||
"No notification data found") {
|
||||
_showCupertinoDialog(context, 'No Notifications',
|
||||
'There are no notifications at this time.');
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
var res = notificationCaptainController
|
||||
.notificationData['message'][index];
|
||||
return CupertinoListTile(
|
||||
leading: const Icon(CupertinoIcons.bell_fill),
|
||||
title: Text(
|
||||
res['title'],
|
||||
style:
|
||||
CupertinoTheme.of(context).textTheme.textStyle,
|
||||
),
|
||||
subtitle: Text(
|
||||
res['body'],
|
||||
style: CupertinoTheme.of(context)
|
||||
.textTheme
|
||||
.tabLabelTextStyle,
|
||||
),
|
||||
onTap: () {
|
||||
_showCupertinoDialog(
|
||||
context,
|
||||
res['title'],
|
||||
res['body'],
|
||||
onConfirm: () {
|
||||
notificationCaptainController
|
||||
.updateNotification(res['id'].toString());
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
))
|
||||
],
|
||||
isleading: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showCupertinoDialog(BuildContext context, String title, String content,
|
||||
{VoidCallback? onConfirm}) {
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => CupertinoAlertDialog(
|
||||
title: Text(title),
|
||||
content: Text(content),
|
||||
actions: <CupertinoDialogAction>[
|
||||
CupertinoDialogAction(
|
||||
child: const Text('OK'),
|
||||
onPressed: onConfirm ?? () => Navigator.of(context).pop(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user