Skip to content

Commit

Permalink
theming example
Browse files Browse the repository at this point in the history
  • Loading branch information
Moktadir authored and Moktadir committed Nov 16, 2023
1 parent 1b2a60d commit dd76e2e
Show file tree
Hide file tree
Showing 10 changed files with 211 additions and 153 deletions.
48 changes: 24 additions & 24 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ PODS:
- BoringSSL-GRPC/Implementation (0.0.24):
- BoringSSL-GRPC/Interface (= 0.0.24)
- BoringSSL-GRPC/Interface (0.0.24)
- cloud_firestore (4.13.0):
- cloud_firestore (4.13.1):
- Firebase/Firestore (= 10.17.0)
- firebase_core
- Flutter
Expand Down Expand Up @@ -689,7 +689,7 @@ PODS:
- Firebase/Messaging (10.17.0):
- Firebase/CoreOnly
- FirebaseMessaging (~> 10.17.0)
- firebase_auth (4.13.0):
- firebase_auth (4.14.0):
- Firebase/Auth (= 10.17.0)
- firebase_core
- Flutter
Expand All @@ -700,7 +700,7 @@ PODS:
- Firebase/Messaging (= 10.17.0)
- firebase_core
- Flutter
- FirebaseAppCheckInterop (10.17.0)
- FirebaseAppCheckInterop (10.18.0)
- FirebaseAuth (10.17.0):
- FirebaseAppCheckInterop (~> 10.17)
- FirebaseCore (~> 10.0)
Expand All @@ -712,16 +712,16 @@ PODS:
- FirebaseCoreInternal (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/Logger (~> 7.8)
- FirebaseCoreExtension (10.17.0):
- FirebaseCoreExtension (10.18.0):
- FirebaseCore (~> 10.0)
- FirebaseCoreInternal (10.17.0):
- FirebaseCoreInternal (10.18.0):
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- FirebaseFirestore (10.17.0):
- FirebaseCore (~> 10.0)
- FirebaseCoreExtension (~> 10.0)
- FirebaseFirestoreInternal (~> 10.17)
- FirebaseSharedSwift (~> 10.0)
- FirebaseFirestoreInternal (10.17.0):
- FirebaseFirestoreInternal (10.18.0):
- abseil/algorithm (~> 1.20220623.0)
- abseil/base (~> 1.20220623.0)
- abseil/container/flat_hash_map (~> 1.20220623.0)
Expand All @@ -735,7 +735,7 @@ PODS:
- "gRPC-C++ (~> 1.49.1)"
- leveldb-library (~> 1.22)
- nanopb (< 2.30910.0, >= 2.30908.0)
- FirebaseInstallations (10.17.0):
- FirebaseInstallations (10.18.0):
- FirebaseCore (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
Expand All @@ -749,7 +749,7 @@ PODS:
- GoogleUtilities/Reachability (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
- nanopb (< 2.30910.0, >= 2.30908.0)
- FirebaseSharedSwift (10.17.0)
- FirebaseSharedSwift (10.18.0)
- Flutter (1.0.0)
- flutter_local_notifications (0.0.1):
- Flutter
Expand All @@ -762,22 +762,22 @@ PODS:
- GoogleUtilities/Environment (~> 7.7)
- nanopb (< 2.30910.0, >= 2.30908.0)
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/AppDelegateSwizzler (7.11.6):
- GoogleUtilities/AppDelegateSwizzler (7.12.0):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Environment (7.11.6):
- GoogleUtilities/Environment (7.12.0):
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/Logger (7.11.6):
- GoogleUtilities/Logger (7.12.0):
- GoogleUtilities/Environment
- GoogleUtilities/Network (7.11.6):
- GoogleUtilities/Network (7.12.0):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (7.11.6)"
- GoogleUtilities/Reachability (7.11.6):
- "GoogleUtilities/NSData+zlib (7.12.0)"
- GoogleUtilities/Reachability (7.12.0):
- GoogleUtilities/Logger
- GoogleUtilities/UserDefaults (7.11.6):
- GoogleUtilities/UserDefaults (7.12.0):
- GoogleUtilities/Logger
- "gRPC-C++ (1.49.1)":
- "gRPC-C++/Implementation (= 1.49.1)"
Expand Down Expand Up @@ -954,32 +954,32 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
abseil: 926fb7a82dc6d2b8e1f2ed7f3a718bce691d1e46
BoringSSL-GRPC: 3175b25143e648463a56daeaaa499c6cb86dad33
cloud_firestore: d76c02bf5967dc9131ab42fcc1088d0873581e28
cloud_firestore: c0e21891b99d3ac3d91abfe476ac88830a7c9939
connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d
device_info_plus: c6fb39579d0f423935b0c9ce7ee2f44b71b9fce6
DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
file_picker: 15fd9539e4eb735dc54bae8c0534a7a9511a03de
Firebase: f4ac0b02927af9253ae094d23deecf0890da7374
firebase_auth: 8b51489f374ea36b8f0aac047738de1d1f02e573
firebase_auth: 6a41305f668ac6f9bcbefdedfcba5aacb8367e92
firebase_core: efc9455611b8769fa90fbdae5da182600bd6901c
firebase_messaging: 9c697d1ecfe77edf15d995b5048906ffc994c96c
FirebaseAppCheckInterop: 534d033d8d0436b4ab066a8205013d271e18a2b9
FirebaseAppCheckInterop: 3cd914842ba46f4304050874cd284de82f154ffd
FirebaseAuth: 8d285d9f6e39cc8e23be53a4edd83a923ea629d8
FirebaseCore: 534544dd98cabcf4bf8598d88ec683b02319a528
FirebaseCoreExtension: 47720bb330d7041047c0935a34a3a4b92f818074
FirebaseCoreInternal: 2cf9202e226e3f78d2bf6d56c472686b935bfb7f
FirebaseCoreExtension: 62b201498aa10535801cdf3448c7f4db5e24ed80
FirebaseCoreInternal: 8eb002e564b533bdcf1ba011f33f2b5c10e2ed4a
FirebaseFirestore: 67e8c2dc613a86f056cc0037569f2aaee7dbf5fe
FirebaseFirestoreInternal: f902222ee92a48e30693bf347f6a8f365c800e79
FirebaseInstallations: 9387bf15abfc69a714f54e54f74a251264fdb79b
FirebaseFirestoreInternal: 3d5d03f2447caae64311d2cda92abbf4ec5241be
FirebaseInstallations: e842042ec6ac1fd2e37d7706363ebe7f662afea4
FirebaseMessaging: 1367b28c0c83a63072af4a711328fcc2e6899902
FirebaseSharedSwift: e8fe8d63d434266a1b2c7f02807d5b64462e1851
FirebaseSharedSwift: 62e248642c0582324d0390706cadd314687c116b
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
GoogleDataTransport: 54dee9d48d14580407f8f5fbf2f496e92437a2f2
GoogleUtilities: 202e7a9f5128accd11160fb9c19612de1911aa19
GoogleUtilities: 0759d1a57ebb953965c2dfe0ba4c82e95ccc2e34
"gRPC-C++": 2df8cba576898bdacd29f0266d5236fa0e26ba6a
gRPC-Core: a21a60aefc08c68c247b439a9ef97174b0c54f96
GTMSessionFetcher: e8647203b65cee28c5f73d0f473d096653945e72
Expand Down
5 changes: 2 additions & 3 deletions lib/app/components/global-widgets/my_buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';

class PrimaryButton extends StatelessWidget {
const PrimaryButton(
{Key? key,
{super.key,
required this.title,
required this.onPressed,
required this.inactive})
: super(key: key);
required this.inactive});
final String title;
final VoidCallback onPressed;
final bool inactive;
Expand Down
28 changes: 19 additions & 9 deletions lib/app/modules/example/home-with-graphql/views/graphql_view.dart
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:getx_standard/app/components/global-widgets/my_buttons.dart';
import 'package:iconly/iconly.dart';
import 'package:iconsax/iconsax.dart';

import '../../../../../config/theme/my_fonts.dart';
import '../../../../../config/theme/my_theme.dart';
import '../../../../components/global-widgets/empty_widget.dart';
import '../controllers/graphql_controller.dart';

class GraphQLView extends GetView<GraphQLController> {
const GraphQLView({Key? key}) : super(key: key);
const GraphQLView({super.key});

@override
Widget build(BuildContext context) {
var theme = Theme.of(context);

return Scaffold(
appBar: AppBar(
title: const Text('GraphQL'),
title: const Text('GetX Standard'),
leading: IconButton(
onPressed: () => MyTheme.changeTheme(),
icon: Icon(
Get.isDarkMode ? Iconsax.moon5 : Iconsax.sun5,
color: Colors.white,
),
),
actions: [
IconButton(
onPressed: () => controller.navController.selectedIndex.value = 0,
Expand All @@ -42,13 +52,13 @@ class GraphQLView extends GetView<GraphQLController> {
child: Column(
children: [
SizedBox(
width: 150.w,
child: ElevatedButton(
onPressed: () async {
await controller.updateTodo();
},
child: const Text("Run mutation")),
),
width: 150.sp,
height: 48.sp,
child: PrimaryButton(
title: "Run mutation",
onPressed: () async =>
await controller.updateTodo(),
inactive: false)),
SizedBox(height: 10.h),
controller.mutationResult.isEmpty
? const SizedBox()
Expand Down
38 changes: 28 additions & 10 deletions lib/app/modules/example/home-with-restAPI/views/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,41 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:getx_standard/app/components/global-widgets/splash_container.dart';
import 'package:getx_standard/config/theme/dark_theme_colors.dart';
import 'package:getx_standard/config/theme/light_theme_colors.dart';
import 'package:iconly/iconly.dart';
import 'package:iconsax/iconsax.dart';

import '../../../../../config/theme/my_theme.dart';
import '../../../../components/global-widgets/empty_widget.dart';
import '../../../../components/global-widgets/network_image_box.dart';
import '../controllers/home_controller.dart';

class HomeView extends GetView<HomeController> {
const HomeView({Key? key}) : super(key: key);
const HomeView({super.key});

@override
Widget build(BuildContext context) {
var theme = Theme.of(context);

return Scaffold(
appBar: AppBar(
title: const Text('Tasty'),
title: const Text('GetX Standard'),
leading: IconButton(
onPressed: () => MyTheme.changeTheme(),
icon: Icon(
Get.isDarkMode ? Iconsax.moon5 : Iconsax.sun5,
color: Colors.white,
),
),
actions: [
IconButton(
onPressed: () => controller.navController.selectedIndex.value = 1,
icon: const Icon(
IconlyBold.graph,
color: Colors.white,
)),
onPressed: () => controller.navController.selectedIndex.value = 1,
icon: const Icon(
IconlyBold.graph,
color: Colors.white,
),
),
],
centerTitle: true,
),
Expand Down Expand Up @@ -147,9 +158,16 @@ class HomeView extends GetView<HomeController> {
color: const Color(0xffFFAD30),
size: 18.sp,
),
Text(controller
.recipes[index].userRatings!.score!
.toStringAsFixed(1)),
Text(
controller.recipes[index].userRatings!.score!
.toStringAsFixed(1),
style: TextStyle(
color: Get.isDarkMode
? DarkThemeColors
.scaffoldBackgroundColor
: LightThemeColors.primaryColor,
),
),
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/config/theme/dark_theme_colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DarkThemeColors {

//BUTTON
static const Color buttonColor = primaryColor;
static const Color buttonTextColor = Colors.black;
static const Color buttonTextColor = Colors.white;
static const Color buttonDisabledColor = Colors.grey;
static const Color buttonDisabledTextColor = Colors.black;

Expand Down
34 changes: 25 additions & 9 deletions lib/config/theme/my_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,46 @@ import 'my_styles.dart';
class MyTheme {
static getThemeData({required bool isLight}) {
return ThemeData(
useMaterial3: true,

// main color (app bar,tabs..etc)
primaryColor: isLight
? LightThemeColors.primaryColor
: DarkThemeColors.primaryColor,

// secondary & background color
colorScheme: ColorScheme.fromSwatch(
accentColor: isLight
? LightThemeColors.accentColor
: DarkThemeColors.accentColor,
backgroundColor: isLight
? LightThemeColors.backgroundColor
: DarkThemeColors.backgroundColor,
brightness: isLight ? Brightness.light : Brightness.dark,
).copyWith(
secondary: isLight
? LightThemeColors.accentColor
: DarkThemeColors.accentColor,
),

// color contrast (if the theme is dark text should be white for example)
brightness: isLight ? Brightness.light : Brightness.dark,

// card widget background color
cardColor:
isLight ? LightThemeColors.cardColor : DarkThemeColors.cardColor,

// hint text color
hintColor: isLight
? LightThemeColors.hintTextColor
: DarkThemeColors.hintTextColor,

// divider color
dividerColor: isLight
? LightThemeColors.dividerColor
: DarkThemeColors.dividerColor,

// app background color
scaffoldBackgroundColor: isLight
? LightThemeColors.scaffoldBackgroundColor
: DarkThemeColors.scaffoldBackgroundColor,
Expand All @@ -52,15 +75,6 @@ class MyTheme {

// icon theme
iconTheme: MyStyles.getIconTheme(isLightTheme: isLight),
colorScheme: ColorScheme.fromSwatch()
.copyWith(
secondary: isLight
? LightThemeColors.accentColor
: DarkThemeColors.accentColor)
.copyWith(
background: isLight
? LightThemeColors.backgroundColor
: DarkThemeColors.backgroundColor),
);
}

Expand All @@ -69,8 +83,10 @@ class MyTheme {
static changeTheme() {
// *) check if the current theme is light (default is light)
bool isLightTheme = MySharedPref.getThemeIsLight();

// *) store the new theme mode on get storage
MySharedPref.setThemeIsLight(!isLightTheme);

// *) let GetX change theme
Get.changeThemeMode(!isLightTheme ? ThemeMode.light : ThemeMode.dark);
}
Expand Down
Loading

0 comments on commit dd76e2e

Please sign in to comment.