Skip to content

Commit

Permalink
fix: removed unnecessary send alert button in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
vskvj3 committed Jun 26, 2023
1 parent 8a1d1c4 commit a427608
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
3 changes: 2 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//import 'package:AlertMe/pages/Login_RegisterPage.dart';
import 'dart:ui';

import 'package:alert_me/utils/find_distance.dart';
import 'package:alert_me/widgets/alert_notification.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
Expand Down Expand Up @@ -42,7 +44,6 @@ void main() async {
'Message also contained a notification: ${message.notification}');
}
});

runApp(const MyApp());
}

Expand Down
2 changes: 1 addition & 1 deletion lib/pages/alert_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class _AlertPageState extends State<AlertPage> {
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
))
)),
],
);
}
Expand Down
26 changes: 18 additions & 8 deletions lib/pages/emergency_contacts_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:convert';
import 'package:alert_me/utils/emergency_notif.dart';
import 'package:alert_me/utils/validate_data.dart';
import 'package:alert_me/widgets/text_field.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -87,7 +88,10 @@ class _EmergencyContactsPageState extends State<EmergencyContactsPage> {
_phoneNumberController.text.isNotEmpty &&
emergencyContactList.length < 5 &&
PhoneValidator.validatePhoneNumber(
_phoneNumberController.text) && !(PhoneValidator.checkDuplicate(emergencyContactList,_phoneNumberController.text))) {
_phoneNumberController.text) &&
!(PhoneValidator.checkDuplicate(
emergencyContactList,
_phoneNumberController.text))) {
final tempList = [
_nameController.text,
_phoneNumberController.text
Expand All @@ -108,8 +112,8 @@ class _EmergencyContactsPageState extends State<EmergencyContactsPage> {
}
}
setState(() {
_phoneNumberController.text ="";
_nameController.text="";
_phoneNumberController.text = "";
_nameController.text = "";
emergencyContactList;
});
}
Expand Down Expand Up @@ -149,11 +153,11 @@ class _EmergencyContactsPageState extends State<EmergencyContactsPage> {
trailing: TextButton(
onPressed: () async {
setState(() {
emergencyContactList.removeAt(index);
});
await EmergencyDataStorage.storeContacts(
json.encode(emergencyContactList),
);
emergencyContactList.removeAt(index);
});
await EmergencyDataStorage.storeContacts(
json.encode(emergencyContactList),
);
},
child: const Text("Remove")),
contentPadding: const EdgeInsets.only(left: 10),
Expand All @@ -170,6 +174,12 @@ class _EmergencyContactsPageState extends State<EmergencyContactsPage> {
),
),
],
// ElevatedButton(
// onPressed: () {
// AppNotif().showNotification(
// title: "Send Alert", body: "Press to send alert");
// },
// child: Text("test"))
],
),
),
Expand Down
10 changes: 8 additions & 2 deletions lib/utils/emergency_notif.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';

class AppNotif {
Expand All @@ -10,15 +11,19 @@ class AppNotif {
InitializationSettings(android: initializationSettingsAndroid);
await appNotif.initialize(initializationSettings,
onDidReceiveBackgroundNotificationResponse:
(NotificationResponse notificationResponse) async {});
(NotificationResponse notificationResponse) async {
debugPrint("pressed background notification");
}, onDidReceiveNotificationResponse:
(NotificationResponse norificationResponse) async {
debugPrint("pressed notification");
});
}

notificationDetails() {
return const NotificationDetails(
android: AndroidNotificationDetails('1', 'Notification Button',
playSound: false,
enableVibration: false,
showWhen: false,
importance: Importance.max,
icon: 'mipmap/ic_launcher',
ongoing: true,
Expand All @@ -29,6 +34,7 @@ class AppNotif {

Future showNotification(
{int id = 111, String? title, String? body, String? payload}) async {
debugPrint("indise show notification");
return appNotif.show(id, title, body, await notificationDetails());
}
}

0 comments on commit a427608

Please sign in to comment.