TF-438 Apply new design for push notification

This commit is contained in:
dab246
2022-11-24 19:21:32 +07:00
committed by Dat H. Pham
parent 44bf37a246
commit f3f2c19f20
17 changed files with 86 additions and 70 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 518 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 913 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

+50 -37
View File
@@ -3,44 +3,57 @@ import 'package:core/presentation/extensions/color_extension.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
ThemeData appTheme() { class ThemeUtils {
return ThemeData(
scaffoldBackgroundColor: Colors.white,
fontFamily: ConstantsUI.fontApp,
appBarTheme: appBarTheme(),
textTheme: textTheme(),
visualDensity: VisualDensity.adaptivePlatformDensity,
);
}
InputDecorationTheme inputDecorationTheme() { static ThemeData get appTheme {
OutlineInputBorder outlineInputBorder = OutlineInputBorder( return ThemeData(
borderRadius: BorderRadius.circular(28), scaffoldBackgroundColor: Colors.white,
borderSide: const BorderSide(color: AppColor.baseTextColor), fontFamily: ConstantsUI.fontApp,
gapPadding: 10, appBarTheme: _appBarTheme,
); textTheme: _textTheme,
return InputDecorationTheme( visualDensity: VisualDensity.adaptivePlatformDensity,
floatingLabelBehavior: FloatingLabelBehavior.always, );
contentPadding: const EdgeInsets.symmetric(horizontal: 42, vertical: 20), }
enabledBorder: outlineInputBorder,
focusedBorder: outlineInputBorder,
border: outlineInputBorder,
);
}
TextTheme textTheme() { static TextTheme get _textTheme {
return const TextTheme( return const TextTheme(
bodyText1: TextStyle(color: AppColor.baseTextColor), bodyText1: TextStyle(color: AppColor.baseTextColor),
bodyText2: TextStyle(color: AppColor.baseTextColor), bodyText2: TextStyle(color: AppColor.baseTextColor),
); );
} }
AppBarTheme appBarTheme() { static AppBarTheme get _appBarTheme {
return const AppBarTheme( return const AppBarTheme(
color: Colors.white, color: Colors.white,
elevation: 0, elevation: 0,
systemOverlayStyle: SystemUiOverlayStyle.light, systemOverlayStyle: SystemUiOverlayStyle.light,
iconTheme: IconThemeData(color: Colors.black), iconTheme: IconThemeData(color: Colors.black),
titleTextStyle: TextStyle(color: Color(0XFF8B8B8B), fontSize: 18), titleTextStyle: TextStyle(color: Color(0XFF8B8B8B), fontSize: 18),
); );
}
static void setSystemLightUIStyle() {
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
systemNavigationBarColor: Colors.black,
systemNavigationBarIconBrightness: Brightness.light,
statusBarColor: Colors.black,
statusBarIconBrightness: Brightness.light,
));
}
static void setSystemDarkUIStyle() {
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
systemNavigationBarColor: Colors.white,
systemNavigationBarIconBrightness: Brightness.dark,
statusBarColor: Colors.white,
statusBarIconBrightness: Brightness.dark,
));
}
static void setStatusBarTransparentColor() {
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
systemNavigationBarIconBrightness: Brightness.dark,
));
}
} }
@@ -1,7 +1,6 @@
import 'package:core/core.dart'; import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:tmail_ui_user/features/home/presentation/home_controller.dart'; import 'package:tmail_ui_user/features/home/presentation/home_controller.dart';
@@ -10,12 +9,7 @@ class HomeView extends GetWidget<HomeController> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle( ThemeUtils.setSystemDarkUIStyle();
systemNavigationBarColor: Colors.white,
systemNavigationBarIconBrightness: Brightness.dark,
statusBarColor: Colors.white,
statusBarIconBrightness: Brightness.dark,
));
return Container( return Container(
color: AppColor.primaryLightColor, color: AppColor.primaryLightColor,
@@ -1,7 +1,6 @@
import 'package:core/core.dart'; import 'package:core/core.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:model/model.dart'; import 'package:model/model.dart';
@@ -26,9 +25,7 @@ class MailboxView extends GetWidget<MailboxController> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle( ThemeUtils.setStatusBarTransparentColor();
statusBarColor: Colors.transparent,
));
return SafeArea(bottom: false, left: false, right: false, return SafeArea(bottom: false, left: false, right: false,
top: _responsiveUtils.isMobile(context), top: _responsiveUtils.isMobile(context),
@@ -1,4 +1,5 @@
import 'package:core/presentation/utils/responsive_utils.dart'; import 'package:core/presentation/utils/responsive_utils.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:core/presentation/views/responsive/responsive_widget.dart'; import 'package:core/presentation/views/responsive/responsive_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:focus_detector/focus_detector.dart'; import 'package:focus_detector/focus_detector.dart';
@@ -27,7 +28,13 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView {
); );
return FocusDetector( return FocusDetector(
onFocusGained: controller.refreshActionWhenBackToApp, onFocusGained: () {
ThemeUtils.setSystemDarkUIStyle();
if (controller.isDrawerOpen) {
ThemeUtils.setStatusBarTransparentColor();
}
controller.refreshActionWhenBackToApp();
},
child: Scaffold( child: Scaffold(
drawerEnableOpenDragGesture: responsiveUtils.hasLeftMenuDrawerActive(context), drawerEnableOpenDragGesture: responsiveUtils.hasLeftMenuDrawerActive(context),
body: Stack(children: [ body: Stack(children: [
@@ -44,7 +44,10 @@ class LocalNotificationConfig {
importance: Importance.max, importance: Importance.max,
priority: Priority.high, priority: Priority.high,
setAsGroupSummary: setAsGroup, setAsGroupSummary: setAsGroup,
styleInformation: styleInformation styleInformation: styleInformation,
channelShowBadge: true,
showWhen: true,
largeIcon: const DrawableResourceAndroidBitmap('@mipmap/ic_large_notification')
), ),
iOS: const DarwinNotificationDetails( iOS: const DarwinNotificationDetails(
presentSound: true, presentSound: true,
@@ -99,19 +99,18 @@ class LocalNotificationManager {
String? payload String? payload
}) async { }) async {
final inboxStyleInformation = InboxStyleInformation( final inboxStyleInformation = InboxStyleInformation(
[title, message ?? ''], [message?.addBlockTag('p', attribute: 'style="color:#6D7885;"') ?? ''],
contentTitle: (emailAddress?.asString() ?? '').addBlockTag('b'), htmlFormatLines: true,
summaryText: (emailAddress?.asString() ?? '').addBlockTag('b'), contentTitle: title,
htmlFormatTitle: true,
htmlFormatContent: true,
htmlFormatContentTitle: true, htmlFormatContentTitle: true,
summaryText: (emailAddress?.asString() ?? '').addBlockTag('b'),
htmlFormatSummaryText: true, htmlFormatSummaryText: true,
); );
await _localNotificationsPlugin.show( await _localNotificationsPlugin.show(
id.hashCode, id.hashCode,
title.addBlockTag('b'), null,
message ?? '', null,
LocalNotificationConfig.instance.generateNotificationDetails(styleInformation: inboxStyleInformation), LocalNotificationConfig.instance.generateNotificationDetails(styleInformation: inboxStyleInformation),
payload: payload payload: payload
); );
@@ -123,11 +122,20 @@ class LocalNotificationManager {
?.getActiveNotifications(); ?.getActiveNotifications();
if (activeNotifications != null && activeNotifications.isNotEmpty) { if (activeNotifications != null && activeNotifications.isNotEmpty) {
final inboxStyleInformation = InboxStyleInformation(
[''],
summaryText: '${activeNotifications.length - 1} new emails'.addBlockTag('b'),
htmlFormatSummaryText: true,
);
await _localNotificationsPlugin.show( await _localNotificationsPlugin.show(
1995, 1995,
'', null,
'', null,
LocalNotificationConfig.instance.generateNotificationDetails(setAsGroup: true) LocalNotificationConfig.instance.generateNotificationDetails(
setAsGroup: true,
styleInformation: inboxStyleInformation
),
); );
} }
} }
+2 -8
View File
@@ -1,6 +1,5 @@
import 'package:core/core.dart'; import 'package:core/core.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:tmail_ui_user/features/caching/config/hive_cache_config.dart'; import 'package:tmail_ui_user/features/caching/config/hive_cache_config.dart';
@@ -16,12 +15,7 @@ import 'package:worker_manager/worker_manager.dart';
void main() async { void main() async {
initLogger(() async { initLogger(() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle( ThemeUtils.setSystemLightUIStyle();
systemNavigationBarColor: Colors.black,
systemNavigationBarIconBrightness: Brightness.light,
statusBarColor: Colors.black,
statusBarIconBrightness: Brightness.light,
));
await MainBindings().dependencies(); await MainBindings().dependencies();
await HiveCacheConfig().setUp(); await HiveCacheConfig().setUp();
await HiveCacheConfig.initializeEncryptionKey(); await HiveCacheConfig.initializeEncryptionKey();
@@ -38,7 +32,7 @@ class TMailApp extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GetMaterialApp( return GetMaterialApp(
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
theme: appTheme(), theme: ThemeUtils.appTheme,
supportedLocales: LocalizationService.supportedLocales, supportedLocales: LocalizationService.supportedLocales,
localizationsDelegates: const [ localizationsDelegates: const [
AppLocalizationsDelegate(), AppLocalizationsDelegate(),