diff --git a/example/lib/l10n/app_en.arb b/example/lib/l10n/app_en.arb index d495dbd..e9a9886 100644 --- a/example/lib/l10n/app_en.arb +++ b/example/lib/l10n/app_en.arb @@ -56,8 +56,9 @@ "flutterCacheManagerDesc": "Desc", "@_FLUTTER_LOCAL_NOTIFICATIONS": {}, - "flutterLocalNotificationsTitle": "Title", - "flutterLocalNotificationsDesc": "Desc", + "flutterLocalNotificationsHintTitle": "Notification title", + "flutterLocalNotificationsHintBody": "Notification body", + "flutterLocalNotificationsBtn": "Send", "@_FLUTTER_SECURE_STORAGE": {}, "flutterSecureStorageTitle": "Title", diff --git a/example/lib/l10n/app_ru.arb b/example/lib/l10n/app_ru.arb index ee25872..8e1284e 100644 --- a/example/lib/l10n/app_ru.arb +++ b/example/lib/l10n/app_ru.arb @@ -56,8 +56,9 @@ "flutterCacheManagerDesc": "Описание", "@_FLUTTER_LOCAL_NOTIFICATIONS": {}, - "flutterLocalNotificationsTitle": "Заголовок", - "flutterLocalNotificationsDesc": "Описание", + "flutterLocalNotificationsHintTitle": "Заголовок уведомления", + "flutterLocalNotificationsHintBody": "Текст уведомления", + "flutterLocalNotificationsBtn": "Отправить", "@_FLUTTER_SECURE_STORAGE": {}, "flutterSecureStorageTitle": "Заголовок", diff --git a/example/lib/packages/flutter_local_notifications/model.dart b/example/lib/packages/flutter_local_notifications/model.dart index 65b62db..c8c9406 100644 --- a/example/lib/packages/flutter_local_notifications/model.dart +++ b/example/lib/packages/flutter_local_notifications/model.dart @@ -1,10 +1,17 @@ import 'package:flutter/widgets.dart'; +import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:scoped_model/scoped_model.dart'; /// Model for [FlutterLocalNotificationsPage] class FlutterLocalNotificationsModel extends Model { /// Get [ScopedModel] - static FlutterLocalNotificationsModel of(BuildContext context) => ScopedModel.of(context); + static FlutterLocalNotificationsModel of(BuildContext context) => + ScopedModel.of(context); + + final FlutterLocalNotificationsPlugin notification = + FlutterLocalNotificationsPlugin(); + + final notificationID = 1; /// Error String? _error; @@ -14,4 +21,25 @@ class FlutterLocalNotificationsModel extends Model { /// Public is error bool get isError => _error != null; -} \ No newline at end of file + + /// Show local notification + Future showNotification({ + required String title, + required String body, + }) async { + try { + // Cansel if already run + await notification.cancel(notificationID); + // Show notification + await notification.show( + notificationID, + title, + body, + null, + ); + } catch (e) { + _error = e.toString(); + notifyListeners(); + } + } +} diff --git a/example/lib/packages/flutter_local_notifications/page.dart b/example/lib/packages/flutter_local_notifications/page.dart index 389f80b..5bd8707 100644 --- a/example/lib/packages/flutter_local_notifications/page.dart +++ b/example/lib/packages/flutter_local_notifications/page.dart @@ -5,8 +5,8 @@ import 'package:flutter_example_packages/packages/flutter_local_notifications/pa import 'package:flutter_example_packages/widgets/base/export.dart'; import 'package:flutter_example_packages/widgets/blocks/block_alert.dart'; import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; -import 'package:flutter_example_packages/widgets/blocks/block_item.dart'; import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; class FlutterLocalNotificationsPage extends AppStatefulWidget { @@ -23,6 +23,9 @@ class FlutterLocalNotificationsPage extends AppStatefulWidget { class _FlutterLocalNotificationsPageState extends AppState { + final TextEditingController _titleController = TextEditingController(); + final TextEditingController _bodyController = TextEditingController(); + @override Widget buildWide( BuildContext context, @@ -44,10 +47,36 @@ class _FlutterLocalNotificationsPageState Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - BlockItem( - title: l10n.flutterLocalNotificationsTitle, - desc: l10n.flutterLocalNotificationsDesc, - value: null, + TextField( + controller: _titleController, + decoration: InputDecoration( + hintText: l10n.flutterLocalNotificationsHintTitle, + ), + ), + const SizedBox(height: 18), + TextField( + controller: _bodyController, + decoration: InputDecoration( + hintText: l10n.flutterLocalNotificationsHintBody, + ), + ), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: () => model.showNotification( + title: _titleController.text.isEmpty + ? l10n.flutterLocalNotificationsHintTitle + : _titleController.text, + body: _bodyController.text.isEmpty + ? l10n.flutterLocalNotificationsHintBody + : _bodyController.text, + ), + child: TextBodyLarge( + l10n.flutterLocalNotificationsBtn, + color: Colors.white, + ), + ), ), ], ), diff --git a/example/lib/pages/home/page.dart b/example/lib/pages/home/page.dart index 108e3e1..7b6e4e4 100644 --- a/example/lib/pages/home/page.dart +++ b/example/lib/pages/home/page.dart @@ -135,7 +135,7 @@ class _HomePageState extends AppState { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - TextTitleLarge( + TextHeadlineMedium( l10n.homeWelcomeTitle, color: Colors.white, ), @@ -143,7 +143,7 @@ class _HomePageState extends AppState { height: media.orientation == Orientation.portrait ? 40 : 20, ), - TextBodyLarge( + TextTitleMedium( l10n.homeWelcomeText(packages.length), color: Colors.white, ) diff --git a/example/lib/pages/home/widgets/home_app_bar.dart b/example/lib/pages/home/widgets/home_app_bar.dart index b47a5e2..c28d2a9 100644 --- a/example/lib/pages/home/widgets/home_app_bar.dart +++ b/example/lib/pages/home/widgets/home_app_bar.dart @@ -66,13 +66,14 @@ class _HomeAppBarState extends AppState { ? TextField( focusNode: _searchFocus, controller: _searchController, - style: theme.textTheme.titleSmall?.copyWith(color: Colors.white), + style: theme.textTheme.titleLarge?.copyWith(color: Colors.white), cursorColor: Colors.white, decoration: InputDecoration( hintText: l10n.homeSearchTitle, hintStyle: - theme.textTheme.titleSmall?.copyWith(color: Colors.white54), + theme.textTheme.titleLarge?.copyWith(color: Colors.white54), border: InputBorder.none, + contentPadding: const EdgeInsets.all(0), ), onChanged: (value) { widget.onChangeSearch.call(value); diff --git a/example/lib/pages/home/widgets/package_list_item.dart b/example/lib/pages/home/widgets/package_list_item.dart index 43331ca..7250ca9 100644 --- a/example/lib/pages/home/widgets/package_list_item.dart +++ b/example/lib/pages/home/widgets/package_list_item.dart @@ -67,7 +67,7 @@ class PackageListItemWidget extends AppStatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - TextTitleSmall(item.key), + TextTitleLarge(item.key), const SizedBox(height: 10), TextBodyMedium( item.desc, diff --git a/example/lib/theme/theme.dart b/example/lib/theme/theme.dart index c4659d5..ff640db 100644 --- a/example/lib/theme/theme.dart +++ b/example/lib/theme/theme.dart @@ -8,6 +8,8 @@ final appTheme = ThemeData( primary: AppColors.primary, secondary: AppColors.secondary, ), + + /// [Card] cardTheme: CardTheme( clipBehavior: Clip.antiAlias, margin: const EdgeInsets.all(0), @@ -18,27 +20,42 @@ final appTheme = ThemeData( ), ), + /// [TextField] + inputDecorationTheme: const InputDecorationTheme( + contentPadding: EdgeInsets.symmetric( + vertical: 14, + horizontal: 16, + ), + border: OutlineInputBorder(), + ), + + /// [ElevatedButton] + elevatedButtonTheme: ElevatedButtonThemeData( + style: ElevatedButton.styleFrom( + backgroundColor: AppColors.secondary, + minimumSize: const Size.fromHeight(45), + ), + ), + /// [OutlinedButton] outlinedButtonTheme: OutlinedButtonThemeData( style: ButtonStyle( - foregroundColor: MaterialStateProperty.resolveWith( - (Set states) { - if (states.contains(MaterialState.disabled)) { - return AppColors.secondary.withOpacity(0.4); - } else { - return AppColors.secondary; - } - } - ), + foregroundColor: + MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return AppColors.secondary.withOpacity(0.4); + } else { + return AppColors.secondary; + } + }), side: MaterialStateProperty.resolveWith( - (Set states) { - if (states.contains(MaterialState.disabled)) { - return BorderSide(color: AppColors.secondary.withOpacity(0.4)); - } else { - return const BorderSide(color: AppColors.secondary); - } - } - ), + (Set states) { + if (states.contains(MaterialState.disabled)) { + return BorderSide(color: AppColors.secondary.withOpacity(0.4)); + } else { + return const BorderSide(color: AppColors.secondary); + } + }), ), ), @@ -49,7 +66,7 @@ final appTheme = ThemeData( fontWeight: FontWeight.bold, ), headlineMedium: GoogleFonts.roboto( - fontSize: 36, + fontSize: 30, fontWeight: FontWeight.bold, ), headlineSmall: GoogleFonts.roboto( @@ -57,13 +74,16 @@ final appTheme = ThemeData( fontWeight: FontWeight.bold, ), titleLarge: GoogleFonts.roboto( - fontSize: 44, + fontSize: 20, + height: 1.3, ), titleMedium: GoogleFonts.roboto( - fontSize: 36, + fontSize: 18, + height: 1.3, ), titleSmall: GoogleFonts.roboto( - fontSize: 24, + fontSize: 14, + height: 1.3, ), bodyLarge: GoogleFonts.openSans( fontSize: 18, diff --git a/example/lib/widgets/blocks/block_item.dart b/example/lib/widgets/blocks/block_item.dart index 6a20fb1..617ddcd 100644 --- a/example/lib/widgets/blocks/block_item.dart +++ b/example/lib/widgets/blocks/block_item.dart @@ -27,7 +27,7 @@ class BlockItem extends AppStatelessWidget { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - TextTitleSmall(title), + TextTitleLarge(title), const SizedBox(height: 8), TextBodyMedium(desc), const SizedBox(height: 8), diff --git a/example/lib/widgets/layouts/block_layout.dart b/example/lib/widgets/layouts/block_layout.dart index 9882553..3d92a47 100644 --- a/example/lib/widgets/layouts/block_layout.dart +++ b/example/lib/widgets/layouts/block_layout.dart @@ -46,7 +46,7 @@ class BlockLayout extends AppStatelessWidget { ), ), backgroundColor: AppColors.primary, - title: TextTitleSmall( + title: TextTitleLarge( title!, color: Colors.white, ), diff --git a/example/pubspec.lock b/example/pubspec.lock index 4a72d77..6790108 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -244,6 +244,34 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" + flutter_local_notifications: + dependency: "direct main" + description: + name: flutter_local_notifications + url: "https://pub.dartlang.org" + source: hosted + version: "14.1.1" + flutter_local_notifications_aurora: + dependency: "direct main" + description: + path: "../packages/flutter_local_notifications/flutter_local_notifications_aurora" + relative: true + source: path + version: "0.0.1" + flutter_local_notifications_linux: + dependency: transitive + description: + name: flutter_local_notifications_linux + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0+1" + flutter_local_notifications_platform_interface: + dependency: transitive + description: + name: flutter_local_notifications_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "7.0.0+1" flutter_localizations: dependency: "direct main" description: flutter @@ -593,6 +621,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.12" + timezone: + dependency: transitive + description: + name: timezone + url: "https://pub.dartlang.org" + source: hosted + version: "0.9.2" timing: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index b484900..96c7d1e 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -42,12 +42,12 @@ dependencies: device_info_plus_aurora: path: ../packages/device_info_plus/device_info_plus_aurora -# ## https://pub.dev/packages/flutter_local_notifications -# flutter_local_notifications: ^14.1.1 -# ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/flutter_local_notifications/flutter_local_notifications_aurora -# flutter_local_notifications_aurora: -# path: ../packages/flutter_local_notifications/flutter_local_notifications_aurora -# + ## https://pub.dev/packages/flutter_local_notifications + flutter_local_notifications: ^14.1.1 + ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/flutter_local_notifications/flutter_local_notifications_aurora + flutter_local_notifications_aurora: + path: ../packages/flutter_local_notifications/flutter_local_notifications_aurora + # ## https://pub.dev/packages/flutter_secure_storage # flutter_secure_storage: ^8.0.0 # ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/flutter_secure_storage/flutter_secure_storage_aurora