From 87121b3cd46e76c7cfbe438ec5a088d03dc8733b Mon Sep 17 00:00:00 2001 From: Ryotaro Onoue <73390859+YumNumm@users.noreply.github.com> Date: Fri, 31 May 2024 03:37:06 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20=E3=83=9E=E3=83=83=E3=83=97=E9=85=8D?= =?UTF-8?q?=E8=89=B2=E3=81=AE=E5=A4=89=E6=9B=B4=E3=83=BB=E3=83=9E=E3=83=83?= =?UTF-8?q?=E3=83=97=E3=81=AE=E8=89=B2=E3=81=8C=E5=A4=89=E3=82=8F=E3=82=89?= =?UTF-8?q?=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=20(#704)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix --- .../firebase_messaging_interaction.g.dart | 2 +- app/lib/core/provider/map/map_config.dart | 28 +++----- app/lib/core/theme/platform_brightness.dart | 19 +++++ app/lib/core/theme/platform_brightness.g.dart | 29 ++++++++ .../home/features/map/view/main_map_view.dart | 12 ++-- app/lib/feature/home/view/home_view.dart | 69 ++++++++++++------- 6 files changed, 107 insertions(+), 52 deletions(-) create mode 100644 app/lib/core/theme/platform_brightness.dart create mode 100644 app/lib/core/theme/platform_brightness.g.dart diff --git a/app/lib/core/provider/firebase/firebase_messaging_interaction.g.dart b/app/lib/core/provider/firebase/firebase_messaging_interaction.g.dart index b8cc3d80f..26c7f8dba 100644 --- a/app/lib/core/provider/firebase/firebase_messaging_interaction.g.dart +++ b/app/lib/core/provider/firebase/firebase_messaging_interaction.g.dart @@ -9,7 +9,7 @@ part of 'firebase_messaging_interaction.dart'; // ************************************************************************** String _$firebaseMessagingInteractionHash() => - r'991b7b483ec1c1c934d9ae2e67b093ba48746cf1'; + r'e9f5c9192138ef904cba11702ebc8863edf59f7a'; /// See also [firebaseMessagingInteraction]. @ProviderFor(firebaseMessagingInteraction) diff --git a/app/lib/core/provider/map/map_config.dart b/app/lib/core/provider/map/map_config.dart index f2817bbbf..d06984d00 100644 --- a/app/lib/core/provider/map/map_config.dart +++ b/app/lib/core/provider/map/map_config.dart @@ -40,35 +40,23 @@ class MapColorScheme with _$MapColorScheme { factory MapColorScheme.light({required ColorScheme colorScheme}) => MapColorScheme( - backgroundColor: colorScheme.surfaceContainerLowest, - worldLandColor: colorScheme.surface, + backgroundColor: colorScheme.surface, + worldLandColor: colorScheme.surfaceContainerLowest, worldLineColor: colorScheme.onSurfaceVariant, - japanLandColor: colorScheme.surface, + japanLandColor: colorScheme.surfaceContainerLowest, japanLineColor: colorScheme.onSurfaceVariant, ); factory MapColorScheme.dark({required ColorScheme colorScheme}) => - /* MapColorScheme( - backgroundColor: colorScheme.surface, - worldLandColor: Color.lerp( - Colors.blue, - colorScheme.surfaceVariant, - 0.9, - )!, - worldLineColor: colorScheme.onSurfaceVariant, - japanLandColor: Color.lerp( - Colors.blue.shade700, - colorScheme.surface, - 0.75, + backgroundColor: Color.lerp( + colorScheme.surfaceContainerLowest, + Colors.blue.shade900, + 0.1, )!, - japanLineColor: colorScheme.onSurfaceVariant, - );*/ - MapColorScheme( - backgroundColor: colorScheme.surfaceContainerLowest, worldLandColor: colorScheme.surfaceContainerHighest, worldLineColor: colorScheme.onSurfaceVariant, japanLandColor: colorScheme.surfaceContainerHighest, - japanLineColor: colorScheme.onSurfaceVariant, + japanLineColor: colorScheme.onSurface, ); } diff --git a/app/lib/core/theme/platform_brightness.dart b/app/lib/core/theme/platform_brightness.dart new file mode 100644 index 000000000..1608e9d0b --- /dev/null +++ b/app/lib/core/theme/platform_brightness.dart @@ -0,0 +1,19 @@ +import 'package:flutter/foundation.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; + +part 'platform_brightness.g.dart'; + +@riverpod +class PlatformBrightness extends _$PlatformBrightness { + @override + Brightness build() { + PlatformDispatcher.instance.onPlatformBrightnessChanged = () async { + Future.delayed( + const Duration(milliseconds: 250), + ref.invalidateSelf, + ); + }; + + return PlatformDispatcher.instance.platformBrightness; + } +} diff --git a/app/lib/core/theme/platform_brightness.g.dart b/app/lib/core/theme/platform_brightness.g.dart new file mode 100644 index 000000000..895c25f1a --- /dev/null +++ b/app/lib/core/theme/platform_brightness.g.dart @@ -0,0 +1,29 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ignore_for_file: type=lint, duplicate_ignore + +part of 'platform_brightness.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +String _$platformBrightnessHash() => + r'f9865295fbe553321ffa9af63872313cc7c61c1e'; + +/// See also [PlatformBrightness]. +@ProviderFor(PlatformBrightness) +final platformBrightnessProvider = + AutoDisposeNotifierProvider.internal( + PlatformBrightness.new, + name: r'platformBrightnessProvider', + debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') + ? null + : _$platformBrightnessHash, + dependencies: null, + allTransitiveDependencies: null, +); + +typedef _$PlatformBrightness = AutoDisposeNotifier; +// ignore_for_file: type=lint +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, inference_failure_on_uninitialized_variable, inference_failure_on_function_return_type, inference_failure_on_untyped_parameter, deprecated_member_use_from_same_package diff --git a/app/lib/feature/home/features/map/view/main_map_view.dart b/app/lib/feature/home/features/map/view/main_map_view.dart index 6e1209118..5159b5451 100644 --- a/app/lib/feature/home/features/map/view/main_map_view.dart +++ b/app/lib/feature/home/features/map/view/main_map_view.dart @@ -2,13 +2,13 @@ import 'dart:async'; import 'dart:convert'; import 'dart:developer'; -import 'package:eqmonitor/core/provider/app_lifecycle.dart'; import 'package:eqmonitor/core/provider/capture/intensity_icon_render.dart'; import 'package:eqmonitor/core/provider/debugger/debugger_provider.dart'; import 'package:eqmonitor/core/provider/estimated_intensity/provider/estimated_intensity_provider.dart'; import 'package:eqmonitor/core/provider/map/map_style.dart'; import 'package:eqmonitor/core/provider/ntp/ntp_provider.dart'; import 'package:eqmonitor/core/provider/travel_time/provider/travel_time_provider.dart'; +import 'package:eqmonitor/core/theme/platform_brightness.dart'; import 'package:eqmonitor/feature/home/features/map/viewmodel/main_map_viewmodel.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; @@ -21,11 +21,11 @@ class MainMapView extends HookConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { ref.watch(mainMapViewModelProvider); final isDark = useState(Theme.of(context).brightness == Brightness.dark); - ref.listen(appLifeCycleProvider, (_, value) { - if (value == AppLifecycleState.resumed) { - isDark.value = Theme.of(context).brightness == Brightness.dark; - } - }); + ref.listen( + platformBrightnessProvider, + (_, value) => + isDark.value = Theme.of(context).brightness == Brightness.dark, + ); final mapStyle = ref.watch(mapStyleProvider); final stylePath = useState(null); final getStyleJsonFuture = useMemoized( diff --git a/app/lib/feature/home/view/home_view.dart b/app/lib/feature/home/view/home_view.dart index 3e9ca3f0b..275118f90 100644 --- a/app/lib/feature/home/view/home_view.dart +++ b/app/lib/feature/home/view/home_view.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'dart:convert'; import 'dart:math'; +import 'dart:ui'; import 'package:collection/collection.dart'; import 'package:eqapi_types/eqapi_types.dart'; @@ -47,19 +48,30 @@ class HomeView extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { + final theme = Theme.of(context); + final colorScheme = theme.colorScheme; return Scaffold( appBar: PreferredSize( preferredSize: const Size.fromHeight(kToolbarHeight * 0.8), - child: AppBar( - title: Text( - 'EQMonitor', - style: Theme.of(context).textTheme.titleLarge!.copyWith( - fontWeight: FontWeight.bold, + child: ClipRRect( + child: BackdropFilter( + filter: ImageFilter.blur(sigmaX: 4, sigmaY: 4), + child: ColoredBox( + color: colorScheme.primaryContainer.withOpacity(0.1), + child: AppBar( + title: Text( + 'EQMonitor', + style: Theme.of(context).textTheme.titleLarge!.copyWith( + fontWeight: FontWeight.bold, + ), ), + forceMaterialTransparency: true, + ), + ), ), - forceMaterialTransparency: true, ), ), + extendBodyBehindAppBar: true, body: const _HomeBodyWidget(), ); } @@ -245,27 +257,34 @@ class _HomeBodyWidget extends HookConsumerWidget { final child = Stack( children: [ const MainMapView(), - SheetFloatingActionButtons( - controller: sheetController, - fab: const [ - _Fabs(), - ], - ), - // Sheet - const Align( - alignment: Alignment.topRight, - child: IgnorePointer( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - _KmoniScale(), - _IntensityIcons(), - ], - ), + SafeArea( + bottom: false, + child: Stack( + children: [ + SheetFloatingActionButtons( + controller: sheetController, + fab: const [ + _Fabs(), + ], + ), + // Sheet + const Align( + alignment: Alignment.topRight, + child: IgnorePointer( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + _KmoniScale(), + _IntensityIcons(), + ], + ), + ), + ), + _Sheet(sheetController: sheetController), + ], ), ), - _Sheet(sheetController: sheetController), ], ); return child;