Commit f0dcc64
Changed files (4)
lib
components
screens
subsettings
lib/components/CustomBanner.dart
@@ -0,0 +1,50 @@
+import 'package:flutter/material.dart';
+
+/// A floating banner to display information.
+///
+/// The banner allows to perform actions.
+///
+/// Example usage:
+/// ```dart
+/// CustomBanner(
+/// content: Text(localizations.warnNeedsRestartForUsingApp),
+/// action: TextButton(
+/// onPressed: () => Restart.restartApp(),
+/// child: Text(localizations.restartNow),
+/// )
+/// )
+/// ```
+class CustomBanner extends StatelessWidget {
+ /// Create a banner that displays information and an action.
+ const CustomBanner({super.key, required this.content, this.action});
+
+ /// The main content of the banner.
+ ///
+ /// Gets displayed on the left side.
+ final Widget content;
+
+ /// Primary action of the banner.
+ ///
+ /// Usually a [TextButton].
+ ///
+ /// When this is larger than the screen width, overflow occurs.
+ final Widget? action;
+
+ @override
+ Widget build(BuildContext context) => Container(
+ margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 4),
+ padding: const EdgeInsets.all(15),
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(20),
+ color: Theme.of(context).cardColor,
+ ),
+ child: Row(
+ children: [
+ Expanded(child: content),
+ if (action != null)
+ action!,
+ ],
+ ),
+ );
+
+}
\ No newline at end of file
lib/screens/subsettings/delete_data_screen.dart
@@ -1,6 +1,7 @@
import 'dart:io';
import 'dart:math';
+import 'package:blood_pressure_app/components/CustomBanner.dart';
import 'package:blood_pressure_app/components/consistent_future_builder.dart';
import 'package:blood_pressure_app/main.dart';
import 'package:flutter/material.dart';
@@ -42,13 +43,12 @@ class _DeleteDataScreenState extends State<DeleteDataScreen> {
body: Column(
children: [
if (_deletedData)
- MaterialBanner(
+ CustomBanner(
content: Text(localizations.warnNeedsRestartForUsingApp),
- actions: [
- TextButton(onPressed: () {
- Restart.restartApp();
- }, child: Text(localizations.restartNow))
- ]
+ action: TextButton(
+ onPressed: () => Restart.restartApp(),
+ child: Text(localizations.restartNow),
+ )
),
Expanded(
child: Container(
lib/main.dart
@@ -143,6 +143,23 @@ class AppRoot extends StatelessWidget {
border: inputBorder,
enabledBorder: inputBorder,
),
+ pageTransitionsTheme: const PageTransitionsTheme(builders: {
+ TargetPlatform.android: ZoomPageTransitionsBuilder()
+ }),
+ appBarTheme: const AppBarTheme(
+ centerTitle: true,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.only(
+ bottomRight: Radius.circular(15),
+ bottomLeft: Radius.circular(15),
+ ),
+ ),
+ ),
+ snackBarTheme: SnackBarThemeData(
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(8),
+ ),
+ ),
);
}
}