theming!!!

This commit is contained in:
zoe 2022-07-03 00:03:10 +02:00
parent 839bb0bbde
commit c63f062640
12 changed files with 118 additions and 63 deletions

View file

@ -8,12 +8,12 @@ import 'package:flutter_localizations/flutter_localizations.dart';
import 'themes/themes.dart' as themes; import 'themes/themes.dart' as themes;
String _initRoute = "/"; String _initRoute = "/";
ThemeData theme = themes.getTheme(themes.available[0]);
void main() async { void main() async {
Intl.defaultLocale = 'en_US'; Intl.defaultLocale = 'en_US';
// check if all information is available // check if all information is available
settings.saveAuthCode("");
if (await settings.loadAuthCode() == "") { if (await settings.loadAuthCode() == "") {
_initRoute = "/login"; _initRoute = "/login";
} }
@ -36,7 +36,7 @@ class _SlothmuState extends State<Slothmu> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
LocalJsonLocalization.delegate.directories = ['lib/i18n']; LocalJsonLocalization.delegate.directories = ['lib/i18n'];
return MaterialApp( return MaterialApp(
theme: themes.defaultThemeDark, theme: theme,
supportedLocales: supported, supportedLocales: supported,
localizationsDelegates: [ localizationsDelegates: [
GlobalCupertinoLocalizations.delegate, GlobalCupertinoLocalizations.delegate,

View file

@ -1,5 +0,0 @@
import 'package:flutter/widgets.dart';
Widget Chat() {
return Center(child: Text("Chat"));
}

5
lib/pages/chat/chat.dart Normal file
View file

@ -0,0 +1,5 @@
import 'package:flutter/widgets.dart';
Widget chat(context) {
return const Center(child: Text("Chat"));
}

View file

@ -44,7 +44,7 @@ class _LoginFormState extends State<LoginForm> {
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [ children: [
Text("greeting".i18n(), style: const TextStyle(fontSize: 64)), Text("greeting".i18n(), style: Theme.of(context).textTheme.headline1),
TextFormField( TextFormField(
onSaved: (value) async { onSaved: (value) async {
await settings await settings

View file

@ -0,0 +1,5 @@
import 'package:flutter/material.dart';
Widget notifications(context) {
return const Center(child: Text("Notifications"));
}

View file

@ -1,15 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:settings_ui/settings_ui.dart';
Widget Settings() { Widget settings(context) {
return SafeArea( return const Center(
child: SettingsList(contentPadding: EdgeInsets.all(24), sections: [ child: Text("Settings"),
SettingsSection(title: Text("General"), tiles: [
SettingsTile(
title: Text("Language"),
value: Text("no"),
)
])
]),
); );
} }

View file

@ -1,5 +1,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
Widget Timeline() { Widget timeline(context) {
return Center(child: Text("Home")); return Padding(
padding: const EdgeInsets.all(24),
child: Column(
children: [],
));
} }

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; 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/timeline/timeline.dart';
import 'package:slothmu/pages/settings/settings.dart'; import 'package:slothmu/pages/settings/settings.dart';
@ -12,29 +13,49 @@ class MainScaffold extends StatefulWidget {
class _MainScaffoldState extends State<MainScaffold> { class _MainScaffoldState extends State<MainScaffold> {
int index = 0; int index = 0;
final screens = [
Timeline(),
Chat(),
Settings(),
];
@override @override
Widget build(BuildContext context) { 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( return Scaffold(
extendBody: true,
body: screens[index], body: screens[index],
bottomNavigationBar: NavigationBar( floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected, floatingActionButton: buttons[index],
elevation: 0, bottomNavigationBar: BottomAppBar(
height: 60, child: NavigationBar(
onDestinationSelected: (index) => setState(() => this.index = index), onDestinationSelected: (index) =>
selectedIndex: index, setState(() => this.index = index),
destinations: const [ selectedIndex: index,
NavigationDestination( destinations: const [
icon: Icon(Icons.list_alt), label: "Timeline"), NavigationDestination(icon: Icon(Icons.forum), label: "Timeline"),
NavigationDestination(icon: Icon(Icons.chat), label: "Chat"), NavigationDestination(icon: Icon(Icons.chat), label: "Chat"),
NavigationDestination( NavigationDestination(
icon: Icon(Icons.settings), label: "Settings"), icon: Icon(Icons.notifications), label: "Notifications"),
]), NavigationDestination(
icon: Icon(Icons.settings), label: "Settings"),
]),
),
); );
} }
} }

24
lib/themes/dracula.dart Normal file
View file

@ -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),
));

View file

@ -1,15 +1,32 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'dracula.dart' as color_dracula;
final defaultThemeDark = ThemeData( final available = [color_dracula.theme];
colorScheme: const ColorScheme( ThemeData getTheme(CustomColors colors) {
brightness: Brightness.dark, return ThemeData(
primary: Colors.white, scaffoldBackgroundColor: colors.colorScheme.background,
onPrimary: Colors.black, bottomAppBarColor: colors.colorScheme.background,
secondary: Colors.lime, hintColor: colors.hintColor,
onSecondary: Colors.black, colorScheme: colors.colorScheme,
error: Colors.red, errorColor: colors.colorScheme.error,
onError: Colors.white, bottomAppBarTheme: BottomAppBarTheme(
background: Colors.black, color: colors.colorScheme.surface,
onBackground: Colors.white, shape: const CircularNotchedRectangle(),
surface: Colors.deepPurple, elevation: 0,
onSurface: Colors.white)); ),
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);
}

View file

@ -63,7 +63,7 @@ packages:
name: ffi name: ffi
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.0.1"
file: file:
dependency: transitive dependency: transitive
description: description:
@ -210,13 +210,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.2.4" 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: shared_preferences:
dependency: "direct main" dependency: "direct main"
description: description:

View file

@ -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. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at # Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1 version: 0.1.0+1
environment: environment:
sdk: ">=2.17.3 <3.0.0" sdk: ">=2.17.3 <3.0.0"
@ -36,7 +36,6 @@ dependencies:
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2
settings_ui: ^2.0.2
http: ^0.13.4 http: ^0.13.4
localization: ^2.1.0 localization: ^2.1.0
shared_preferences: ^2.0.15 shared_preferences: ^2.0.15