feat: Allow showing regular notifications

This commit is contained in:
2023-07-29 13:12:41 +02:00
parent 30ef477999
commit 6da35cd0ba
11 changed files with 604 additions and 263 deletions

View File

@@ -10,6 +10,7 @@ import 'package:file_picker/file_picker.dart';
/// The id of the notification channel.
const channelId = "me.polynom.moxplatform.testing3";
const otherChannelId = "me.polynom.moxplatform.testing4";
void main() {
runApp(const MyApp());
@@ -46,6 +47,11 @@ class MyAppState extends State<MyApp> {
channelId,
false,
);
await MoxplatformPlugin.notifications.createNotificationChannel(
"Test notification channel for warnings",
otherChannelId,
false,
);
await MoxplatformPlugin.notifications.setI18n(
NotificationI18nData(
reply: "答える",
@@ -190,6 +196,34 @@ class MyHomePage extends StatelessWidget {
},
child: const Text('Show messaging notification'),
),
ElevatedButton(
onPressed: () {
MoxplatformPlugin.notifications.showNotification(
RegularNotification(
id: 4384,
title: 'Warning',
body: 'Something brokey',
channelId: otherChannelId,
icon: NotificationIcon.warning,
),
);
},
child: const Text('Show warning notification'),
),
ElevatedButton(
onPressed: () {
MoxplatformPlugin.notifications.showNotification(
RegularNotification(
id: 4384,
title: 'Error',
body: "Lol, you're on your own",
channelId: otherChannelId,
icon: NotificationIcon.error,
),
);
},
child: const Text('Show error notification'),
),
ElevatedButton(
onPressed: () async {
final result = await FilePicker.platform.pickFiles(