[Theme] Add initial dark theme
Took 1 hour 10 minutes
This commit is contained in:
parent
d7448320d9
commit
26ca8ba4ad
16 changed files with 577 additions and 111 deletions
|
|
@ -237,7 +237,7 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
linkStyle: TextStyle(color: Colors.blueAccent),
|
||||
textStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.black,
|
||||
color: Theme.of(context).accentColor,
|
||||
),
|
||||
),
|
||||
onTap: widget.room.canSendEvent("m.room.topic")
|
||||
|
|
|
|||
|
|
@ -1,16 +1,6 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/components/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/components/list_items/chat_list_item.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/i18n/i18n.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/utils/url_launcher.dart';
|
||||
import 'package:fluffychat/views/archive.dart';
|
||||
import 'package:fluffychat/views/new_group.dart';
|
||||
import 'package:fluffychat/views/new_private_chat.dart';
|
||||
import 'package:fluffychat/views/settings.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
|
@ -18,6 +8,18 @@ import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
|||
import 'package:toast/toast.dart';
|
||||
import 'package:uni_links/uni_links.dart';
|
||||
|
||||
import '../components/ThemeSwitcher.dart';
|
||||
import '../components/adaptive_page_layout.dart';
|
||||
import '../components/list_items/chat_list_item.dart';
|
||||
import '../components/matrix.dart';
|
||||
import '../i18n/i18n.dart';
|
||||
import '../utils/app_route.dart';
|
||||
import '../utils/url_launcher.dart';
|
||||
import 'archive.dart';
|
||||
import 'new_group.dart';
|
||||
import 'new_private_chat.dart';
|
||||
import 'settings.dart';
|
||||
|
||||
enum SelectMode { normal, share }
|
||||
|
||||
class ChatListView extends StatelessWidget {
|
||||
|
|
@ -39,6 +41,7 @@ class ChatList extends StatefulWidget {
|
|||
final String activeChat;
|
||||
|
||||
const ChatList({this.activeChat, Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ChatListState createState() => _ChatListState();
|
||||
}
|
||||
|
|
@ -189,13 +192,15 @@ class _ChatListState extends State<ChatList> {
|
|||
),
|
||||
floatingActionButton: SpeedDial(
|
||||
child: Icon(Icons.add),
|
||||
overlayColor: blackWhiteColor(context),
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
children: [
|
||||
SpeedDialChild(
|
||||
child: Icon(Icons.people_outline),
|
||||
backgroundColor: Colors.blue,
|
||||
label: I18n.of(context).createNewGroup,
|
||||
labelStyle: TextStyle(fontSize: 18.0),
|
||||
labelStyle:
|
||||
TextStyle(fontSize: 18.0, color: blackWhiteColor(context)),
|
||||
onTap: () => Navigator.of(context).pushAndRemoveUntil(
|
||||
AppRoute.defaultRoute(context, NewGroupView()),
|
||||
(r) => r.isFirst),
|
||||
|
|
@ -204,7 +209,11 @@ class _ChatListState extends State<ChatList> {
|
|||
child: Icon(Icons.person_add),
|
||||
backgroundColor: Colors.green,
|
||||
label: I18n.of(context).newPrivateChat,
|
||||
labelStyle: TextStyle(fontSize: 18.0),
|
||||
labelStyle: TextStyle(
|
||||
fontSize: 18.0,
|
||||
color: Theme.of(context).brightness == Brightness.light
|
||||
? Colors.white
|
||||
: Colors.black),
|
||||
onTap: () => Navigator.of(context).pushAndRemoveUntil(
|
||||
AppRoute.defaultRoute(context, NewPrivateChatView()),
|
||||
(r) => r.isFirst),
|
||||
|
|
|
|||
|
|
@ -120,7 +120,6 @@ class _LoginState extends State<Login> {
|
|||
),
|
||||
ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.white,
|
||||
child: Icon(Icons.account_box,
|
||||
color: Theme.of(context).primaryColor),
|
||||
),
|
||||
|
|
@ -137,7 +136,9 @@ class _LoginState extends State<Login> {
|
|||
),
|
||||
ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.white,
|
||||
backgroundColor: Theme.of(context).brightness == Brightness.dark
|
||||
? Color(0xff121212)
|
||||
: Colors.white,
|
||||
child: Icon(Icons.lock, color: Theme.of(context).primaryColor),
|
||||
),
|
||||
title: TextField(
|
||||
|
|
|
|||
|
|
@ -1,20 +1,22 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/components/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/components/content_banner.dart';
|
||||
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/i18n/i18n.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/views/app_info.dart';
|
||||
import 'package:fluffychat/views/chat_list.dart';
|
||||
import 'package:fluffychat/views/sign_up.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'app_info.dart';
|
||||
import 'chat_list.dart';
|
||||
import 'settings_themes.dart';
|
||||
import 'sign_up.dart';
|
||||
import '../components/dialogs/simple_dialogs.dart';
|
||||
import '../components/adaptive_page_layout.dart';
|
||||
import '../components/content_banner.dart';
|
||||
import '../components/matrix.dart';
|
||||
import '../i18n/i18n.dart';
|
||||
import '../utils/app_route.dart';
|
||||
|
||||
class SettingsView extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
@ -34,6 +36,7 @@ class Settings extends StatefulWidget {
|
|||
class _SettingsState extends State<Settings> {
|
||||
Future<dynamic> profileFuture;
|
||||
dynamic profile;
|
||||
|
||||
void logoutAction(BuildContext context) async {
|
||||
if (await SimpleDialogs(context).askConfirmation() == false) {
|
||||
return;
|
||||
|
|
@ -140,6 +143,17 @@ class _SettingsState extends State<Settings> {
|
|||
subtitle: Text(profile?.displayname ?? client.userID.localpart),
|
||||
onTap: () => setDisplaynameAction(context),
|
||||
),
|
||||
ListTile(
|
||||
trailing: Icon(Icons.color_lens),
|
||||
title: Text(I18n.of(context).changeTheme),
|
||||
onTap: () async => await Navigator.of(context).push(
|
||||
AppRoute.defaultRoute(
|
||||
context,
|
||||
ThemesSettingsView(),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(thickness: 1),
|
||||
ListTile(
|
||||
trailing: Icon(Icons.exit_to_app),
|
||||
title: Text(I18n.of(context).logout),
|
||||
|
|
|
|||
105
lib/views/settings_themes.dart
Normal file
105
lib/views/settings_themes.dart
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../components/ThemeSwitcher.dart';
|
||||
import '../components/adaptive_page_layout.dart';
|
||||
import '../components/matrix.dart';
|
||||
import '../i18n/i18n.dart';
|
||||
import 'chat_list.dart';
|
||||
|
||||
class ThemesSettingsView extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AdaptivePageLayout(
|
||||
primaryPage: FocusPage.SECOND,
|
||||
firstScaffold: ChatList(),
|
||||
secondScaffold: ThemesSettings(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ThemesSettings extends StatefulWidget {
|
||||
@override
|
||||
ThemesSettingsState createState() => ThemesSettingsState();
|
||||
}
|
||||
|
||||
class ThemesSettingsState extends State<ThemesSettings> {
|
||||
Themes _selectedTheme;
|
||||
bool _amoledEnabled;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final MatrixState matrix = Matrix.of(context);
|
||||
final ThemeSwitcherWidgetState themeEngine =
|
||||
ThemeSwitcherWidget.of(context);
|
||||
_selectedTheme = themeEngine.selectedTheme;
|
||||
_amoledEnabled = themeEngine.amoledEnabled;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(I18n.of(context).changeTheme),
|
||||
),
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
RadioListTile<Themes>(
|
||||
title: Text(
|
||||
I18n.of(context).systemTheme,
|
||||
),
|
||||
value: Themes.system,
|
||||
groupValue: _selectedTheme,
|
||||
activeColor: Theme.of(context).primaryColor,
|
||||
onChanged: (Themes value) {
|
||||
setState(() {
|
||||
_selectedTheme = value;
|
||||
themeEngine.switchTheme(matrix, value, _amoledEnabled);
|
||||
});
|
||||
},
|
||||
),
|
||||
RadioListTile<Themes>(
|
||||
title: Text(
|
||||
I18n.of(context).lightTheme,
|
||||
),
|
||||
value: Themes.light,
|
||||
groupValue: _selectedTheme,
|
||||
activeColor: Theme.of(context).primaryColor,
|
||||
onChanged: (Themes value) {
|
||||
setState(() {
|
||||
_selectedTheme = value;
|
||||
themeEngine.switchTheme(matrix, value, _amoledEnabled);
|
||||
});
|
||||
},
|
||||
),
|
||||
RadioListTile<Themes>(
|
||||
title: Text(
|
||||
I18n.of(context).darkTheme,
|
||||
),
|
||||
value: Themes.dark,
|
||||
groupValue: _selectedTheme,
|
||||
activeColor: Theme.of(context).primaryColor,
|
||||
onChanged: (Themes value) {
|
||||
setState(() {
|
||||
_selectedTheme = value;
|
||||
themeEngine.switchTheme(matrix, value, _amoledEnabled);
|
||||
});
|
||||
},
|
||||
),
|
||||
Divider(thickness: 8),
|
||||
ListTile(
|
||||
title: Text(
|
||||
I18n.of(context).useAmoledTheme,
|
||||
),
|
||||
trailing: Switch(
|
||||
value: _amoledEnabled,
|
||||
activeColor: Theme.of(context).primaryColor,
|
||||
onChanged: (bool value) {
|
||||
setState(() {
|
||||
_amoledEnabled = value;
|
||||
themeEngine.switchTheme(matrix, _selectedTheme, value);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -97,12 +97,13 @@ class _SignUpState extends State<SignUp> {
|
|||
autocorrect: false,
|
||||
controller: serverController,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(Icons.domain),
|
||||
hintText: "matrix-client.matrix.org",
|
||||
errorText: serverError,
|
||||
errorMaxLines: 1,
|
||||
prefixText: "https://",
|
||||
labelText: serverError == null ? "Homeserver" : serverError),
|
||||
icon: Icon(Icons.domain),
|
||||
hintText: "matrix-client.matrix.org",
|
||||
errorText: serverError,
|
||||
errorMaxLines: 1,
|
||||
prefixText: "https://",
|
||||
labelText: serverError == null ? "Homeserver" : serverError,
|
||||
),
|
||||
),
|
||||
),
|
||||
body: ListView(
|
||||
|
|
@ -115,7 +116,7 @@ class _SignUpState extends State<SignUp> {
|
|||
leading: CircleAvatar(
|
||||
backgroundImage: avatar == null ? null : FileImage(avatar),
|
||||
backgroundColor: avatar == null
|
||||
? Colors.white
|
||||
? Theme.of(context).brightness == Brightness.dark ? Color(0xff121212) : Colors.white
|
||||
: Theme.of(context).secondaryHeaderColor,
|
||||
child: avatar == null
|
||||
? Icon(Icons.camera_alt,
|
||||
|
|
@ -137,7 +138,7 @@ class _SignUpState extends State<SignUp> {
|
|||
),
|
||||
ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.white,
|
||||
backgroundColor: Theme.of(context).brightness == Brightness.dark ? Color(0xff121212) : Colors.white,
|
||||
child: Icon(
|
||||
Icons.account_circle,
|
||||
color: Theme.of(context).primaryColor,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue