From ddd5711f79a35c2d52bea1454138e2274bf96eb1 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Mon, 24 May 2021 10:59:00 +0200 Subject: [PATCH] refactor: Deprecate accentColor --- lib/config/themes.dart | 10 ++++++++-- lib/main.dart | 1 + lib/pages/views/chat_details_view.dart | 10 +++++++--- lib/pages/views/chat_encryption_settings_view.dart | 2 +- lib/pages/views/chat_view.dart | 13 +++++++++---- lib/pages/views/new_private_chat_view.dart | 7 ++++--- lib/pages/views/search_view.dart | 6 +++--- lib/pages/views/settings_emotes_view.dart | 12 ++++++++---- lib/pages/views/settings_notifications_view.dart | 4 ++-- lib/pages/views/settings_style_view.dart | 4 ++-- lib/pages/views/settings_view.dart | 10 +++++----- lib/widgets/contacts_list.dart | 2 +- lib/widgets/event_content/html_message.dart | 2 +- lib/widgets/layouts/one_page_card.dart | 2 +- lib/widgets/list_items/chat_list_item.dart | 10 +++++----- lib/widgets/lock_screen.dart | 2 +- linux/flutter/CMakeLists.txt | 2 +- 17 files changed, 60 insertions(+), 39 deletions(-) diff --git a/lib/config/themes.dart b/lib/config/themes.dart index c48fe319..6f5f88ac 100644 --- a/lib/config/themes.dart +++ b/lib/config/themes.dart @@ -34,7 +34,10 @@ abstract class FluffyThemes { primaryColorLight: Color(0xff121212), brightness: Brightness.light, primaryColor: AppConfig.primaryColor, - accentColor: AppConfig.primaryColor, + colorScheme: ThemeData.light().colorScheme.copyWith( + primary: AppConfig.primaryColor, + secondary: AppConfig.primaryColor, + ), backgroundColor: Colors.white, secondaryHeaderColor: lighten(AppConfig.primaryColor, .51), scaffoldBackgroundColor: Colors.white, @@ -115,7 +118,10 @@ abstract class FluffyThemes { errorColor: Color(0xFFCF6679), backgroundColor: Colors.black, scaffoldBackgroundColor: Colors.black, - accentColor: AppConfig.primaryColorLight, + colorScheme: ThemeData.dark().colorScheme.copyWith( + primary: AppConfig.primaryColorLight, + secondary: AppConfig.primaryColorLight, + ), secondaryHeaderColor: FluffyThemes.darken(AppConfig.primaryColorLight, .65), textTheme: Typography.material2018().white.merge(fallback_text_theme), dialogTheme: DialogTheme( diff --git a/lib/main.dart b/lib/main.dart index e908f8ff..94dc3c41 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -9,6 +9,7 @@ import 'package:fluffychat/utils/sentry_controller.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'utils/localized_exception_extension.dart'; import 'package:flutter_app_lock/flutter_app_lock.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; diff --git a/lib/pages/views/chat_details_view.dart b/lib/pages/views/chat_details_view.dart index f2bc343a..c4593dcf 100644 --- a/lib/pages/views/chat_details_view.dart +++ b/lib/pages/views/chat_details_view.dart @@ -110,7 +110,9 @@ class ChatDetailsView extends StatelessWidget { title: Text( '${L10n.of(context).groupDescription}:', style: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context) + .colorScheme + .secondary, fontWeight: FontWeight.bold)), subtitle: LinkText( text: room.topic?.isEmpty ?? true @@ -136,7 +138,8 @@ class ChatDetailsView extends StatelessWidget { title: Text( L10n.of(context).settings, style: TextStyle( - color: Theme.of(context).accentColor, + color: + Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -321,7 +324,8 @@ class ChatDetailsView extends StatelessWidget { actualMembersCount.toString()) : L10n.of(context).emptyChat, style: TextStyle( - color: Theme.of(context).accentColor, + color: + Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold, ), ), diff --git a/lib/pages/views/chat_encryption_settings_view.dart b/lib/pages/views/chat_encryption_settings_view.dart index 0a86ac6b..4c8172fb 100644 --- a/lib/pages/views/chat_encryption_settings_view.dart +++ b/lib/pages/views/chat_encryption_settings_view.dart @@ -32,7 +32,7 @@ class ChatEncryptionSettingsView extends StatelessWidget { title: Text(L10n.of(context).deviceVerifyDescription), leading: CircleAvatar( backgroundColor: Theme.of(context).secondaryHeaderColor, - foregroundColor: Theme.of(context).accentColor, + foregroundColor: Theme.of(context).colorScheme.secondary, child: Icon(Icons.lock), ), ), diff --git a/lib/pages/views/chat_view.dart b/lib/pages/views/chat_view.dart index ed73d112..604f1a65 100644 --- a/lib/pages/views/chat_view.dart +++ b/lib/pages/views/chat_view.dart @@ -110,7 +110,8 @@ class ChatView extends StatelessWidget { : Row( children: [ Icon(Icons.edit_outlined, - color: Theme.of(context).accentColor, + color: + Theme.of(context).colorScheme.secondary, size: 13), SizedBox(width: 4), Expanded( @@ -119,7 +120,9 @@ class ChatView extends StatelessWidget { .getLocalizedTypingText(context), maxLines: 1, style: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context) + .colorScheme + .secondary, fontStyle: FontStyle.italic, ), ), @@ -209,7 +212,8 @@ class ChatView extends StatelessWidget { color: Theme.of(context).secondaryHeaderColor, child: ListTile( leading: CircleAvatar( - foregroundColor: Theme.of(context).accentColor, + foregroundColor: + Theme.of(context).colorScheme.secondary, backgroundColor: Theme.of(context).backgroundColor, child: Icon(Icons.upgrade_outlined), ), @@ -330,7 +334,8 @@ class ChatView extends StatelessWidget { overflow: TextOverflow.ellipsis, style: TextStyle( color: Theme.of(context) - .accentColor, + .colorScheme + .secondary, ), ), ), diff --git a/lib/pages/views/new_private_chat_view.dart b/lib/pages/views/new_private_chat_view.dart index fb52c140..3f51b0c8 100644 --- a/lib/pages/views/new_private_chat_view.dart +++ b/lib/pages/views/new_private_chat_view.dart @@ -25,7 +25,7 @@ class NewPrivateChatView extends StatelessWidget { onPressed: () => VRouter.of(context).push('/newgroup'), child: Text( L10n.of(context).createNewGroup, - style: TextStyle(color: Theme.of(context).accentColor), + style: TextStyle(color: Theme.of(context).colorScheme.secondary), ), ) ], @@ -78,7 +78,7 @@ class NewPrivateChatView extends StatelessWidget { ListTile( leading: CircleAvatar( radius: Avatar.defaultSize / 2, - foregroundColor: Theme.of(context).accentColor, + foregroundColor: Theme.of(context).colorScheme.secondary, backgroundColor: Theme.of(context).secondaryHeaderColor, child: Icon(Icons.share_outlined), ), @@ -86,7 +86,8 @@ class NewPrivateChatView extends StatelessWidget { title: Text('${L10n.of(context).yourOwnUsername}:'), subtitle: Text( Matrix.of(context).client.userID, - style: TextStyle(color: Theme.of(context).accentColor), + style: + TextStyle(color: Theme.of(context).colorScheme.secondary), ), ), Divider(height: 1), diff --git a/lib/pages/views/search_view.dart b/lib/pages/views/search_view.dart index bbc3bf78..c6defcff 100644 --- a/lib/pages/views/search_view.dart +++ b/lib/pages/views/search_view.dart @@ -75,8 +75,8 @@ class SearchView extends StatelessWidget { onChanged: controller.search, ), bottom: TabBar( - indicatorColor: Theme.of(context).accentColor, - labelColor: Theme.of(context).accentColor, + indicatorColor: Theme.of(context).colorScheme.secondary, + labelColor: Theme.of(context).colorScheme.secondary, unselectedLabelColor: Theme.of(context).textTheme.bodyText1.color, labelStyle: TextStyle(fontSize: 16), labelPadding: EdgeInsets.symmetric( @@ -97,7 +97,7 @@ class SearchView extends StatelessWidget { SizedBox(height: 12), ListTile( leading: CircleAvatar( - foregroundColor: Theme.of(context).accentColor, + foregroundColor: Theme.of(context).colorScheme.secondary, backgroundColor: Theme.of(context).secondaryHeaderColor, child: Icon(Icons.edit_outlined), ), diff --git a/lib/pages/views/settings_emotes_view.dart b/lib/pages/views/settings_emotes_view.dart index 6db174fd..7a14e705 100644 --- a/lib/pages/views/settings_emotes_view.dart +++ b/lib/pages/views/settings_emotes_view.dart @@ -56,11 +56,11 @@ class EmotesSettingsView extends StatelessWidget { prefixText: ': ', suffixText: ':', prefixStyle: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold, ), suffixStyle: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold, ), border: InputBorder.none, @@ -140,11 +140,15 @@ class EmotesSettingsView extends StatelessWidget { prefixText: ': ', suffixText: ':', prefixStyle: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context) + .colorScheme + .secondary, fontWeight: FontWeight.bold, ), suffixStyle: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context) + .colorScheme + .secondary, fontWeight: FontWeight.bold, ), border: InputBorder.none, diff --git a/lib/pages/views/settings_notifications_view.dart b/lib/pages/views/settings_notifications_view.dart index 8d4266e5..1f4cc9d9 100644 --- a/lib/pages/views/settings_notifications_view.dart +++ b/lib/pages/views/settings_notifications_view.dart @@ -65,7 +65,7 @@ class SettingsNotificationsView extends StatelessWidget { title: Text( L10n.of(context).pushRules, style: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -83,7 +83,7 @@ class SettingsNotificationsView extends StatelessWidget { title: Text( L10n.of(context).devices, style: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold, ), ), diff --git a/lib/pages/views/settings_style_view.dart b/lib/pages/views/settings_style_view.dart index 860a5fc1..7e1fcf47 100644 --- a/lib/pages/views/settings_style_view.dart +++ b/lib/pages/views/settings_style_view.dart @@ -47,7 +47,7 @@ class SettingsStyleView extends StatelessWidget { title: Text( L10n.of(context).wallpaper, style: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -77,7 +77,7 @@ class SettingsStyleView extends StatelessWidget { title: Text( L10n.of(context).fontSize, style: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold, ), ), diff --git a/lib/pages/views/settings_view.dart b/lib/pages/views/settings_view.dart index da97affa..67516f54 100644 --- a/lib/pages/views/settings_view.dart +++ b/lib/pages/views/settings_view.dart @@ -74,7 +74,7 @@ class SettingsView extends StatelessWidget { title: Text( L10n.of(context).notifications, style: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -89,7 +89,7 @@ class SettingsView extends StatelessWidget { title: Text( L10n.of(context).chat, style: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -127,7 +127,7 @@ class SettingsView extends StatelessWidget { title: Text( L10n.of(context).account, style: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -188,7 +188,7 @@ class SettingsView extends StatelessWidget { title: Text( L10n.of(context).security, style: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold, ), ), @@ -223,7 +223,7 @@ class SettingsView extends StatelessWidget { title: Text( L10n.of(context).about, style: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold, ), ), diff --git a/lib/widgets/contacts_list.dart b/lib/widgets/contacts_list.dart index ee3a7ecd..42ea5769 100644 --- a/lib/widgets/contacts_list.dart +++ b/lib/widgets/contacts_list.dart @@ -98,7 +98,7 @@ class _ContactListTile extends StatelessWidget { subtitle: Text(contact.getLocalizedStatusMessage(context), style: contact.presence.statusMsg?.isNotEmpty ?? false ? TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold, ) : null), diff --git a/lib/widgets/event_content/html_message.dart b/lib/widgets/event_content/html_message.dart index d221cc2c..bbb3e479 100644 --- a/lib/widgets/event_content/html_message.dart +++ b/lib/widgets/event_content/html_message.dart @@ -46,7 +46,7 @@ class HtmlMessage extends StatelessWidget { emoteSize: emoteSize, linkStyle: linkStyle ?? themeData.textTheme.bodyText2.copyWith( - color: themeData.accentColor, + color: themeData.colorScheme.secondary, decoration: TextDecoration.underline, ), shrinkToFit: true, diff --git a/lib/widgets/layouts/one_page_card.dart b/lib/widgets/layouts/one_page_card.dart index abc33a69..0370dee0 100644 --- a/lib/widgets/layouts/one_page_card.dart +++ b/lib/widgets/layouts/one_page_card.dart @@ -30,7 +30,7 @@ class OnePageCard extends StatelessWidget { colors: [ Theme.of(context).secondaryHeaderColor.withAlpha(alpha), Theme.of(context).primaryColor.withAlpha(alpha), - Theme.of(context).accentColor.withAlpha(alpha), + Theme.of(context).colorScheme.secondary.withAlpha(alpha), Theme.of(context).backgroundColor.withAlpha(alpha), ], ), diff --git a/lib/widgets/list_items/chat_list_item.dart b/lib/widgets/list_items/chat_list_item.dart index ae2065e2..7ea486bd 100644 --- a/lib/widgets/list_items/chat_list_item.dart +++ b/lib/widgets/list_items/chat_list_item.dart @@ -185,7 +185,7 @@ class ChatListItem extends StatelessWidget { style: TextStyle( fontSize: 13, color: room.notificationCount > 0 - ? Theme.of(context).accentColor + ? Theme.of(context).colorScheme.secondary : null, ), ), @@ -205,7 +205,7 @@ class ChatListItem extends StatelessWidget { if (typingText.isNotEmpty) ...{ Icon( Icons.edit_outlined, - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, size: 14, ), SizedBox(width: 4), @@ -215,7 +215,7 @@ class ChatListItem extends StatelessWidget { ? Text( typingText, style: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, ), softWrap: false, ) @@ -223,7 +223,7 @@ class ChatListItem extends StatelessWidget { ? Text( L10n.of(context).youAreInvitedToThisChat, style: TextStyle( - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, ), softWrap: false, ) @@ -253,7 +253,7 @@ class ChatListItem extends StatelessWidget { child: Icon( Icons.push_pin_outlined, size: 20, - color: Theme.of(context).accentColor, + color: Theme.of(context).colorScheme.secondary, ), ), if (room.isUnread) diff --git a/lib/widgets/lock_screen.dart b/lib/widgets/lock_screen.dart index 2ebda093..2845399d 100644 --- a/lib/widgets/lock_screen.dart +++ b/lib/widgets/lock_screen.dart @@ -51,7 +51,7 @@ class _LockScreenState extends State { colors: [ Theme.of(context).secondaryHeaderColor.withAlpha(16), Theme.of(context).primaryColor.withAlpha(16), - Theme.of(context).accentColor.withAlpha(16), + Theme.of(context).colorScheme.secondary.withAlpha(16), Theme.of(context).backgroundColor.withAlpha(16), ], ), diff --git a/linux/flutter/CMakeLists.txt b/linux/flutter/CMakeLists.txt index a1da1b9e..6dc97055 100644 --- a/linux/flutter/CMakeLists.txt +++ b/linux/flutter/CMakeLists.txt @@ -82,7 +82,7 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" - linux-x64 ${CMAKE_BUILD_TYPE} + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} VERBATIM ) add_custom_target(flutter_assemble DEPENDS