Skip to content

Commit

Permalink
[FIX] マップ配色の変更・マップの色が変わらない問題を修正 (#704)
Browse files Browse the repository at this point in the history
* fix
  • Loading branch information
YumNumm authored May 30, 2024
1 parent a553519 commit 87121b3
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 52 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 8 additions & 20 deletions app/lib/core/provider/map/map_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
19 changes: 19 additions & 0 deletions app/lib/core/theme/platform_brightness.dart
Original file line number Diff line number Diff line change
@@ -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<void>.delayed(
const Duration(milliseconds: 250),
ref.invalidateSelf,
);
};

return PlatformDispatcher.instance.platformBrightness;
}
}
29 changes: 29 additions & 0 deletions app/lib/core/theme/platform_brightness.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions app/lib/feature/home/features/map/view/main_map_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<String?>(null);
final getStyleJsonFuture = useMemoized(
Expand Down
69 changes: 44 additions & 25 deletions app/lib/feature/home/view/home_view.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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(),
);
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 87121b3

Please sign in to comment.