Clean up dark mode

This commit is contained in:
Christian Pauly 2020-02-16 20:11:39 +01:00
parent 38ef2b7807
commit ea71a97e45
8 changed files with 65 additions and 49 deletions

View file

@ -38,7 +38,7 @@ class AdaptivePageLayout extends StatelessWidget {
), ),
Container( Container(
width: 1, width: 1,
color: Color(0xFFE8E8E8), color: Theme.of(context).secondaryHeaderColor, //Color(0xFFE8E8E8),
), ),
Expanded( Expanded(
child: Container( child: Container(

View file

@ -11,7 +11,7 @@ import '../../utils/date_time_extension.dart';
import '../../utils/event_extension.dart'; import '../../utils/event_extension.dart';
import '../../utils/room_extension.dart'; import '../../utils/room_extension.dart';
import '../../views/chat.dart'; import '../../views/chat.dart';
import '../ThemeSwitcher.dart'; import '../theme_switcher.dart';
import '../avatar.dart'; import '../avatar.dart';
import '../dialogs/simple_dialogs.dart'; import '../dialogs/simple_dialogs.dart';
import '../matrix.dart'; import '../matrix.dart';

View file

@ -1,7 +1,5 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../utils/famedlysdk_store.dart';
import 'matrix.dart'; import 'matrix.dart';
enum Themes { enum Themes {
@ -49,6 +47,16 @@ final ThemeData darkTheme = ThemeData.dark().copyWith(
scaffoldBackgroundColor: Color(0xff121212), scaffoldBackgroundColor: Color(0xff121212),
accentColor: Color(0xFFF5B4D2), accentColor: Color(0xFFF5B4D2),
secondaryHeaderColor: Color(0xff1D1D1D), secondaryHeaderColor: Color(0xff1D1D1D),
dialogTheme: DialogTheme(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
popupMenuTheme: PopupMenuThemeData(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
appBarTheme: AppBarTheme( appBarTheme: AppBarTheme(
brightness: Brightness.dark, brightness: Brightness.dark,
color: Color(0xff1D1D1D), color: Color(0xff1D1D1D),
@ -70,6 +78,16 @@ final ThemeData amoledTheme = ThemeData.dark().copyWith(
scaffoldBackgroundColor: Colors.black, scaffoldBackgroundColor: Colors.black,
accentColor: Color(0xFFF5B4D2), accentColor: Color(0xFFF5B4D2),
secondaryHeaderColor: Color(0xff1D1D1D), secondaryHeaderColor: Color(0xff1D1D1D),
dialogTheme: DialogTheme(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
popupMenuTheme: PopupMenuThemeData(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
appBarTheme: AppBarTheme( appBarTheme: AppBarTheme(
brightness: Brightness.dark, brightness: Brightness.dark,
color: Color(0xff1D1D1D), color: Color(0xff1D1D1D),
@ -141,25 +159,15 @@ class ThemeSwitcherWidgetState extends State<ThemeSwitcherWidget> {
BuildContext context; BuildContext context;
Future loadSelection(MatrixState matrix) async { Future loadSelection(MatrixState matrix) async {
if (kIsWeb) { String item = await matrix.client.storeAPI.getItem("theme") ?? "light";
Store store = matrix.client.storeAPI;
String item = await store.getItem("theme") ?? "light";
selectedTheme = selectedTheme =
Themes.values.firstWhere((e) => e.toString() == 'Themes.' + item); Themes.values.firstWhere((e) => e.toString() == 'Themes.' + item);
amoledEnabled = amoledEnabled =
(await store.getItem("amoled_enabled") ?? "false").toLowerCase() == (await matrix.client.storeAPI.getItem("amoled_enabled") ?? "false")
.toLowerCase() ==
'true'; 'true';
} else {
ExtendedStore store = matrix.client.storeAPI;
String item = await store.getItem("theme") ?? "light";
selectedTheme =
Themes.values.firstWhere((e) => e.toString() == 'Themes.' + item);
amoledEnabled =
(await store.getItem("amoled_enabled") ?? "false").toLowerCase() ==
'true';
}
switchTheme(matrix, selectedTheme, amoledEnabled); switchTheme(matrix, selectedTheme, amoledEnabled);
return; return;
} }
@ -205,23 +213,12 @@ class ThemeSwitcherWidgetState extends State<ThemeSwitcherWidget> {
} }
Future saveThemeValue(MatrixState matrix, Themes value) async { Future saveThemeValue(MatrixState matrix, Themes value) async {
if (kIsWeb) { await matrix.client.storeAPI
Store store = matrix.client.storeAPI; .setItem("theme", value.toString().split('.').last);
await store.setItem("theme", value.toString().split('.').last);
} else {
ExtendedStore store = matrix.client.storeAPI;
await store.setItem("theme", value.toString().split('.').last);
}
} }
Future saveAmoledEnabledValue(MatrixState matrix, bool value) async { Future saveAmoledEnabledValue(MatrixState matrix, bool value) async {
if (kIsWeb) { await matrix.client.storeAPI.setItem("amoled_enabled", value.toString());
Store store = matrix.client.storeAPI;
await store.setItem("amoled_enabled", value.toString());
} else {
ExtendedStore store = matrix.client.storeAPI;
await store.setItem("amoled_enabled", value.toString());
}
} }
void setup() async { void setup() async {

View file

@ -5,7 +5,7 @@ import 'package:flutter_localizations/flutter_localizations.dart';
import 'i18n/i18n.dart'; import 'i18n/i18n.dart';
import 'views/sign_up.dart'; import 'views/sign_up.dart';
import 'components/ThemeSwitcher.dart'; import 'components/theme_switcher.dart';
import 'components/matrix.dart'; import 'components/matrix.dart';
import 'views/chat_list.dart'; import 'views/chat_list.dart';

View file

@ -202,7 +202,12 @@ class _ChatDetailsState extends State<ChatDetails> {
ChatSettingsPopupMenu(widget.room, false) ChatSettingsPopupMenu(widget.room, false)
], ],
title: Text(widget.room.getLocalizedDisplayname(context), title: Text(widget.room.getLocalizedDisplayname(context),
style: TextStyle(color: Colors.black)), style: TextStyle(
color: Theme.of(context)
.appBarTheme
.textTheme
.headline6
.color)),
backgroundColor: Theme.of(context).appBarTheme.color, backgroundColor: Theme.of(context).appBarTheme.color,
flexibleSpace: FlexibleSpaceBar( flexibleSpace: FlexibleSpaceBar(
background: ContentBanner(widget.room.avatar, background: ContentBanner(widget.room.avatar,
@ -221,7 +226,8 @@ class _ChatDetailsState extends State<ChatDetails> {
ListTile( ListTile(
leading: widget.room.canSendEvent("m.room.topic") leading: widget.room.canSendEvent("m.room.topic")
? CircleAvatar( ? CircleAvatar(
backgroundColor: Colors.white, backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: Icon(Icons.edit), child: Icon(Icons.edit),
) )
@ -257,7 +263,8 @@ class _ChatDetailsState extends State<ChatDetails> {
if (widget.room.canSendEvent("m.room.name")) if (widget.room.canSendEvent("m.room.name"))
ListTile( ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: Colors.white, backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: Icon(Icons.people), child: Icon(Icons.people),
), ),
@ -270,7 +277,8 @@ class _ChatDetailsState extends State<ChatDetails> {
widget.room.joinRules == JoinRules.public) widget.room.joinRules == JoinRules.public)
ListTile( ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: Colors.white, backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: Icon(Icons.link), child: Icon(Icons.link),
), ),
@ -284,7 +292,8 @@ class _ChatDetailsState extends State<ChatDetails> {
PopupMenuButton( PopupMenuButton(
child: ListTile( child: ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: Colors.white, backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: Icon(Icons.public)), child: Icon(Icons.public)),
title: Text( title: Text(
@ -316,7 +325,8 @@ class _ChatDetailsState extends State<ChatDetails> {
PopupMenuButton( PopupMenuButton(
child: ListTile( child: ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: Colors.white, backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: Icon(Icons.visibility), child: Icon(Icons.visibility),
), ),
@ -363,7 +373,8 @@ class _ChatDetailsState extends State<ChatDetails> {
PopupMenuButton( PopupMenuButton(
child: ListTile( child: ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: Colors.white, backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: Icon(Icons.info_outline), child: Icon(Icons.info_outline),
), ),
@ -436,7 +447,8 @@ class _ChatDetailsState extends State<ChatDetails> {
title: Text(I18n.of(context).loadCountMoreParticipants( title: Text(I18n.of(context).loadCountMoreParticipants(
(actualMembersCount - members.length).toString())), (actualMembersCount - members.length).toString())),
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: Colors.white, backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
child: Icon( child: Icon(
Icons.refresh, Icons.refresh,
color: Colors.grey, color: Colors.grey,

View file

@ -8,7 +8,7 @@ import 'package:flutter_speed_dial/flutter_speed_dial.dart';
import 'package:toast/toast.dart'; import 'package:toast/toast.dart';
import 'package:uni_links/uni_links.dart'; import 'package:uni_links/uni_links.dart';
import '../components/ThemeSwitcher.dart'; import '../components/theme_switcher.dart';
import '../components/adaptive_page_layout.dart'; import '../components/adaptive_page_layout.dart';
import '../components/list_items/chat_list_item.dart'; import '../components/list_items/chat_list_item.dart';
import '../components/matrix.dart'; import '../components/matrix.dart';

View file

@ -114,8 +114,15 @@ class _SettingsState extends State<Settings> {
pinned: true, pinned: true,
backgroundColor: Theme.of(context).appBarTheme.color, backgroundColor: Theme.of(context).appBarTheme.color,
flexibleSpace: FlexibleSpaceBar( flexibleSpace: FlexibleSpaceBar(
title: Text(I18n.of(context).settings, title: Text(
style: TextStyle(color: Colors.black)), I18n.of(context).settings,
style: TextStyle(
color: Theme.of(context)
.appBarTheme
.textTheme
.headline6
.color),
),
background: ContentBanner( background: ContentBanner(
profile?.avatarUrl ?? MxContent(""), profile?.avatarUrl ?? MxContent(""),
height: 300, height: 300,

View file

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../components/ThemeSwitcher.dart'; import '../components/theme_switcher.dart';
import '../components/adaptive_page_layout.dart'; import '../components/adaptive_page_layout.dart';
import '../components/matrix.dart'; import '../components/matrix.dart';
import '../i18n/i18n.dart'; import '../i18n/i18n.dart';
@ -82,7 +82,7 @@ class ThemesSettingsState extends State<ThemesSettings> {
}); });
}, },
), ),
Divider(thickness: 8), Divider(thickness: 1),
ListTile( ListTile(
title: Text( title: Text(
I18n.of(context).useAmoledTheme, I18n.of(context).useAmoledTheme,