Changed primary color for old Android versions

This commit is contained in:
Juan Gilsanz Polo 2022-09-28 02:51:55 +02:00
parent fcac9ccbe4
commit a1f2de6812
3 changed files with 105 additions and 43 deletions

View file

@ -1,12 +1,24 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
const MaterialColor primaryColorLight = Colors.blue; Map<int, Color> swatch = {
const MaterialColor primaryColorDark = Colors.lightBlue; 50: const Color.fromRGBO(25, 180, 119, .1),
100: const Color.fromRGBO(25, 180, 119, .2),
200: const Color.fromRGBO(25, 180, 119, .3),
300: const Color.fromRGBO(25, 180, 119, .4),
400: const Color.fromRGBO(25, 180, 119, .5),
500: const Color.fromRGBO(25, 180, 119, .6),
600: const Color.fromRGBO(25, 180, 119, .7),
700: const Color.fromRGBO(25, 180, 119, .8),
800: const Color.fromRGBO(25, 180, 119, .9),
900: const Color.fromRGBO(25, 180, 119, 1),
};
MaterialColor primaryColor = MaterialColor(0xff19b477, swatch);
ThemeData lightTheme(ColorScheme? dynamicColorScheme) => ThemeData( ThemeData lightTheme(ColorScheme? dynamicColorScheme) => ThemeData(
useMaterial3: true, useMaterial3: true,
colorScheme: dynamicColorScheme ?? ColorScheme.fromSwatch(primarySwatch: primaryColorLight), colorScheme: dynamicColorScheme ?? ColorScheme.fromSwatch(primarySwatch: primaryColor),
primaryColor: dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColorLight, primaryColor: dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColor,
scaffoldBackgroundColor: dynamicColorScheme != null ? dynamicColorScheme.background : Colors.white, scaffoldBackgroundColor: dynamicColorScheme != null ? dynamicColorScheme.background : Colors.white,
snackBarTheme: SnackBarThemeData( snackBarTheme: SnackBarThemeData(
behavior: SnackBarBehavior.floating, behavior: SnackBarBehavior.floating,
@ -27,15 +39,15 @@ ThemeData lightTheme(ColorScheme? dynamicColorScheme) => ThemeData(
), ),
floatingActionButtonTheme: FloatingActionButtonThemeData( floatingActionButtonTheme: FloatingActionButtonThemeData(
foregroundColor: Colors.white, foregroundColor: Colors.white,
backgroundColor: dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColorLight backgroundColor: dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColor
), ),
textButtonTheme: TextButtonThemeData( textButtonTheme: TextButtonThemeData(
style: ButtonStyle( style: ButtonStyle(
foregroundColor: MaterialStateProperty.all( foregroundColor: MaterialStateProperty.all(
dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColorLight dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColor
), ),
overlayColor: MaterialStateProperty.all( overlayColor: MaterialStateProperty.all(
dynamicColorScheme != null ? dynamicColorScheme.primary.withOpacity(0.1) : primaryColorLight.withOpacity(0.1) dynamicColorScheme != null ? dynamicColorScheme.primary.withOpacity(0.1) : primaryColor.withOpacity(0.1)
), ),
), ),
), ),
@ -46,15 +58,15 @@ ThemeData lightTheme(ColorScheme? dynamicColorScheme) => ThemeData(
checkboxTheme: CheckboxThemeData( checkboxTheme: CheckboxThemeData(
checkColor: MaterialStateProperty.all(Colors.white), checkColor: MaterialStateProperty.all(Colors.white),
fillColor: MaterialStateProperty.all( fillColor: MaterialStateProperty.all(
dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColorLight dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColor
), ),
), ),
tabBarTheme: TabBarTheme( tabBarTheme: TabBarTheme(
unselectedLabelColor: Colors.black, unselectedLabelColor: Colors.black,
labelColor: dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColorLight, labelColor: dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColor,
indicator: UnderlineTabIndicator( indicator: UnderlineTabIndicator(
borderSide: BorderSide( borderSide: BorderSide(
color: dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColorLight, color: dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColor,
width: 2 width: 2
) )
) )
@ -64,14 +76,14 @@ ThemeData lightTheme(ColorScheme? dynamicColorScheme) => ThemeData(
ThemeData darkTheme(ColorScheme? dynamicColorScheme) => ThemeData( ThemeData darkTheme(ColorScheme? dynamicColorScheme) => ThemeData(
useMaterial3: true, useMaterial3: true,
colorScheme: dynamicColorScheme ?? ColorScheme.fromSwatch(primarySwatch: primaryColorDark).copyWith( colorScheme: dynamicColorScheme ?? ColorScheme.fromSwatch(primarySwatch: primaryColor).copyWith(
brightness: Brightness.dark brightness: Brightness.dark
), ),
primaryColor: dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColorDark, primaryColor: dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColor,
scaffoldBackgroundColor: dynamicColorScheme != null ? dynamicColorScheme.background :const Color.fromRGBO(18, 18, 18, 1), scaffoldBackgroundColor: dynamicColorScheme != null ? dynamicColorScheme.background :const Color.fromRGBO(18, 18, 18, 1),
dialogBackgroundColor: dynamicColorScheme != null ? dynamicColorScheme.background : const Color.fromRGBO(44, 44, 44, 1), dialogBackgroundColor: dynamicColorScheme != null ? dynamicColorScheme.background : const Color.fromRGBO(44, 44, 44, 1),
navigationBarTheme: NavigationBarThemeData( navigationBarTheme: NavigationBarThemeData(
indicatorColor: dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColorDark, indicatorColor: dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColor,
), ),
snackBarTheme: SnackBarThemeData( snackBarTheme: SnackBarThemeData(
contentTextStyle: const TextStyle( contentTextStyle: const TextStyle(
@ -85,15 +97,15 @@ ThemeData darkTheme(ColorScheme? dynamicColorScheme) => ThemeData(
), ),
floatingActionButtonTheme: FloatingActionButtonThemeData( floatingActionButtonTheme: FloatingActionButtonThemeData(
foregroundColor: Colors.white, foregroundColor: Colors.white,
backgroundColor: dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColorDark backgroundColor: dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColor
), ),
textButtonTheme: TextButtonThemeData( textButtonTheme: TextButtonThemeData(
style: ButtonStyle( style: ButtonStyle(
foregroundColor: MaterialStateProperty.all( foregroundColor: MaterialStateProperty.all(
dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColorDark dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColor
), ),
overlayColor: MaterialStateProperty.all( overlayColor: MaterialStateProperty.all(
dynamicColorScheme != null ? dynamicColorScheme.primary.withOpacity(0.1) : primaryColorDark.withOpacity(0.1) dynamicColorScheme != null ? dynamicColorScheme.primary.withOpacity(0.1) : primaryColor.withOpacity(0.1)
), ),
), ),
), ),
@ -113,15 +125,15 @@ ThemeData darkTheme(ColorScheme? dynamicColorScheme) => ThemeData(
checkboxTheme: CheckboxThemeData( checkboxTheme: CheckboxThemeData(
checkColor: MaterialStateProperty.all(Colors.white), checkColor: MaterialStateProperty.all(Colors.white),
fillColor: MaterialStateProperty.all( fillColor: MaterialStateProperty.all(
dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColorDark dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColor
), ),
), ),
tabBarTheme: TabBarTheme( tabBarTheme: TabBarTheme(
unselectedLabelColor: Colors.white, unselectedLabelColor: Colors.white,
labelColor: dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColorDark, labelColor: dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColor,
indicator: UnderlineTabIndicator( indicator: UnderlineTabIndicator(
borderSide: BorderSide( borderSide: BorderSide(
color: dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColorDark, color: dynamicColorScheme != null ? dynamicColorScheme.primary : primaryColor,
width: 2 width: 2
) )
) )
@ -131,11 +143,12 @@ ThemeData darkTheme(ColorScheme? dynamicColorScheme) => ThemeData(
ThemeData lightThemeOldVersions() => ThemeData( ThemeData lightThemeOldVersions() => ThemeData(
useMaterial3: true, useMaterial3: true,
primaryColor: primaryColorLight, primaryColor: primaryColor,
appBarTheme: const AppBarTheme( appBarTheme: AppBarTheme(
color: Colors.white, color: Colors.white,
foregroundColor: Colors.black, foregroundColor: Colors.black,
elevation: 0 elevation: 0,
surfaceTintColor: primaryColor
), ),
snackBarTheme: SnackBarThemeData( snackBarTheme: SnackBarThemeData(
behavior: SnackBarBehavior.floating, behavior: SnackBarBehavior.floating,
@ -155,52 +168,80 @@ ThemeData lightThemeOldVersions() => ThemeData(
color: Colors.black color: Colors.black
), ),
), ),
floatingActionButtonTheme: const FloatingActionButtonThemeData( floatingActionButtonTheme: FloatingActionButtonThemeData(
foregroundColor: Colors.white, foregroundColor: Colors.white,
backgroundColor: primaryColor
), ),
textButtonTheme: TextButtonThemeData( textButtonTheme: TextButtonThemeData(
style: ButtonStyle( style: ButtonStyle(
foregroundColor: MaterialStateProperty.all(primaryColorLight), foregroundColor: MaterialStateProperty.all(primaryColor),
overlayColor: MaterialStateProperty.all(primaryColorLight.withOpacity(0.1)) overlayColor: MaterialStateProperty.all(primaryColor.withOpacity(0.1))
), ),
), ),
navigationBarTheme: NavigationBarThemeData(
surfaceTintColor: primaryColor,
indicatorColor: primaryColor
),
inputDecorationTheme: InputDecorationTheme(
floatingLabelStyle: TextStyle(
color: primaryColor
),
iconColor: Colors.grey,
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: primaryColor,
width: 2
)
)
),
textSelectionTheme: TextSelectionThemeData(
cursorColor: primaryColor
),
dividerColor: Colors.black12, dividerColor: Colors.black12,
listTileTheme: const ListTileThemeData( listTileTheme: const ListTileThemeData(
tileColor: Colors.transparent tileColor: Colors.transparent
), ),
checkboxTheme: CheckboxThemeData( checkboxTheme: CheckboxThemeData(
checkColor: MaterialStateProperty.all(Colors.white), checkColor: MaterialStateProperty.all(Colors.white),
fillColor: MaterialStateProperty.all(primaryColorLight), fillColor: MaterialStateProperty.all(primaryColor),
), ),
tabBarTheme: const TabBarTheme( tabBarTheme: TabBarTheme(
unselectedLabelColor: Colors.black, unselectedLabelColor: Colors.black,
labelColor: primaryColorLight, labelColor: primaryColor,
indicator: UnderlineTabIndicator( indicator: UnderlineTabIndicator(
borderSide: BorderSide( borderSide: BorderSide(
color: primaryColorLight, color: primaryColor,
width: 2 width: 2
) )
) )
), ),
progressIndicatorTheme: ProgressIndicatorThemeData(
color: primaryColor
),
indicatorColor: primaryColor,
androidOverscrollIndicator: AndroidOverscrollIndicator.stretch, androidOverscrollIndicator: AndroidOverscrollIndicator.stretch,
); );
ThemeData darkThemeOldVersions() => ThemeData( ThemeData darkThemeOldVersions() => ThemeData(
useMaterial3: true, useMaterial3: true,
primaryColor: primaryColorDark, primaryColor: primaryColor,
scaffoldBackgroundColor: const Color.fromRGBO(18, 18, 18, 1), scaffoldBackgroundColor: const Color.fromRGBO(18, 18, 18, 1),
navigationBarTheme: const NavigationBarThemeData( navigationBarTheme: NavigationBarThemeData(
indicatorColor: primaryColorDark, indicatorColor: primaryColor,
surfaceTintColor: primaryColor
), ),
dialogTheme: DialogTheme( dialogTheme: DialogTheme(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30) borderRadius: BorderRadius.circular(30)
) )
), ),
appBarTheme: const AppBarTheme( appBarTheme: AppBarTheme(
color: Color.fromRGBO(18, 18, 18, 1), color: const Color.fromRGBO(18, 18, 18, 1),
foregroundColor: Colors.white, foregroundColor: Colors.white,
elevation: 0 elevation: 0,
surfaceTintColor: primaryColor
), ),
dialogBackgroundColor: const Color.fromRGBO(44, 44, 44, 1), dialogBackgroundColor: const Color.fromRGBO(44, 44, 44, 1),
snackBarTheme: SnackBarThemeData( snackBarTheme: SnackBarThemeData(
@ -213,16 +254,31 @@ ThemeData darkThemeOldVersions() => ThemeData(
), ),
elevation: 4, elevation: 4,
), ),
floatingActionButtonTheme: const FloatingActionButtonThemeData( floatingActionButtonTheme: FloatingActionButtonThemeData(
foregroundColor: Colors.white, foregroundColor: Colors.white,
backgroundColor: primaryColorDark backgroundColor: primaryColor
), ),
textButtonTheme: TextButtonThemeData( textButtonTheme: TextButtonThemeData(
style: ButtonStyle( style: ButtonStyle(
foregroundColor: MaterialStateProperty.all(primaryColorDark), foregroundColor: MaterialStateProperty.all(primaryColor),
overlayColor: MaterialStateProperty.all(primaryColorDark.withOpacity(0.1)) overlayColor: MaterialStateProperty.all(primaryColor.withOpacity(0.1))
), ),
), ),
inputDecorationTheme: InputDecorationTheme(
floatingLabelStyle: TextStyle(
color: primaryColor
),
iconColor: Colors.grey,
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: primaryColor,
)
)
),
textSelectionTheme: TextSelectionThemeData(
cursorColor: primaryColor
),
brightness: Brightness.dark, brightness: Brightness.dark,
textTheme: const TextTheme( textTheme: const TextTheme(
bodyText1: TextStyle( bodyText1: TextStyle(
@ -240,15 +296,19 @@ ThemeData darkThemeOldVersions() => ThemeData(
checkColor: MaterialStateProperty.all(Colors.white), checkColor: MaterialStateProperty.all(Colors.white),
fillColor: MaterialStateProperty.all(Colors.blue), fillColor: MaterialStateProperty.all(Colors.blue),
), ),
tabBarTheme: const TabBarTheme( tabBarTheme: TabBarTheme(
unselectedLabelColor: Colors.white, unselectedLabelColor: Colors.white,
labelColor: primaryColorDark, labelColor: primaryColor,
indicator: UnderlineTabIndicator( indicator: UnderlineTabIndicator(
borderSide: BorderSide( borderSide: BorderSide(
color: primaryColorDark, color: primaryColor,
width: 2 width: 2
) )
) )
), ),
progressIndicatorTheme: ProgressIndicatorThemeData(
color: primaryColor
),
indicatorColor: primaryColor,
androidOverscrollIndicator: AndroidOverscrollIndicator.stretch androidOverscrollIndicator: AndroidOverscrollIndicator.stretch
); );

View file

@ -25,6 +25,7 @@ class HomeAppBar extends StatelessWidget with PreferredSizeWidget {
} }
return AppBar( return AppBar(
toolbarHeight: 70,
title: Padding( title: Padding(
padding: const EdgeInsets.only(bottom: 5), padding: const EdgeInsets.only(bottom: 5),
child: Row( child: Row(
@ -89,5 +90,5 @@ class HomeAppBar extends StatelessWidget with PreferredSizeWidget {
} }
@override @override
Size get preferredSize => const Size.fromHeight(kToolbarHeight); Size get preferredSize => const Size.fromHeight(70);
} }

View file

@ -116,6 +116,7 @@ class Home extends StatelessWidget {
} }
return RefreshIndicator( return RefreshIndicator(
color: Theme.of(context).primaryColor,
onRefresh: () async { onRefresh: () async {
final result = await getServerStatus(serversProvider.selectedServer!); final result = await getServerStatus(serversProvider.selectedServer!);
if (result['result'] == 'success') { if (result['result'] == 'success') {