79 lines
2.2 KiB
Dart
79 lines
2.2 KiB
Dart
import 'package:dynamic_color/dynamic_color.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:hrt/notification.dart';
|
|
import 'package:hrt/tasks.dart';
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
void main() {
|
|
runApp(const App());
|
|
}
|
|
|
|
class App extends StatelessWidget {
|
|
const App({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
setupBackgroundTasks();
|
|
return DynamicColorBuilder(
|
|
builder: ((lightDynamic, darkDynamic) => MaterialApp(
|
|
title: "HRT",
|
|
theme: ThemeData(
|
|
brightness: Brightness.light,
|
|
useMaterial3: true,
|
|
colorScheme: lightDynamic,
|
|
),
|
|
darkTheme: ThemeData(
|
|
brightness: Brightness.dark,
|
|
useMaterial3: true,
|
|
colorScheme: darkDynamic,
|
|
),
|
|
themeMode: ThemeMode.system,
|
|
home: const HomePage(title: "HRT"))),
|
|
);
|
|
}
|
|
}
|
|
|
|
class HomePage extends StatefulWidget {
|
|
const HomePage({super.key, required this.title});
|
|
|
|
// This widget is the home page of your application. It is stateful, meaning
|
|
// that it has a State object (defined below) that contains fields that affect
|
|
// how it looks.
|
|
|
|
// This class is the configuration for the state. It holds the values (in this
|
|
// case the title) provided by the parent (in this case the App widget) and
|
|
// used by the build method of the State. Fields in a Widget subclass are
|
|
// always marked "final".
|
|
|
|
final String title;
|
|
|
|
@override
|
|
State<HomePage> createState() => _HomePageState();
|
|
}
|
|
|
|
class _HomePageState extends State<HomePage> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
|
title: Text(widget.title),
|
|
),
|
|
body: Center(
|
|
child: TextButton(
|
|
child: const Text("Test notification"),
|
|
onPressed: () async {
|
|
await Permission.notification.isDenied.then((value) async {
|
|
if (value) {
|
|
await Permission.notification.request();
|
|
}
|
|
});
|
|
|
|
scheduleNotification();
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|