Skip to content

Commit

Permalink
issue #185
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonavichus committed Jul 9, 2024
1 parent 9a7858f commit dd3339b
Show file tree
Hide file tree
Showing 8 changed files with 1,048 additions and 931 deletions.
385 changes: 194 additions & 191 deletions lib/app/modules/cards/widgets/create_card_weather.dart

Large diffs are not rendered by default.

1,431 changes: 726 additions & 705 deletions lib/app/modules/settings/view/settings.dart

Large diffs are not rendered by default.

34 changes: 21 additions & 13 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import 'package:rain/app/modules/geolocation.dart';
import 'package:rain/app/modules/home.dart';
import 'package:rain/app/modules/onboarding.dart';
import 'package:rain/theme/theme.dart';
import 'package:rain/utils/device_info.dart';
import 'package:time_machine/time_machine.dart';
import 'package:timezone/data/latest_all.dart' as tz;
import 'package:timezone/timezone.dart' as tz;
Expand Down Expand Up @@ -92,8 +93,7 @@ void main() async {
? isOnline.value = Future(() => false)
: isOnline.value = InternetConnection().hasInternetAccess;
});
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(systemNavigationBarColor: Colors.black));
DeviceFeature().init();
if (Platform.isAndroid) {
Workmanager().initialize(callbackDispatcher, isInDebugMode: kDebugMode);
await setOptimalDisplayMode();
Expand Down Expand Up @@ -284,34 +284,42 @@ class _MyAppState extends State<MyApp> {

@override
Widget build(BuildContext context) {
final edgeToEdgeAvailable = DeviceFeature().isEdgeToEdgeAvailable();
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);

return GestureDetector(
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
child: DynamicColorBuilder(
builder: (lightColorScheme, darkColorScheme) {
final lightMaterialTheme =
lightTheme(lightColorScheme?.surface, lightColorScheme);
final darkMaterialTheme =
darkTheme(darkColorScheme?.surface, darkColorScheme);
final darkMaterialThemeOled = darkTheme(oledColor, darkColorScheme);
final lightMaterialTheme = lightTheme(
lightColorScheme?.surface, lightColorScheme, edgeToEdgeAvailable);
final darkMaterialTheme = darkTheme(
darkColorScheme?.surface, darkColorScheme, edgeToEdgeAvailable);
final darkMaterialThemeOled =
darkTheme(oledColor, darkColorScheme, edgeToEdgeAvailable);

return GetMaterialApp(
themeMode: themeController.theme,
theme: materialColor
? lightColorScheme != null
? lightMaterialTheme
: lightTheme(lightColor, colorSchemeLight)
: lightTheme(lightColor, colorSchemeLight),
: lightTheme(
lightColor, colorSchemeLight, edgeToEdgeAvailable)
: lightTheme(lightColor, colorSchemeLight, edgeToEdgeAvailable),
darkTheme: amoledTheme
? materialColor
? darkColorScheme != null
? darkMaterialThemeOled
: darkTheme(oledColor, colorSchemeDark)
: darkTheme(oledColor, colorSchemeDark)
: darkTheme(
oledColor, colorSchemeDark, edgeToEdgeAvailable)
: darkTheme(oledColor, colorSchemeDark, edgeToEdgeAvailable)
: materialColor
? darkColorScheme != null
? darkMaterialTheme
: darkTheme(darkColor, colorSchemeDark)
: darkTheme(darkColor, colorSchemeDark),
: darkTheme(
darkColor, colorSchemeDark, edgeToEdgeAvailable)
: darkTheme(
darkColor, colorSchemeDark, edgeToEdgeAvailable),
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
Expand Down
27 changes: 25 additions & 2 deletions lib/theme/theme.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:dynamic_color/dynamic_color.dart';

Expand All @@ -18,7 +19,8 @@ ColorScheme colorSchemeDark = ColorScheme.fromSeed(
brightness: Brightness.dark,
);

ThemeData lightTheme(Color? color, ColorScheme? colorScheme) {
ThemeData lightTheme(
Color? color, ColorScheme? colorScheme, bool edgeToEdgeAvailable) {
return baseLigth.copyWith(
brightness: Brightness.light,
colorScheme: colorScheme
Expand All @@ -34,6 +36,16 @@ ThemeData lightTheme(Color? color, ColorScheme? colorScheme) {
shadowColor: Colors.transparent,
surfaceTintColor: Colors.transparent,
elevation: 0,
systemOverlayStyle: SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.dark,
statusBarColor: Colors.transparent,
systemStatusBarContrastEnforced: false,
systemNavigationBarContrastEnforced: false,
systemNavigationBarDividerColor: Colors.transparent,
systemNavigationBarIconBrightness: Brightness.dark,
systemNavigationBarColor:
edgeToEdgeAvailable ? Colors.transparent : colorScheme?.surface,
),
),
primaryColor: color,
canvasColor: color,
Expand Down Expand Up @@ -74,7 +86,8 @@ ThemeData lightTheme(Color? color, ColorScheme? colorScheme) {
);
}

ThemeData darkTheme(Color? color, ColorScheme? colorScheme) {
ThemeData darkTheme(
Color? color, ColorScheme? colorScheme, bool edgeToEdgeAvailable) {
return baseDark.copyWith(
brightness: Brightness.dark,
colorScheme: colorScheme
Expand All @@ -90,6 +103,16 @@ ThemeData darkTheme(Color? color, ColorScheme? colorScheme) {
shadowColor: Colors.transparent,
surfaceTintColor: Colors.transparent,
elevation: 0,
systemOverlayStyle: SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.light,
statusBarColor: Colors.transparent,
systemStatusBarContrastEnforced: false,
systemNavigationBarContrastEnforced: false,
systemNavigationBarDividerColor: Colors.transparent,
systemNavigationBarIconBrightness: Brightness.light,
systemNavigationBarColor:
edgeToEdgeAvailable ? Colors.transparent : colorScheme?.surface,
),
),
primaryColor: color,
canvasColor: color,
Expand Down
31 changes: 31 additions & 0 deletions lib/utils/device_info.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/foundation.dart';

class DeviceFeature {
DeviceFeature._internal();

static final DeviceFeature _singleton = DeviceFeature._internal();

factory DeviceFeature() {
return _singleton;
}

final _deviceInfoPlugin = DeviceInfoPlugin();

AndroidDeviceInfo? _androidDeviceInfo;

Future<void> init() async {
try {
_androidDeviceInfo = await _deviceInfoPlugin.androidInfo;
} catch (e) {
if (kDebugMode) {
print('Error initializing device info: $e');
}
}
}

bool isEdgeToEdgeAvailable() {
return _androidDeviceInfo != null &&
_androidDeviceInfo!.version.sdkInt > 28;
}
}
2 changes: 2 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import FlutterMacOS
import Foundation

import connectivity_plus
import device_info_plus
import dynamic_color
import flutter_local_notifications
import flutter_timezone
Expand All @@ -17,6 +18,7 @@ import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin"))
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
FlutterTimezonePlugin.register(with: registry.registrar(forPlugin: "FlutterTimezonePlugin"))
Expand Down
61 changes: 43 additions & 18 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.10"
device_info_plus:
dependency: "direct main"
description:
name: device_info_plus
sha256: eead12d1a1ed83d8283ab4c2f3fca23ac4082f29f25f29dff0f758f57d06ec91
url: "https://pub.dev"
source: hosted
version: "10.1.0"
device_info_plus_platform_interface:
dependency: transitive
description:
name: device_info_plus_platform_interface
sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64
url: "https://pub.dev"
source: hosted
version: "7.0.0"
dio:
dependency: "direct main"
description:
Expand Down Expand Up @@ -302,6 +318,15 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.6.0"
flutter_glow:
dependency: "direct main"
description:
path: "."
ref: HEAD
resolved-ref: "7c5e1fd34583db4b40073add9ca329b03bf52a51"
url: "https://github.com/payam-zahedi/flutter-glow.git"
source: git
version: "0.3.1"
flutter_hsvcolor_picker:
dependency: "direct main"
description:
Expand Down Expand Up @@ -372,10 +397,10 @@ packages:
dependency: "direct main"
description:
name: flutter_timezone
sha256: b7448ff8a9e1350606727e40b3f314aa798a6a1cc07127eba58f09b98a66f03f
sha256: f9c328f66d58cd2af8a0cbd2f84d0c211fda8b7332b5e458d9848bd9ec936120
url: "https://pub.dev"
source: hosted
version: "2.0.0"
version: "2.0.1"
flutter_web_plugins:
dependency: transitive
description: flutter
Expand All @@ -393,10 +418,10 @@ packages:
dependency: "direct main"
description:
name: freezed_annotation
sha256: f54946fdb1fa7b01f780841937b1a80783a20b393485f3f6cdf336fd6f4705f2
sha256: f9f6597ac43cc262fa7d7f2e65259a6060c23a560525d1f2631be374540f2a9b
url: "https://pub.dev"
source: hosted
version: "2.4.2"
version: "2.4.3"
frontend_server_client:
dependency: transitive
description:
Expand Down Expand Up @@ -625,18 +650,10 @@ packages:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.7"
js_interop:
dependency: transitive
description:
name: js_interop
sha256: "7ec859c296958ccea34dc770504bd3ff4ae52fdd9e7eeb2bacc7081ad476a1f5"
sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf
url: "https://pub.dev"
source: hosted
version: "0.0.1"
version: "0.7.1"
json_annotation:
dependency: "direct main"
description:
Expand Down Expand Up @@ -785,10 +802,10 @@ packages:
dependency: transitive
description:
name: path_provider_android
sha256: bca87b0165ffd7cdb9cad8edd22d18d2201e886d9a9f19b4fb3452ea7df3a72a
sha256: "30c5aa827a6ae95ce2853cdc5fe3971daaac00f6f081c419c013f7f57bff2f5e"
url: "https://pub.dev"
source: hosted
version: "2.2.6"
version: "2.2.7"
path_provider_foundation:
dependency: transitive
description:
Expand Down Expand Up @@ -817,10 +834,10 @@ packages:
dependency: transitive
description:
name: path_provider_windows
sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170"
sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7
url: "https://pub.dev"
source: hosted
version: "2.2.1"
version: "2.3.0"
petitparser:
dependency: transitive
description:
Expand Down Expand Up @@ -1162,6 +1179,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.5.1"
win32_registry:
dependency: transitive
description:
name: win32_registry
sha256: "10589e0d7f4e053f2c61023a31c9ce01146656a70b7b7f0828c0b46d7da2a9bb"
url: "https://pub.dev"
source: hosted
version: "1.1.3"
workmanager:
dependency: "direct main"
description:
Expand Down
8 changes: 6 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,18 @@ dependencies:
google_fonts: ^6.2.1
url_launcher: ^6.3.0
time_machine: ^0.9.17
flutter_glow:
git:
url: https://github.com/payam-zahedi/flutter-glow.git
dynamic_color: ^1.7.0
path_provider: ^2.1.3
# quick_settings: ^1.0.1
json_annotation: ^4.9.0
flutter_timezone: ^2.0.0
flutter_timezone: ^2.0.1
device_info_plus: ^10.1.0
package_info_plus: ^8.0.0
connectivity_plus: ^6.0.3
freezed_annotation: ^2.4.2
freezed_annotation: ^2.4.3
isar_flutter_libs:
version: ^3.1.7
hosted: https://pub.isar-community.dev/
Expand Down

0 comments on commit dd3339b

Please sign in to comment.