diff --git a/android/app/src/main/res/drawable/estrogen.xml b/android/app/src/main/res/drawable/estrogen.xml
new file mode 100644
index 0000000..f2bc793
--- /dev/null
+++ b/android/app/src/main/res/drawable/estrogen.xml
@@ -0,0 +1,11 @@
+
+
+
diff --git a/android/app/src/main/res/drawable/take_your_hrt.png b/android/app/src/main/res/drawable/take_your_hrt.png
new file mode 100644
index 0000000..b8ef883
Binary files /dev/null and b/android/app/src/main/res/drawable/take_your_hrt.png differ
diff --git a/lib/main.dart b/lib/main.dart
index 033adf8..881a8de 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,5 +1,7 @@
import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/material.dart';
+import 'package:hrt/notification.dart';
+import 'package:permission_handler/permission_handler.dart';
void main() {
runApp(const App());
@@ -48,71 +50,27 @@ class HomePage extends StatefulWidget {
}
class _HomePageState extends State {
- int _counter = 0;
-
- void _incrementCounter() {
- setState(() {
- // This call to setState tells the Flutter framework that something has
- // changed in this State, which causes it to rerun the build method below
- // so that the display can reflect the updated values. If we changed
- // _counter without calling setState(), then the build method would not be
- // called again, and so nothing would appear to happen.
- _counter++;
- });
- }
-
@override
Widget build(BuildContext context) {
- // This method is rerun every time setState is called, for instance as done
- // by the _incrementCounter method above.
- //
- // The Flutter framework has been optimized to make rerunning build methods
- // fast, so that you can just rebuild anything that needs updating rather
- // than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
- // TRY THIS: Try changing the color here to a specific color (to
- // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
- // change color while the other colors stay the same.
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
- // Here we take the value from the MyHomePage object that was created by
- // the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
- // Center is a layout widget. It takes a single child and positions it
- // in the middle of the parent.
- child: Column(
- // Column is also a layout widget. It takes a list of children and
- // arranges them vertically. By default, it sizes itself to fit its
- // children horizontally, and tries to be as tall as its parent.
- //
- // Column has various properties to control how it sizes itself and
- // how it positions its children. Here we use mainAxisAlignment to
- // center the children vertically; the main axis here is the vertical
- // axis because Columns are vertical (the cross axis would be
- // horizontal).
- //
- // TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
- // action in the IDE, or press "p" in the console), to see the
- // wireframe for each widget.
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- const Text(
- 'You have pushed the button this many times:',
- ),
- Text(
- '$_counter',
- style: Theme.of(context).textTheme.headlineMedium,
- ),
- ],
+ child: TextButton(
+ child: const Text("Test notification"),
+ onPressed: () async {
+ await Permission.notification.isDenied.then((value) async {
+ if (value) {
+ await Permission.notification.request();
+ }
+ });
+
+ sendNotification();
+ },
),
),
- floatingActionButton: FloatingActionButton(
- onPressed: _incrementCounter,
- tooltip: 'Increment',
- child: const Icon(Icons.add),
- ), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
diff --git a/lib/notification.dart b/lib/notification.dart
new file mode 100644
index 0000000..a6fa4db
--- /dev/null
+++ b/lib/notification.dart
@@ -0,0 +1,32 @@
+import 'package:flutter_local_notifications/flutter_local_notifications.dart';
+
+void sendNotification() async {
+ var initialized = await FlutterLocalNotificationsPlugin().initialize(
+ const InitializationSettings(
+ android: AndroidInitializationSettings('estrogen'),
+ ),
+ );
+
+ if (initialized != true) {
+ throw "Not initialized";
+ }
+
+ await FlutterLocalNotificationsPlugin().show(
+ 1,
+ null,
+ null,
+ const NotificationDetails(
+ android: AndroidNotificationDetails(
+ 'hrt',
+ 'HRT',
+ autoCancel: false,
+ styleInformation: BigPictureStyleInformation(
+ DrawableResourceAndroidBitmap('take_your_hrt'),
+ ),
+ importance: Importance.max,
+ ongoing: true,
+ actions: [AndroidNotificationAction("confirmation", "Done!")],
+ ),
+ ),
+ );
+}
diff --git a/pubspec.lock b/pubspec.lock
index fa4db00..3e5192d 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -1,6 +1,14 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
+ args:
+ dependency: transitive
+ description:
+ name: args
+ sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.4.2"
async:
dependency: transitive
description:
@@ -49,6 +57,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.6"
+ dbus:
+ dependency: transitive
+ description:
+ name: dbus
+ sha256: "6f07cba3f7b3448d42d015bfd3d53fe12e5b36da2423f23838efc1d5fb31a263"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.7.8"
dynamic_color:
dependency: "direct main"
description:
@@ -65,6 +81,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.1"
+ ffi:
+ dependency: transitive
+ description:
+ name: ffi
+ sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.0"
flutter:
dependency: "direct main"
description: flutter
@@ -78,6 +102,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
+ flutter_local_notifications:
+ dependency: "direct main"
+ description:
+ name: flutter_local_notifications
+ sha256: "3002092e5b8ce2f86c3361422e52e6db6776c23ee21e0b2f71b892bf4259ef04"
+ url: "https://pub.dev"
+ source: hosted
+ version: "15.1.1"
+ flutter_local_notifications_linux:
+ dependency: transitive
+ description:
+ name: flutter_local_notifications_linux
+ sha256: "33f741ef47b5f63cc7f78fe75eeeac7e19f171ff3c3df054d84c1e38bedb6a03"
+ url: "https://pub.dev"
+ source: hosted
+ version: "4.0.0+1"
+ flutter_local_notifications_platform_interface:
+ dependency: transitive
+ description:
+ name: flutter_local_notifications_platform_interface
+ sha256: "7cf643d6d5022f3baed0be777b0662cce5919c0a7b86e700299f22dc4ae660ef"
+ url: "https://pub.dev"
+ source: hosted
+ version: "7.0.0+1"
flutter_test:
dependency: "direct dev"
description: flutter
@@ -123,6 +171,62 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.8.3"
+ permission_handler:
+ dependency: "direct main"
+ description:
+ name: permission_handler
+ sha256: "284a66179cabdf942f838543e10413246f06424d960c92ba95c84439154fcac8"
+ url: "https://pub.dev"
+ source: hosted
+ version: "11.0.1"
+ permission_handler_android:
+ dependency: transitive
+ description:
+ name: permission_handler_android
+ sha256: ace7d15a3d1a4a0b91c041d01e5405df221edb9de9116525efc773c74e6fc790
+ url: "https://pub.dev"
+ source: hosted
+ version: "11.0.5"
+ permission_handler_apple:
+ dependency: transitive
+ description:
+ name: permission_handler_apple
+ sha256: "99e220bce3f8877c78e4ace901082fb29fa1b4ebde529ad0932d8d664b34f3f5"
+ url: "https://pub.dev"
+ source: hosted
+ version: "9.1.4"
+ permission_handler_platform_interface:
+ dependency: transitive
+ description:
+ name: permission_handler_platform_interface
+ sha256: f2343e9fa9c22ae4fd92d4732755bfe452214e7189afcc097380950cf567b4b2
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.11.5"
+ permission_handler_windows:
+ dependency: transitive
+ description:
+ name: permission_handler_windows
+ sha256: cc074aace208760f1eee6aa4fae766b45d947df85bc831cde77009cdb4720098
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.1.3"
+ petitparser:
+ dependency: transitive
+ description:
+ name: petitparser
+ sha256: eeb2d1428ee7f4170e2bd498827296a18d4e7fc462b71727d111c0ac7707cfa6
+ url: "https://pub.dev"
+ source: hosted
+ version: "6.0.1"
+ plugin_platform_interface:
+ dependency: transitive
+ description:
+ name: plugin_platform_interface
+ sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.6"
sky_engine:
dependency: transitive
description: flutter
@@ -176,6 +280,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.6.1"
+ timezone:
+ dependency: transitive
+ description:
+ name: timezone
+ sha256: "1cfd8ddc2d1cfd836bc93e67b9be88c3adaeca6f40a00ca999104c30693cdca0"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.9.2"
vector_math:
dependency: transitive
description:
@@ -192,6 +304,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.1.4-beta"
+ xdg_directories:
+ dependency: transitive
+ description:
+ name: xdg_directories
+ sha256: "589ada45ba9e39405c198fe34eb0f607cddb2108527e658136120892beac46d2"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.0.3"
+ xml:
+ dependency: transitive
+ description:
+ name: xml
+ sha256: af5e77e9b83f2f4adc5d3f0a4ece1c7f45a2467b695c2540381bac793e34e556
+ url: "https://pub.dev"
+ source: hosted
+ version: "6.4.2"
sdks:
dart: ">=3.2.0-134.1.beta <4.0.0"
flutter: ">=3.4.0-17.0.pre"
diff --git a/pubspec.yaml b/pubspec.yaml
index 18a9b4e..33278ce 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -36,6 +36,8 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
dynamic_color: ^1.6.7
+ flutter_local_notifications: ^15.1.1
+ permission_handler: ^11.0.1
dev_dependencies:
flutter_test: