diff --git a/.gitignore b/.gitignore index 0282a1e0c..65d41b92f 100644 --- a/.gitignore +++ b/.gitignore @@ -132,7 +132,6 @@ app.*.symbols # Web related -lib/generated_plugin_registrant.dart # Obfuscation related app.*.map.json @@ -172,4 +171,4 @@ ios/*.p8 *.pem -*_old \ No newline at end of file +*_old diff --git a/.metadata b/.metadata index 982739bb0..bcd1a6008 100644 --- a/.metadata +++ b/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled and should not be manually edited. version: - revision: "9e1c857886f07d342cf106f2cd588bcd5e031bb2" + revision: "78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9" channel: "stable" project_type: app @@ -13,11 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: 9e1c857886f07d342cf106f2cd588bcd5e031bb2 - base_revision: 9e1c857886f07d342cf106f2cd588bcd5e031bb2 - - platform: ios - create_revision: 9e1c857886f07d342cf106f2cd588bcd5e031bb2 - base_revision: 9e1c857886f07d342cf106f2cd588bcd5e031bb2 + create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 + base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 + - platform: web + create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 + base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 # User provided section diff --git a/lib/core/provider/app_information/app_information_model.dart b/lib/core/provider/app_information/app_information_model.dart index 4fa9d859a..d2bfc302b 100644 --- a/lib/core/provider/app_information/app_information_model.dart +++ b/lib/core/provider/app_information/app_information_model.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:eqapi_types/eqapi_types.dart'; +import 'package:flutter/foundation.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:version/version.dart'; @@ -42,7 +43,7 @@ extension AppInformationEx on AppInformation { AppInformationModel toModel({ required Version currentVersion, }) { - if (Platform.isIOS) { + if (!kIsWeb && Platform.isIOS) { final latestVersion = Version.parse(iosLatestVersion); final minimumVersion = iosMinimumVersion == null ? null : Version.parse(iosMinimumVersion!); @@ -57,7 +58,7 @@ extension AppInformationEx on AppInformation { latestVersion > currentVersion, ); } - if (Platform.isAndroid) { + if (!kIsWeb && Platform.isAndroid) { final latestVersion = Version.parse(androidLatestVersion); final minimumVersion = androidMinimumVersion == null ? null diff --git a/lib/core/provider/dio_provider.dart b/lib/core/provider/dio_provider.dart index 56ea9fbcf..c94dea8fc 100644 --- a/lib/core/provider/dio_provider.dart +++ b/lib/core/provider/dio_provider.dart @@ -15,8 +15,9 @@ Dio dio(DioRef ref) { final dio = Dio( BaseOptions( headers: { - 'user-agent': 'eqmonitor-${Platform.version}', - 'x-operation-system-version': Platform.operatingSystemVersion, + 'user-agent': 'eqmonitor-${kIsWeb ? "web" : Platform.version}', + 'x-operation-system-version': + kIsWeb ? 'web' : Platform.operatingSystemVersion, if (authorization != null) 'authorization': authorization, }, baseUrl: ref.watch(telegramUrlProvider).restApiUrl, diff --git a/lib/feature/earthquake_history/viewmodel/earthquake_history_view_model.dart b/lib/feature/earthquake_history/viewmodel/earthquake_history_view_model.dart index ee66742fa..943987f2b 100644 --- a/lib/feature/earthquake_history/viewmodel/earthquake_history_view_model.dart +++ b/lib/feature/earthquake_history/viewmodel/earthquake_history_view_model.dart @@ -24,7 +24,6 @@ part 'earthquake_history_view_model.g.dart'; class EarthquakeHistoryViewModel extends _$EarthquakeHistoryViewModel { @override AsyncValue> build() { - _useCase = ref.watch(earthquakeHistoryUseCaseProvider); // start listen telegram ws ref ..listen(telegramWsProvider, (previous, next) { @@ -42,7 +41,6 @@ class EarthquakeHistoryViewModel extends _$EarthquakeHistoryViewModel { return const AsyncData([]); } - late EarthquakeHistoryUseCase _useCase; // state final bool _includeTestTelegrams = false; @@ -80,7 +78,8 @@ class EarthquakeHistoryViewModel extends _$EarthquakeHistoryViewModel { // 処理開始 state = await state.guardPlus(() async { final offset = isRefresh ? 0 : state.asData?.value.length ?? 0; - final result = await _useCase.getEarthquakeHistory( + final useCase = ref.read(earthquakeHistoryUseCaseProvider); + final result = await useCase.getEarthquakeHistory( limit: limit, offset: offset, includeEew: true, diff --git a/lib/feature/settings/settings_screen.dart b/lib/feature/settings/settings_screen.dart index f242094f4..21876e367 100644 --- a/lib/feature/settings/settings_screen.dart +++ b/lib/feature/settings/settings_screen.dart @@ -12,6 +12,7 @@ import 'package:eqmonitor/feature/home/component/sheet/debug_widget.dart'; import 'package:eqmonitor/feature/home/features/debugger/debugger_provider.dart'; import 'package:eqmonitor/feature/settings/component/settings_section_header.dart'; import 'package:eqmonitor/gen/assets.gen.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:go_router/go_router.dart'; @@ -186,9 +187,11 @@ Future _onInquiryTap(BuildContext context, WidgetRef ref) async { ), ); final packageInfo = ref.read(packageInfoProvider); - final androidDeviceInfo = - Platform.isAndroid ? ref.read(androidDeviceInfoProvider) : null; - final iosDeviceInfo = Platform.isIOS ? ref.read(iosDeviceInfoProvider) : null; + final androidDeviceInfo = !kIsWeb && Platform.isAndroid + ? ref.read(androidDeviceInfoProvider) + : null; + final iosDeviceInfo = + !kIsWeb && Platform.isIOS ? ref.read(iosDeviceInfoProvider) : null; final notificationSetting = await ref.read(firebaseMessagingProvider).getNotificationSettings(); diff --git a/lib/main.dart b/lib/main.dart index a51fad6f1..b600ebf4a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -48,9 +48,11 @@ Future main() async { ), PackageInfo.fromPlatform(), // ignore: prefer_void_to_null - (Platform.isAndroid ? deviceInfo.androidInfo : Future.value()), + (!kIsWeb && Platform.isAndroid + ? deviceInfo.androidInfo + : Future.value()), // ignore: prefer_void_to_null - (Platform.isIOS ? deviceInfo.iosInfo : Future.value()), + (!kIsWeb && Platform.isIOS ? deviceInfo.iosInfo : Future.value()), FlutterLocalNotificationsPlugin().initialize( const InitializationSettings( iOS: DarwinInitializationSettings( diff --git a/web/favicon.png b/web/favicon.png new file mode 100644 index 000000000..8aaa46ac1 Binary files /dev/null and b/web/favicon.png differ diff --git a/web/icons/Icon-192.png b/web/icons/Icon-192.png new file mode 100644 index 000000000..b749bfef0 Binary files /dev/null and b/web/icons/Icon-192.png differ diff --git a/web/icons/Icon-512.png b/web/icons/Icon-512.png new file mode 100644 index 000000000..88cfd48df Binary files /dev/null and b/web/icons/Icon-512.png differ diff --git a/web/icons/Icon-maskable-192.png b/web/icons/Icon-maskable-192.png new file mode 100644 index 000000000..eb9b4d76e Binary files /dev/null and b/web/icons/Icon-maskable-192.png differ diff --git a/web/icons/Icon-maskable-512.png b/web/icons/Icon-maskable-512.png new file mode 100644 index 000000000..d69c56691 Binary files /dev/null and b/web/icons/Icon-maskable-512.png differ diff --git a/web/index.html b/web/index.html new file mode 100644 index 000000000..b41001546 --- /dev/null +++ b/web/index.html @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + eqmonitor + + + + + + + + + + diff --git a/web/manifest.json b/web/manifest.json new file mode 100644 index 000000000..d5e5b6c61 --- /dev/null +++ b/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "eqmonitor", + "short_name": "eqmonitor", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +}