Skip to content

Commit

Permalink
REST APIのURL切り替え (#474)
Browse files Browse the repository at this point in the history
* add
  • Loading branch information
YumNumm authored Dec 26, 2023
1 parent cc033e5 commit f8d0efb
Show file tree
Hide file tree
Showing 32 changed files with 573 additions and 477 deletions.

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

Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@ part 'crashlytics_setting_provider.g.dart';
class CrashlyticsSetting extends _$CrashlyticsSetting {
@override
CrashlyticsSettingModel build() {
_prefs = ref.watch(sharedPreferencesProvider);
ref.listenSelf((_, next) => _save());
return const CrashlyticsSettingModel();
}

late final SharedPreferences _prefs;

static const String _key = 'crashlytics_setting';

Future<void> _save() async {
await _prefs.setString(_key, jsonEncode(state.toJson()));
}
Future<void> _save() async => ref
.read(sharedPreferencesProvider)
.setString(_key, jsonEncode(state.toJson()));

void setEnabled({required bool isEnabled}) {
state = state.copyWith(isEnabled: isEnabled);
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,29 @@ import 'dart:convert';
import 'package:eqmonitor/core/provider/config/theme/intensity_color/model/intensity_color_model.dart';
import 'package:eqmonitor/core/provider/shared_preferences.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:shared_preferences/shared_preferences.dart';

part 'intensity_color_provider.g.dart';

@Riverpod(keepAlive: true)
class IntensityColor extends _$IntensityColor {
@override
IntensityColorModel build() {
_prefs = ref.watch(sharedPreferencesProvider);
final result = load();
if (result != null) {
return result;
}
return IntensityColorModel.eqmonitor();
}

static const _key = 'intensity_color';
late final SharedPreferences _prefs;

// ignore: use_setters_to_change_properties
void update(IntensityColorModel model) {
state = model;
}



IntensityColorModel? load() {
final value = _prefs.getString(_key);
final value = ref.read(sharedPreferencesProvider).getString(_key);
if (value == null) {
return null;
}
Expand Down

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

2 changes: 1 addition & 1 deletion lib/core/provider/dio_provider.g.dart

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

44 changes: 36 additions & 8 deletions lib/core/router/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import 'package:eqmonitor/feature/settings/children/application_info/license_pag
import 'package:eqmonitor/feature/settings/children/application_info/privacy_policy_screen.dart';
import 'package:eqmonitor/feature/settings/children/application_info/term_of_service_screen.dart';
import 'package:eqmonitor/feature/settings/children/config/color_scheme/color_scheme_config_page.dart';
import 'package:eqmonitor/feature/settings/children/config/debug/api_endpoint_selector/api_endpoint_selector_page.dart';
import 'package:eqmonitor/feature/settings/children/config/debug/debugger_page.dart';
import 'package:eqmonitor/feature/settings/children/config/notification/children/earthquake/earthquake_notification_settings_page.dart';
import 'package:eqmonitor/feature/settings/children/config/notification/children/eew/eew_notification_settings_page.dart';
import 'package:eqmonitor/feature/settings/children/config/notification/notification_setting_page.dart';
Expand Down Expand Up @@ -80,14 +82,6 @@ class EewDetailedHistoryRoute extends GoRouteData {
);
}

@TypedGoRoute<ColorSchemeConfigRoute>(path: '/config')
class ColorSchemeConfigRoute extends GoRouteData {
const ColorSchemeConfigRoute();
@override
Widget build(BuildContext context, GoRouterState state) =>
const ColorSchemeConfigPage();
}

@TypedGoRoute<HomeRoute>(path: '/')
class HomeRoute extends GoRouteData {
const HomeRoute();
Expand Down Expand Up @@ -123,6 +117,9 @@ class KmoniRoute extends GoRouteData {
TypedGoRoute<LicenseRoute>(
path: 'license',
),
TypedGoRoute<ColorSchemeConfigRoute>(
path: 'color-schema',
),
TypedGoRoute<NotificationSettingsRoute>(
path: 'notification',
routes: [
Expand All @@ -134,6 +131,14 @@ class KmoniRoute extends GoRouteData {
),
],
),
TypedGoRoute<DebuggerRoute>(
path: 'debugger',
routes: [
TypedGoRoute<ApiEndpointSelectorRoute>(
path: 'api-endpoint-selector',
),
],
),
],
)
class SettingsRoute extends GoRouteData {
Expand All @@ -144,6 +149,22 @@ class SettingsRoute extends GoRouteData {
const SettingsScreen();
}

class DebuggerRoute extends GoRouteData {
const DebuggerRoute();

@override
Widget build(BuildContext context, GoRouterState state) =>
const DebuggerPage();
}

class ApiEndpointSelectorRoute extends GoRouteData {
const ApiEndpointSelectorRoute();

@override
Widget build(BuildContext context, GoRouterState state) =>
const ApiEndpointSelectorPage();
}

class TermOfServiceRoute extends GoRouteData {
const TermOfServiceRoute({
required this.$extra,
Expand All @@ -160,6 +181,13 @@ class TermOfServiceRoute extends GoRouteData {
);
}

class ColorSchemeConfigRoute extends GoRouteData {
const ColorSchemeConfigRoute();
@override
Widget build(BuildContext context, GoRouterState state) =>
const ColorSchemeConfigPage();
}

class PrivacyPolicyRoute extends GoRouteData {
const PrivacyPolicyRoute({
required this.$extra,
Expand Down
91 changes: 67 additions & 24 deletions lib/core/router/router.g.dart

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

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:collection/collection.dart';
import 'package:eqapi_types/eqapi_types.dart';
import 'package:eqmonitor/core/component/chip/custom_chip.dart';
import 'package:eqmonitor/core/component/intenisty/intensity_icon_type.dart';
Expand Down Expand Up @@ -41,6 +42,11 @@ class EarthquakeHistoryTileWidget extends ConsumerWidget {
) &&
item.telegrams.every((e) => e.type == TelegramType.vxse52);

// 通常報以外かどうか
final telegramStatuses = item.telegrams.map((e) => e.status).toSet();
final isNotNormal = telegramStatuses.contains(TelegramStatus.test) ||
telegramStatuses.contains(TelegramStatus.training);

// ! title
final title = StringBuffer();
if (item.earthquake.earthquake != null) {
Expand Down Expand Up @@ -125,6 +131,19 @@ class EarthquakeHistoryTileWidget extends ConsumerWidget {
fontFamilyFallback: [FontFamily.notoSansJP],
),
),
if (!const SetEquality<TelegramStatus>()
.equals(telegramStatuses, {TelegramStatus.normal}))
for (final status in telegramStatuses)
CustomChip(
backgroundColor: Colors.red.shade200,
child: Text(
'${status.type}報',
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
if (item.tsunami?.forecasts != null ||
item.tsunami?.observations != null ||
item.tsunami?.estimations != null)
Expand Down
Loading

0 comments on commit f8d0efb

Please sign in to comment.