From c63f0626406783460d542d75a93df8210c973b4b Mon Sep 17 00:00:00 2001 From: zoe Date: Sun, 3 Jul 2022 00:03:10 +0200 Subject: [PATCH] theming!!! --- lib/main.dart | 4 +- lib/pages/chat/ chat.dart | 5 -- lib/pages/chat/chat.dart | 5 ++ lib/pages/login.dart | 2 +- lib/pages/notifications/notifications.dart | 5 ++ lib/pages/settings/settings.dart | 14 ++--- lib/pages/timeline/timeline.dart | 8 ++- lib/partials/main_scaffold.dart | 59 +++++++++++++++------- lib/themes/dracula.dart | 24 +++++++++ lib/themes/themes.dart | 43 +++++++++++----- pubspec.lock | 9 +--- pubspec.yaml | 3 +- 12 files changed, 118 insertions(+), 63 deletions(-) delete mode 100644 lib/pages/chat/ chat.dart create mode 100644 lib/pages/chat/chat.dart create mode 100644 lib/pages/notifications/notifications.dart create mode 100644 lib/themes/dracula.dart diff --git a/lib/main.dart b/lib/main.dart index 161dc54..ccc0671 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,12 +8,12 @@ import 'package:flutter_localizations/flutter_localizations.dart'; import 'themes/themes.dart' as themes; String _initRoute = "/"; +ThemeData theme = themes.getTheme(themes.available[0]); void main() async { Intl.defaultLocale = 'en_US'; // check if all information is available - settings.saveAuthCode(""); if (await settings.loadAuthCode() == "") { _initRoute = "/login"; } @@ -36,7 +36,7 @@ class _SlothmuState extends State { Widget build(BuildContext context) { LocalJsonLocalization.delegate.directories = ['lib/i18n']; return MaterialApp( - theme: themes.defaultThemeDark, + theme: theme, supportedLocales: supported, localizationsDelegates: [ GlobalCupertinoLocalizations.delegate, diff --git a/lib/pages/chat/ chat.dart b/lib/pages/chat/ chat.dart deleted file mode 100644 index 1703121..0000000 --- a/lib/pages/chat/ chat.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:flutter/widgets.dart'; - -Widget Chat() { - return Center(child: Text("Chat")); -} diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart new file mode 100644 index 0000000..d34e9bb --- /dev/null +++ b/lib/pages/chat/chat.dart @@ -0,0 +1,5 @@ +import 'package:flutter/widgets.dart'; + +Widget chat(context) { + return const Center(child: Text("Chat")); +} diff --git a/lib/pages/login.dart b/lib/pages/login.dart index 3158113..5948d02 100644 --- a/lib/pages/login.dart +++ b/lib/pages/login.dart @@ -44,7 +44,7 @@ class _LoginFormState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - Text("greeting".i18n(), style: const TextStyle(fontSize: 64)), + Text("greeting".i18n(), style: Theme.of(context).textTheme.headline1), TextFormField( onSaved: (value) async { await settings diff --git a/lib/pages/notifications/notifications.dart b/lib/pages/notifications/notifications.dart new file mode 100644 index 0000000..9417a39 --- /dev/null +++ b/lib/pages/notifications/notifications.dart @@ -0,0 +1,5 @@ +import 'package:flutter/material.dart'; + +Widget notifications(context) { + return const Center(child: Text("Notifications")); +} diff --git a/lib/pages/settings/settings.dart b/lib/pages/settings/settings.dart index 6a8f0a0..918f5bc 100644 --- a/lib/pages/settings/settings.dart +++ b/lib/pages/settings/settings.dart @@ -1,15 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:settings_ui/settings_ui.dart'; -Widget Settings() { - return SafeArea( - child: SettingsList(contentPadding: EdgeInsets.all(24), sections: [ - SettingsSection(title: Text("General"), tiles: [ - SettingsTile( - title: Text("Language"), - value: Text("no"), - ) - ]) - ]), +Widget settings(context) { + return const Center( + child: Text("Settings"), ); } diff --git a/lib/pages/timeline/timeline.dart b/lib/pages/timeline/timeline.dart index 70a00af..2aa666a 100644 --- a/lib/pages/timeline/timeline.dart +++ b/lib/pages/timeline/timeline.dart @@ -1,5 +1,9 @@ import 'package:flutter/material.dart'; -Widget Timeline() { - return Center(child: Text("Home")); +Widget timeline(context) { + return Padding( + padding: const EdgeInsets.all(24), + child: Column( + children: [], + )); } diff --git a/lib/partials/main_scaffold.dart b/lib/partials/main_scaffold.dart index 7ba31c3..ce92bdf 100644 --- a/lib/partials/main_scaffold.dart +++ b/lib/partials/main_scaffold.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:slothmu/pages/chat/%20chat.dart'; +import 'package:slothmu/pages/chat/chat.dart'; +import 'package:slothmu/pages/notifications/notifications.dart'; import 'package:slothmu/pages/timeline/timeline.dart'; import 'package:slothmu/pages/settings/settings.dart'; @@ -12,29 +13,49 @@ class MainScaffold extends StatefulWidget { class _MainScaffoldState extends State { int index = 0; - final screens = [ - Timeline(), - Chat(), - Settings(), - ]; @override Widget build(BuildContext context) { + final screens = [ + timeline(context), + chat(context), + notifications(context), + settings(context), + ]; + final buttons = [ + FloatingActionButton( + child: const Icon(Icons.chat_bubble), + onPressed: () {}, + ), + FloatingActionButton( + onPressed: () {}, + child: const Icon(Icons.person_add), + ), + FloatingActionButton( + onPressed: () {}, + child: const Icon(Icons.clear_all), + ), + null, + ]; return Scaffold( + extendBody: true, body: screens[index], - bottomNavigationBar: NavigationBar( - labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected, - elevation: 0, - height: 60, - onDestinationSelected: (index) => setState(() => this.index = index), - selectedIndex: index, - destinations: const [ - NavigationDestination( - icon: Icon(Icons.list_alt), label: "Timeline"), - NavigationDestination(icon: Icon(Icons.chat), label: "Chat"), - NavigationDestination( - icon: Icon(Icons.settings), label: "Settings"), - ]), + floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, + floatingActionButton: buttons[index], + bottomNavigationBar: BottomAppBar( + child: NavigationBar( + onDestinationSelected: (index) => + setState(() => this.index = index), + selectedIndex: index, + destinations: const [ + NavigationDestination(icon: Icon(Icons.forum), label: "Timeline"), + NavigationDestination(icon: Icon(Icons.chat), label: "Chat"), + NavigationDestination( + icon: Icon(Icons.notifications), label: "Notifications"), + NavigationDestination( + icon: Icon(Icons.settings), label: "Settings"), + ]), + ), ); } } diff --git a/lib/themes/dracula.dart b/lib/themes/dracula.dart new file mode 100644 index 0000000..6d2b815 --- /dev/null +++ b/lib/themes/dracula.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; +import 'themes.dart' as themes; + +themes.CustomColors theme = themes.CustomColors( + "Dracula", + const Color.fromARGB( + 255, + 98, + 114, + 164, + ), + const ColorScheme( + brightness: Brightness.dark, + primary: Color.fromARGB(255, 255, 121, 198), + onPrimary: Color.fromARGB(255, 40, 42, 54), + secondary: Color.fromARGB(255, 80, 250, 123), + onSecondary: Color.fromARGB(255, 40, 42, 54), + error: Color.fromARGB(255, 255, 85, 85), + onError: Color.fromARGB(255, 40, 42, 54), + background: Color.fromARGB(255, 40, 42, 54), + onBackground: Color.fromARGB(255, 248, 248, 242), + surface: Color.fromARGB(255, 68, 71, 90), + onSurface: Color.fromARGB(255, 248, 248, 242), + )); diff --git a/lib/themes/themes.dart b/lib/themes/themes.dart index ab5493f..1c00f33 100644 --- a/lib/themes/themes.dart +++ b/lib/themes/themes.dart @@ -1,15 +1,32 @@ import 'package:flutter/material.dart'; +import 'dracula.dart' as color_dracula; -final defaultThemeDark = ThemeData( - colorScheme: const ColorScheme( - brightness: Brightness.dark, - primary: Colors.white, - onPrimary: Colors.black, - secondary: Colors.lime, - onSecondary: Colors.black, - error: Colors.red, - onError: Colors.white, - background: Colors.black, - onBackground: Colors.white, - surface: Colors.deepPurple, - onSurface: Colors.white)); +final available = [color_dracula.theme]; +ThemeData getTheme(CustomColors colors) { + return ThemeData( + scaffoldBackgroundColor: colors.colorScheme.background, + bottomAppBarColor: colors.colorScheme.background, + hintColor: colors.hintColor, + colorScheme: colors.colorScheme, + errorColor: colors.colorScheme.error, + bottomAppBarTheme: BottomAppBarTheme( + color: colors.colorScheme.surface, + shape: const CircularNotchedRectangle(), + elevation: 0, + ), + navigationBarTheme: const NavigationBarThemeData( + backgroundColor: Colors.transparent, + labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected, + indicatorColor: Colors.transparent, + elevation: 0, + height: 64, + ), + ); +} + +class CustomColors { + late String name; + late Color hintColor; + late ColorScheme colorScheme; + CustomColors(this.name, this.hintColor, this.colorScheme); +} diff --git a/pubspec.lock b/pubspec.lock index 678978c..a043b12 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -63,7 +63,7 @@ packages: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" file: dependency: transitive description: @@ -210,13 +210,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.2.4" - settings_ui: - dependency: "direct main" - description: - name: settings_ui - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.2" shared_preferences: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index f2885e0..f49952c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.0+1 +version: 0.1.0+1 environment: sdk: ">=2.17.3 <3.0.0" @@ -36,7 +36,6 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 - settings_ui: ^2.0.2 http: ^0.13.4 localization: ^2.1.0 shared_preferences: ^2.0.15