From 97f77ca927ddefc63273a1a1b4b60b5123befb90 Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Tue, 9 Apr 2024 20:26:31 +0800 Subject: [PATCH 01/19] Update .gitignore --- .gitignore | 122 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 114 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 6bf5d9d3f..251617513 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,9 @@ +# Do not remove or rename entries in this file, only add new ones +# See https://github.com/flutter/flutter/issues/128635 for more context. + +# Miscellaneous *.class +*.lock *.log *.pyc *.swp @@ -7,30 +12,131 @@ .buildlog/ .history .svn/ -migrate_working_dir/ +# IntelliJ related *.iml *.ipr *.iws .idea/ +# Visual Studio Code related +.classpath +.project +.settings/ +.vscode/* + +# Flutter repo-specific +/bin/cache/ +/bin/internal/bootstrap.bat +/bin/internal/bootstrap.sh +/bin/mingit/ +/dev/benchmarks/mega_gallery/ +/dev/bots/.recipe_deps +/dev/bots/android_tools/ +/dev/devicelab/ABresults*.json +/dev/docs/doc/ +/dev/docs/api_docs.zip +/dev/docs/flutter.docs.zip +/dev/docs/lib/ +/dev/docs/pubspec.yaml +/dev/integration_tests/**/xcuserdata +/dev/integration_tests/**/Pods +/packages/flutter/coverage/ +version +analysis_benchmark.json + +# packages file containing multi-root paths +.packages.generated + +# Flutter/Dart/Pub related **/doc/api/ -**/ios/Flutter/.last_build_id .dart_tool/ .flutter-plugins .flutter-plugins-dependencies +**/generated_plugin_registrant.dart .packages +.pub-preload-cache/ .pub-cache/ .pub/ -/build/ +build/ +flutter_*.png +linked_*.ds +unlinked.ds +unlinked_spec.ds -app.*.symbols +# Android related +**/android/**/gradle-wrapper.jar +.gradle/ +**/android/captures/ +**/android/gradlew +**/android/gradlew.bat +**/android/**/GeneratedPluginRegistrant.java +**/android/key.properties +**/android/local.properties +*.jks -app.*.map.json +# iOS/XCode related +**/ios/**/*.mode1v3 +**/ios/**/*.mode2v3 +**/ios/**/*.moved-aside +**/ios/**/*.pbxuser +**/ios/**/*.perspectivev3 +**/ios/**/*sync/ +**/ios/**/.sconsign.dblite +**/ios/**/.tags* +**/ios/**/.vagrant/ +**/ios/**/DerivedData/ +**/ios/**/Icon? +**/ios/**/Pods/ +**/ios/**/.symlinks/ +**/ios/**/profile +**/ios/**/xcuserdata +**/ios/.generated/ +**/ios/Flutter/.last_build_id +**/ios/Flutter/App.framework +**/ios/Flutter/Flutter.framework +**/ios/Flutter/Flutter.podspec +**/ios/Flutter/Generated.xcconfig +**/ios/Flutter/ephemeral +**/ios/Flutter/app.flx +**/ios/Flutter/app.zip +**/ios/Flutter/flutter_assets/ +**/ios/Flutter/flutter_export_environment.sh +**/ios/ServiceDefinitions.json +**/ios/Runner/GeneratedPluginRegistrant.* + +# macOS +**/Flutter/ephemeral/ +**/Pods/ +**/macos/Flutter/GeneratedPluginRegistrant.swift +**/macos/Flutter/ephemeral +**/xcuserdata/ + +# Windows +**/windows/flutter/generated_plugin_registrant.cc +**/windows/flutter/generated_plugin_registrant.h +**/windows/flutter/generated_plugins.cmake + +# Linux +**/linux/flutter/generated_plugin_registrant.cc +**/linux/flutter/generated_plugin_registrant.h +**/linux/flutter/generated_plugins.cmake +**/linux/flutter/ephemeral + +# Coverage +coverage/ + +# Symbols +app.*.symbols -/android/app/debug -/android/app/profile -/android/app/release +# Exceptions to above rules. +!**/ios/**/default.mode1v3 +!**/ios/**/default.mode2v3 +!**/ios/**/default.pbxuser +!**/ios/**/default.perspectivev3 +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +!/dev/ci/**/Gemfile.lock +!.vscode/settings.json # Generated *.g.dart \ No newline at end of file From 9346ac5fab9fb154adc2d4ef17729a51e1981b99 Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Tue, 9 Apr 2024 20:42:56 +0800 Subject: [PATCH 02/19] chore: untrack ignored files --- .gitignore | 6 ++-- .../.plugin_symlinks/audioplayers_linux | 1 - .../.plugin_symlinks/connectivity_plus | 1 - .../ephemeral/.plugin_symlinks/dynamic_color | 1 - .../.plugin_symlinks/package_info_plus | 1 - .../.plugin_symlinks/path_provider_linux | 1 - .../.plugin_symlinks/shared_preferences_linux | 1 - .../.plugin_symlinks/url_launcher_linux | 1 - linux/flutter/generated_plugin_registrant.cc | 23 ------------- linux/flutter/generated_plugin_registrant.h | 15 --------- linux/flutter/generated_plugins.cmake | 26 --------------- macos/Flutter/GeneratedPluginRegistrant.swift | 32 ------------------- .../ephemeral/Flutter-Generated.xcconfig | 11 ------- .../ephemeral/flutter_export_environment.sh | 12 ------- .../flutter/generated_plugin_registrant.cc | 26 --------------- windows/flutter/generated_plugin_registrant.h | 15 --------- windows/flutter/generated_plugins.cmake | 28 ---------------- 17 files changed, 2 insertions(+), 199 deletions(-) delete mode 120000 linux/flutter/ephemeral/.plugin_symlinks/audioplayers_linux delete mode 120000 linux/flutter/ephemeral/.plugin_symlinks/connectivity_plus delete mode 120000 linux/flutter/ephemeral/.plugin_symlinks/dynamic_color delete mode 120000 linux/flutter/ephemeral/.plugin_symlinks/package_info_plus delete mode 120000 linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux delete mode 120000 linux/flutter/ephemeral/.plugin_symlinks/shared_preferences_linux delete mode 120000 linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux delete mode 100644 linux/flutter/generated_plugin_registrant.cc delete mode 100644 linux/flutter/generated_plugin_registrant.h delete mode 100644 linux/flutter/generated_plugins.cmake delete mode 100644 macos/Flutter/GeneratedPluginRegistrant.swift delete mode 100644 macos/Flutter/ephemeral/Flutter-Generated.xcconfig delete mode 100755 macos/Flutter/ephemeral/flutter_export_environment.sh delete mode 100644 windows/flutter/generated_plugin_registrant.cc delete mode 100644 windows/flutter/generated_plugin_registrant.h delete mode 100644 windows/flutter/generated_plugins.cmake diff --git a/.gitignore b/.gitignore index 251617513..53e3906f5 100644 --- a/.gitignore +++ b/.gitignore @@ -63,6 +63,7 @@ flutter_*.png linked_*.ds unlinked.ds unlinked_spec.ds +*.g.dart # Android related **/android/**/gradle-wrapper.jar @@ -136,7 +137,4 @@ app.*.symbols !**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages !/dev/ci/**/Gemfile.lock -!.vscode/settings.json - -# Generated -*.g.dart \ No newline at end of file +!.vscode/settings.json \ No newline at end of file diff --git a/linux/flutter/ephemeral/.plugin_symlinks/audioplayers_linux b/linux/flutter/ephemeral/.plugin_symlinks/audioplayers_linux deleted file mode 120000 index 9bacf06c2..000000000 --- a/linux/flutter/ephemeral/.plugin_symlinks/audioplayers_linux +++ /dev/null @@ -1 +0,0 @@ -/Users/whes1015/.pub-cache/hosted/pub.dev/audioplayers_linux-3.1.0/ \ No newline at end of file diff --git a/linux/flutter/ephemeral/.plugin_symlinks/connectivity_plus b/linux/flutter/ephemeral/.plugin_symlinks/connectivity_plus deleted file mode 120000 index a567d9772..000000000 --- a/linux/flutter/ephemeral/.plugin_symlinks/connectivity_plus +++ /dev/null @@ -1 +0,0 @@ -/Users/whes1015/.pub-cache/hosted/pub.dev/connectivity_plus-6.0.1/ \ No newline at end of file diff --git a/linux/flutter/ephemeral/.plugin_symlinks/dynamic_color b/linux/flutter/ephemeral/.plugin_symlinks/dynamic_color deleted file mode 120000 index 81b1a8467..000000000 --- a/linux/flutter/ephemeral/.plugin_symlinks/dynamic_color +++ /dev/null @@ -1 +0,0 @@ -/Users/whes1015/.pub-cache/hosted/pub.dev/dynamic_color-1.7.0/ \ No newline at end of file diff --git a/linux/flutter/ephemeral/.plugin_symlinks/package_info_plus b/linux/flutter/ephemeral/.plugin_symlinks/package_info_plus deleted file mode 120000 index ae29ca9b2..000000000 --- a/linux/flutter/ephemeral/.plugin_symlinks/package_info_plus +++ /dev/null @@ -1 +0,0 @@ -/Users/whes1015/.pub-cache/hosted/pub.dev/package_info_plus-6.0.0/ \ No newline at end of file diff --git a/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux b/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux deleted file mode 120000 index ce403e000..000000000 --- a/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux +++ /dev/null @@ -1 +0,0 @@ -/Users/whes1015/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/ \ No newline at end of file diff --git a/linux/flutter/ephemeral/.plugin_symlinks/shared_preferences_linux b/linux/flutter/ephemeral/.plugin_symlinks/shared_preferences_linux deleted file mode 120000 index fb9d13555..000000000 --- a/linux/flutter/ephemeral/.plugin_symlinks/shared_preferences_linux +++ /dev/null @@ -1 +0,0 @@ -/Users/whes1015/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.3.2/ \ No newline at end of file diff --git a/linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux b/linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux deleted file mode 120000 index b0cd949d1..000000000 --- a/linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux +++ /dev/null @@ -1 +0,0 @@ -/Users/whes1015/.pub-cache/hosted/pub.dev/url_launcher_linux-3.1.1/ \ No newline at end of file diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc deleted file mode 100644 index 33ed41342..000000000 --- a/linux/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,23 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - -#include -#include -#include - -void fl_register_plugins(FlPluginRegistry* registry) { - g_autoptr(FlPluginRegistrar) audioplayers_linux_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "AudioplayersLinuxPlugin"); - audioplayers_linux_plugin_register_with_registrar(audioplayers_linux_registrar); - g_autoptr(FlPluginRegistrar) dynamic_color_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "DynamicColorPlugin"); - dynamic_color_plugin_register_with_registrar(dynamic_color_registrar); - g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); - url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); -} diff --git a/linux/flutter/generated_plugin_registrant.h b/linux/flutter/generated_plugin_registrant.h deleted file mode 100644 index e0f0a47bc..000000000 --- a/linux/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void fl_register_plugins(FlPluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake deleted file mode 100644 index eed634131..000000000 --- a/linux/flutter/generated_plugins.cmake +++ /dev/null @@ -1,26 +0,0 @@ -# -# Generated file, do not edit. -# - -list(APPEND FLUTTER_PLUGIN_LIST - audioplayers_linux - dynamic_color - url_launcher_linux -) - -list(APPEND FLUTTER_FFI_PLUGIN_LIST -) - -set(PLUGIN_BUNDLED_LIBRARIES) - -foreach(plugin ${FLUTTER_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) - target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) - list(APPEND PLUGIN_BUNDLED_LIBRARIES $) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) -endforeach(plugin) - -foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) -endforeach(ffi_plugin) diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift deleted file mode 100644 index fd972d6db..000000000 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ /dev/null @@ -1,32 +0,0 @@ -// -// Generated file. Do not edit. -// - -import FlutterMacOS -import Foundation - -import audioplayers_darwin -import connectivity_plus -import dynamic_color -import firebase_core -import firebase_messaging -import flutter_local_notifications -import package_info_plus -import path_provider_foundation -import shared_preferences_foundation -import sqflite -import url_launcher_macos - -func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { - AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin")) - ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin")) - DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin")) - FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) - FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin")) - FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin")) - FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) - PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) - SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) - SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) - UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) -} diff --git a/macos/Flutter/ephemeral/Flutter-Generated.xcconfig b/macos/Flutter/ephemeral/Flutter-Generated.xcconfig deleted file mode 100644 index fe82794bb..000000000 --- a/macos/Flutter/ephemeral/Flutter-Generated.xcconfig +++ /dev/null @@ -1,11 +0,0 @@ -// This is a generated file; do not edit or check into version control. -FLUTTER_ROOT=/Users/whes1015/Documents/flutter -FLUTTER_APPLICATION_PATH=/Users/whes1015/Documents/GitHub/DPIP -COCOAPODS_PARALLEL_CODE_SIGN=true -FLUTTER_BUILD_DIR=build -FLUTTER_BUILD_NAME=1.1.3 -FLUTTER_BUILD_NUMBER=1.1.3 -DART_OBFUSCATION=false -TRACK_WIDGET_CREATION=true -TREE_SHAKE_ICONS=false -PACKAGE_CONFIG=.dart_tool/package_config.json diff --git a/macos/Flutter/ephemeral/flutter_export_environment.sh b/macos/Flutter/ephemeral/flutter_export_environment.sh deleted file mode 100755 index d86d90a9f..000000000 --- a/macos/Flutter/ephemeral/flutter_export_environment.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/Users/whes1015/Documents/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/whes1015/Documents/GitHub/DPIP" -export "COCOAPODS_PARALLEL_CODE_SIGN=true" -export "FLUTTER_BUILD_DIR=build" -export "FLUTTER_BUILD_NAME=1.1.3" -export "FLUTTER_BUILD_NUMBER=1.1.3" -export "DART_OBFUSCATION=false" -export "TRACK_WIDGET_CREATION=true" -export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc deleted file mode 100644 index 4de661cb8..000000000 --- a/windows/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,26 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - -#include -#include -#include -#include -#include - -void RegisterPlugins(flutter::PluginRegistry* registry) { - AudioplayersWindowsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin")); - ConnectivityPlusWindowsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); - DynamicColorPluginCApiRegisterWithRegistrar( - registry->GetRegistrarForPlugin("DynamicColorPluginCApi")); - FirebaseCorePluginCApiRegisterWithRegistrar( - registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); - UrlLauncherWindowsRegisterWithRegistrar( - registry->GetRegistrarForPlugin("UrlLauncherWindows")); -} diff --git a/windows/flutter/generated_plugin_registrant.h b/windows/flutter/generated_plugin_registrant.h deleted file mode 100644 index dc139d85a..000000000 --- a/windows/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void RegisterPlugins(flutter::PluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake deleted file mode 100644 index 7a0d4ecf1..000000000 --- a/windows/flutter/generated_plugins.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# -# Generated file, do not edit. -# - -list(APPEND FLUTTER_PLUGIN_LIST - audioplayers_windows - connectivity_plus - dynamic_color - firebase_core - url_launcher_windows -) - -list(APPEND FLUTTER_FFI_PLUGIN_LIST -) - -set(PLUGIN_BUNDLED_LIBRARIES) - -foreach(plugin ${FLUTTER_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) - target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) - list(APPEND PLUGIN_BUNDLED_LIBRARIES $) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) -endforeach(plugin) - -foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) -endforeach(ffi_plugin) From efb32c967ec21ec076d06c22c84c5534c31487d1 Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Tue, 9 Apr 2024 20:48:36 +0800 Subject: [PATCH 03/19] fix: remove default topic subscription --- lib/view/init.dart | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/view/init.dart b/lib/view/init.dart index 3551bda5f..031352f92 100644 --- a/lib/view/init.dart +++ b/lib/view/init.dart @@ -86,9 +86,6 @@ class _InitPageState extends State { }); }); - await messaging.subscribeToTopic(safeBase64Encode(Global.preference.getString('loc-city') ?? "臺南市")); - await messaging.subscribeToTopic(safeBase64Encode( - "${Global.preference.getString('loc-city') ?? "臺南市"}${Global.preference.getString('loc-town') ?? "歸仁區"}")); /* else { showDialog( From 4e0b5f2d818ae4398a178b6a035b5a1fd676fb7e Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Tue, 9 Apr 2024 20:48:59 +0800 Subject: [PATCH 04/19] chore: remove unused page --- lib/view/loc-set.dart | 81 ------------------------------------------- 1 file changed, 81 deletions(-) delete mode 100644 lib/view/loc-set.dart diff --git a/lib/view/loc-set.dart b/lib/view/loc-set.dart deleted file mode 100644 index 44091348f..000000000 --- a/lib/view/loc-set.dart +++ /dev/null @@ -1,81 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:shared_preferences/shared_preferences.dart'; - -import '../core/utils.dart'; -import '../main.dart'; - -class SettingPage extends StatefulWidget { - const SettingPage({Key? key}) : super(key: key); - - @override - _SettingPage createState() => _SettingPage(); -} - -class _SettingPage extends State { - final List _List_children = [const SizedBox(height: 10)]; - bool init = false; - - void subscribeToTopic(String newTopic, String currentTopic) async { - String encode_newTopic = safeBase64Encode(newTopic); - String encode_currentTopic = safeBase64Encode(currentTopic); - print( - "unsubscribe $currentTopic >> $encode_currentTopic | subscribe $newTopic $encode_newTopic"); - await messaging.unsubscribeFromTopic(encode_currentTopic); - await messaging.subscribeToTopic(encode_newTopic); - } - - @override - Widget build(BuildContext context) { - dynamic data = ModalRoute.of(context)!.settings.arguments; - WidgetsBinding.instance.addPostFrameCallback((_) async { - if (init) return; - init = true; - final SharedPreferences prefs = await SharedPreferences.getInstance(); - for (var i = 0; i < data["data"].length; i++) { - _List_children.add( - Card( - color: const Color(0xff333439), - margin: const EdgeInsets.all(5), - child: ListTile( - onTap: () async { - if (data["storage"] == "loc-city") { - String town = - data["loc_data"][data["data"][i]].keys.toList()[0]; - subscribeToTopic( - data["data"][i], prefs.getString('loc-city') ?? "臺南市"); - subscribeToTopic(data["data"][i] + town, - "${prefs.getString('loc-city') ?? "臺南市"}${prefs.getString('loc-town') ?? "歸仁區"}"); - prefs.setString("loc-town", town); - } else if (data["storage"] == "loc-town") { - subscribeToTopic(data["data"][i] + data["data"][i], - "${prefs.getString('loc-city') ?? "臺南市"}${prefs.getString('loc-town') ?? "歸仁區"}"); - } - prefs.setString(data["storage"], data["data"][i]); - Navigator.pop(context, 'refresh'); - }, - title: Text( - data["data"][i], - style: const TextStyle(fontSize: 22, color: Colors.white), - ), - trailing: const Icon(Icons.arrow_forward, - color: Colors.white, size: 30), - ), - ), - ); - } - if (mounted) setState(() {}); - }); - return Scaffold( - backgroundColor: Colors.black, - body: SafeArea( - child: Padding( - padding: const EdgeInsets.all(10), - child: ListView( - physics: const ClampingScrollPhysics(), - children: _List_children.toList(), - ), - ), - ), - ); - } -} From 6fba39db66cd23425b9f9b87e8a111ebd28b28fd Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Wed, 10 Apr 2024 00:40:36 +0800 Subject: [PATCH 05/19] feat: button to unsubscribe from all topics --- lib/core/api.dart | 26 +++++++++------- lib/view/me.dart | 75 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 11 deletions(-) diff --git a/lib/core/api.dart b/lib/core/api.dart index 56138a956..37a25ca76 100644 --- a/lib/core/api.dart +++ b/lib/core/api.dart @@ -10,28 +10,32 @@ class ExpTechApi { ExpTechApi({this.apikey}); Future> getReportList({int limit = 20}) async { - final response = await http.get( - Uri.parse('https://lb-3.exptech.com.tw/api/v2/eq/report?limit=$limit')); + final response = await http.get(Uri.parse('https://lb-3.exptech.com.tw/api/v2/eq/report?limit=$limit')); if (response.statusCode == 200) { - return (jsonDecode(response.body) as List) - .map((e) => PartialEarthquakeReport.fromJson(e)) - .toList(); + return (jsonDecode(response.body) as List).map((e) => PartialEarthquakeReport.fromJson(e)).toList(); } else { - throw Exception( - 'The server returned a status code of ${response.statusCode}'); + throw Exception('The server returned a status code of ${response.statusCode}'); } } Future getReport(String id) async { - final response = await http - .get(Uri.parse('https://lb-3.exptech.com.tw/api/v2/eq/report/$id')); + final response = await http.get(Uri.parse('https://lb-3.exptech.com.tw/api/v2/eq/report/$id')); if (response.statusCode == 200) { return EarthquakeReport.fromJson(jsonDecode(response.body)); } else { - throw Exception( - 'The server returned a status code of ${response.statusCode}'); + throw Exception('The server returned a status code of ${response.statusCode}'); + } + } + + Future> getNotificationTopics(String fcmToken) async { + final response = await http.get(Uri.parse('https://api-1.exptech.com.tw/dpip/$fcmToken/topics')); + + if (response.statusCode == 200) { + return jsonDecode(response.body) as List; + } else { + throw Exception('The server returned a status code of ${response.statusCode}'); } } } diff --git a/lib/view/me.dart b/lib/view/me.dart index fb01ca5fc..1357f4dd6 100644 --- a/lib/view/me.dart +++ b/lib/view/me.dart @@ -35,6 +35,58 @@ class _MePageState extends State { String currentCity = Global.preference.getString("loc-city") ?? ""; String _theme = Global.preference.getString("theme") ?? "system"; + unsubscribeAllTopics() { + Navigator.pop(context); + + double? progress; + String status = "取得資料中..."; + + showDialog( + barrierDismissible: false, + context: context, + builder: (context) { + return AlertDialog( + content: Row( + children: [ + CircularProgressIndicator(value: progress), + Text(status), + ], + ), + ); + }, + ); + + messaging.getToken().then((fcmToken) { + if (fcmToken == null) { + Navigator.pop(context); + + context.scaffoldMessenger.showSnackBar( + const SnackBar(content: Text("重置 FCM 主題訂閱時發生錯誤:無法取得已訂閱主題列表")), + ); + + return; + } + + Global.api.getNotificationTopics(fcmToken).then((topics) async { + setState(() { + progress = 0; + status = "0/${topics.length} 解除訂閱中..."; + }); + + for (int i = 0; i < topics.length; i++) { + await messaging.unsubscribeFromTopic(topics[i]).catchError((e) { + print(e); + }); + + setState(() { + progress = (i + 1) / topics.length; + status = "${i + 1}/${topics.length} 解除訂閱中..."; + }); + } + }); + }); + } + @override Widget build(BuildContext context) { if (Platform.isIOS) { @@ -546,6 +598,29 @@ class _MePageState extends State { }); }, ), + ListTile( + leading: const Icon(Icons.bug_report_rounded), + title: const Text("重置 FCM 主題訂閱"), + onTap: () { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text("重置 FCM 主題訂閱"), + content: Text("重置主題訂閱後將需要再次設定所在地才能接收到區域通知\n重置可能會需要一點時間"), + actions: [ + TextButton( + onPressed: () { + Navigator.pop(context); + }, + child: const Text("取消")), + FilledButton(onPressed: unsubscribeAllTopics, child: const Text("繼續")) + ], + ); + }, + ); + }, + ), ], ) ], From 787886d23dd4f9f7589611dc8f8f40d69083b860 Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Wed, 10 Apr 2024 06:25:24 +0000 Subject: [PATCH 06/19] fix: api url --- .devcontainer/devcontainer.json | 3 +++ lib/core/api.dart | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..02f0bd366 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,3 @@ +{ + "image": "mobiledevops/flutter-sdk-image:3.16.3" +} \ No newline at end of file diff --git a/lib/core/api.dart b/lib/core/api.dart index 37a25ca76..3fcfd210c 100644 --- a/lib/core/api.dart +++ b/lib/core/api.dart @@ -30,7 +30,7 @@ class ExpTechApi { } Future> getNotificationTopics(String fcmToken) async { - final response = await http.get(Uri.parse('https://api-1.exptech.com.tw/dpip/$fcmToken/topics')); + final response = await http.get(Uri.parse('https://api-2.exptech.com.tw/api/v2/dpip/topic?token=$fcmToken')); if (response.statusCode == 200) { return jsonDecode(response.body) as List; From 9e4c6d76782b1a35072e588d7b223a0717b4e677 Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Wed, 10 Apr 2024 14:31:07 +0800 Subject: [PATCH 07/19] chore: update devcontainer --- .devcontainer/devcontainer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 02f0bd366..9dd6991fa 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,3 +1,3 @@ { - "image": "mobiledevops/flutter-sdk-image:3.16.3" -} \ No newline at end of file + "image": "cirruslabs/docker-images-flutter" +} From 055896260ba1b17ec57e2b9b0df6d2dca31fa8ff Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Wed, 10 Apr 2024 14:35:32 +0800 Subject: [PATCH 08/19] chore: update devcontainer.json --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9dd6991fa..d88602518 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,3 +1,3 @@ { - "image": "cirruslabs/docker-images-flutter" + "image": "cirruslabs/flutter:3.19.5" } From cc40505dd0f16485daffa5d79d983d1d8c54a332 Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Wed, 10 Apr 2024 14:37:35 +0800 Subject: [PATCH 09/19] chore: update devcontainer.json --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d88602518..1876138f7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,3 +1,3 @@ { - "image": "cirruslabs/flutter:3.19.5" + "image": "ghcr.io/cirruslabs/flutter:3.19.5" } From 8f218ff9290d01dfdb586aa58f758e510c17f518 Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:04:12 +0800 Subject: [PATCH 10/19] fix: town topic subscription --- lib/core/api.dart | 2 +- lib/view/me.dart | 73 ++++++++++++++++++++--------------------------- 2 files changed, 32 insertions(+), 43 deletions(-) diff --git a/lib/core/api.dart b/lib/core/api.dart index 3fcfd210c..9a2a14981 100644 --- a/lib/core/api.dart +++ b/lib/core/api.dart @@ -33,7 +33,7 @@ class ExpTechApi { final response = await http.get(Uri.parse('https://api-2.exptech.com.tw/api/v2/dpip/topic?token=$fcmToken')); if (response.statusCode == 200) { - return jsonDecode(response.body) as List; + return List.from(jsonDecode(response.body) as List); } else { throw Exception('The server returned a status code of ${response.statusCode}'); } diff --git a/lib/view/me.dart b/lib/view/me.dart index 1357f4dd6..514f119fc 100644 --- a/lib/view/me.dart +++ b/lib/view/me.dart @@ -36,20 +36,17 @@ class _MePageState extends State { String _theme = Global.preference.getString("theme") ?? "system"; unsubscribeAllTopics() { - Navigator.pop(context); - - double? progress; - String status = "取得資料中..."; - showDialog( barrierDismissible: false, context: context, builder: (context) { - return AlertDialog( + return const AlertDialog( + contentPadding: EdgeInsets.all(24), content: Row( children: [ - CircularProgressIndicator(value: progress), - Text(status), + CircularProgressIndicator(), + SizedBox(width: 24), + Text("解除訂閱中..."), ], ), ); @@ -68,21 +65,31 @@ class _MePageState extends State { } Global.api.getNotificationTopics(fcmToken).then((topics) async { - setState(() { - progress = 0; - status = "0/${topics.length} 解除訂閱中..."; - }); + final topicKeepList = ["DPIP"]; - for (int i = 0; i < topics.length; i++) { - await messaging.unsubscribeFromTopic(topics[i]).catchError((e) { - print(e); - }); - - setState(() { - progress = (i + 1) / topics.length; - status = "${i + 1}/${topics.length} 解除訂閱中..."; - }); + if (Global.preference.getString("loc-city") != null) { + final city = Global.preference.getString("loc-city")!; + topicKeepList.add(safeBase64Encode(city)); + if (Global.preference.getString("loc-town") != null) { + final town = Global.preference.getString("loc-town")!; + topicKeepList.add(safeBase64Encode("$city$town")); + } } + + topics.removeWhere((topic) => topicKeepList.contains(topic)); + + Future.forEach( + topics, + (topic) async => messaging.unsubscribeFromTopic(topic).catchError(print), + ).then((value) { + messaging.subscribeToTopic("DPIP"); + + context.scaffoldMessenger.showSnackBar( + const SnackBar(content: Text("已重置 FCM 主題訂閱")), + ); + + Navigator.of(context).pop(); + }); }); }); } @@ -148,7 +155,7 @@ class _MePageState extends State { messaging.unsubscribeFromTopic(safeBase64Encode("$currentCity$currentTown")); currentTown = value; Global.preference.setString("loc-town", value); - messaging.subscribeToTopic(safeBase64Encode(currentTown)); + messaging.subscribeToTopic(safeBase64Encode("$currentCity$currentTown")); }); } }); @@ -372,7 +379,7 @@ class _MePageState extends State { messaging.unsubscribeFromTopic(safeBase64Encode("$currentCity$currentTown")); currentTown = value; Global.preference.setString("loc-town", value); - messaging.subscribeToTopic(safeBase64Encode(currentTown)); + messaging.subscribeToTopic(safeBase64Encode("$currentCity$currentTown")); } }); Navigator.pop(context); @@ -601,25 +608,7 @@ class _MePageState extends State { ListTile( leading: const Icon(Icons.bug_report_rounded), title: const Text("重置 FCM 主題訂閱"), - onTap: () { - showDialog( - context: context, - builder: (context) { - return AlertDialog( - title: Text("重置 FCM 主題訂閱"), - content: Text("重置主題訂閱後將需要再次設定所在地才能接收到區域通知\n重置可能會需要一點時間"), - actions: [ - TextButton( - onPressed: () { - Navigator.pop(context); - }, - child: const Text("取消")), - FilledButton(onPressed: unsubscribeAllTopics, child: const Text("繼續")) - ], - ); - }, - ); - }, + onTap: unsubscribeAllTopics, ), ], ) From 11e09511b454abeeaf3b46b618aa2b8f48fb88f5 Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:11:23 +0800 Subject: [PATCH 11/19] chore: re-phrase loading dialog --- lib/view/me.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/view/me.dart b/lib/view/me.dart index 514f119fc..36a348228 100644 --- a/lib/view/me.dart +++ b/lib/view/me.dart @@ -46,7 +46,7 @@ class _MePageState extends State { children: [ CircularProgressIndicator(), SizedBox(width: 24), - Text("解除訂閱中..."), + Text("解除通知主題訂閱中..."), ], ), ); From ad1da2328bd342899f87a94d9d64c0b8999fe0b9 Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:19:45 +0800 Subject: [PATCH 12/19] fix: ios specific ui --- lib/view/me.dart | 89 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 67 insertions(+), 22 deletions(-) diff --git a/lib/view/me.dart b/lib/view/me.dart index 36a348228..d36b910a2 100644 --- a/lib/view/me.dart +++ b/lib/view/me.dart @@ -36,30 +36,62 @@ class _MePageState extends State { String _theme = Global.preference.getString("theme") ?? "system"; unsubscribeAllTopics() { - showDialog( - barrierDismissible: false, - context: context, - builder: (context) { - return const AlertDialog( - contentPadding: EdgeInsets.all(24), - content: Row( - children: [ - CircularProgressIndicator(), - SizedBox(width: 24), - Text("解除通知主題訂閱中..."), - ], - ), - ); - }, - ); + if (Platform.isIOS) { + showCupertinoDialog( + barrierDismissible: false, + context: context, + builder: (context) { + return const CupertinoAlertDialog( + content: Row( + children: [ + CupertinoActivityIndicator(), + SizedBox(width: 24), + Text("解除通知主題訂閱中..."), + ], + ), + ); + }, + ); + } else { + showDialog( + barrierDismissible: false, + context: context, + builder: (context) { + return const AlertDialog( + contentPadding: EdgeInsets.all(24), + content: Row( + children: [ + CircularProgressIndicator(), + SizedBox(width: 24), + Text("解除通知主題訂閱中..."), + ], + ), + ); + }, + ); + } messaging.getToken().then((fcmToken) { if (fcmToken == null) { Navigator.pop(context); - context.scaffoldMessenger.showSnackBar( - const SnackBar(content: Text("重置 FCM 主題訂閱時發生錯誤:無法取得已訂閱主題列表")), - ); + if (Platform.isIOS) { + showCupertinoDialog( + barrierDismissible: true, + context: context, + builder: (context) { + return const CupertinoAlertDialog( + title: Text("重置時發生錯誤"), + content: Text("無法取得已訂閱主題列表"), + actions: [CupertinoDialogAction(child: Text("確定"))], + ); + }, + ); + } else { + context.scaffoldMessenger.showSnackBar( + const SnackBar(content: Text("重置 FCM 主題訂閱時發生錯誤:無法取得已訂閱主題列表")), + ); + } return; } @@ -84,9 +116,22 @@ class _MePageState extends State { ).then((value) { messaging.subscribeToTopic("DPIP"); - context.scaffoldMessenger.showSnackBar( - const SnackBar(content: Text("已重置 FCM 主題訂閱")), - ); + if (Platform.isIOS) { + showCupertinoDialog( + barrierDismissible: true, + context: context, + builder: (context) { + return const CupertinoAlertDialog( + content: Text("已重置 FCM 主題訂閱"), + actions: [CupertinoDialogAction(child: Text("確定"))], + ); + }, + ); + } else { + context.scaffoldMessenger.showSnackBar( + const SnackBar(content: Text("已重置 FCM 主題訂閱")), + ); + } Navigator.of(context).pop(); }); From 45be2c78969526d0ac8450711939c0a88db45ccb Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Wed, 10 Apr 2024 18:22:24 +0800 Subject: [PATCH 13/19] fix: ios ui again --- lib/view/earthquake.dart | 74 ++++++++------ lib/view/me.dart | 211 +++++++++++++++++++++++++-------------- 2 files changed, 183 insertions(+), 102 deletions(-) diff --git a/lib/view/earthquake.dart b/lib/view/earthquake.dart index 31813b1bd..71dcab629 100644 --- a/lib/view/earthquake.dart +++ b/lib/view/earthquake.dart @@ -6,6 +6,7 @@ import 'package:dpip/util/extension.dart'; import 'package:dpip/view/about_rts.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:http/http.dart' as http; import '../core/utils.dart'; @@ -135,20 +136,37 @@ class _EarthquakePage extends State with AutomaticKeepAliveClien }, ), ), - child: Padding( - padding: const EdgeInsets.all(4), - child: Column( - mainAxisSize: MainAxisSize.max, - children: [ - const Text( - "即時資料僅供參考\n實際請以中央氣象署的資料為主", - textAlign: TextAlign.center, - ), - Flexible( - flex: 1, - child: Center(child: stack), - ), - ], + child: SafeArea( + child: Padding( + padding: const EdgeInsets.all(4), + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + const Padding( + padding: EdgeInsets.all(8.0), + child: Text( + "即時資料僅供參考\n實際請以中央氣象署的資料為主", + textAlign: TextAlign.center, + style: TextStyle(fontSize: 14), + ), + ), + Flexible( + flex: 1, + fit: FlexFit.tight, + child: stack != null + ? ClipRRect( + child: InteractiveViewer( + clipBehavior: Clip.none, + maxScale: 10, + child: stack!, + ), + ) + : const Center( + child: CupertinoActivityIndicator(), + ), + ), + ], + ), ), ), ); @@ -183,20 +201,20 @@ class _EarthquakePage extends State with AutomaticKeepAliveClien "即時資料僅供參考\n實際請以中央氣象署的資料為主", textAlign: TextAlign.center, ), - Expanded( - child: Center( - child: stack != null - ? ClipRRect( - child: InteractiveViewer( - clipBehavior: Clip.none, - maxScale: 10, - child: stack!, - ), - ) - : Platform.isIOS - ? const CupertinoActivityIndicator() - : const CircularProgressIndicator(), - ), + Flexible( + flex: 1, + fit: FlexFit.tight, + child: stack != null + ? ClipRRect( + child: InteractiveViewer( + clipBehavior: Clip.none, + maxScale: 10, + child: stack!, + ), + ) + : const Center( + child: CircularProgressIndicator(), + ), ), ], ), diff --git a/lib/view/me.dart b/lib/view/me.dart index d36b910a2..d7a5c786b 100644 --- a/lib/view/me.dart +++ b/lib/view/me.dart @@ -35,44 +35,48 @@ class _MePageState extends State { String currentCity = Global.preference.getString("loc-city") ?? ""; String _theme = Global.preference.getString("theme") ?? "system"; - unsubscribeAllTopics() { - if (Platform.isIOS) { - showCupertinoDialog( - barrierDismissible: false, - context: context, - builder: (context) { - return const CupertinoAlertDialog( - content: Row( - children: [ - CupertinoActivityIndicator(), - SizedBox(width: 24), - Text("解除通知主題訂閱中..."), - ], - ), - ); - }, - ); - } else { - showDialog( - barrierDismissible: false, - context: context, - builder: (context) { - return const AlertDialog( - contentPadding: EdgeInsets.all(24), - content: Row( - children: [ - CircularProgressIndicator(), - SizedBox(width: 24), - Text("解除通知主題訂閱中..."), - ], - ), - ); - }, - ); - } + Future unsubscribeAllTopics() async { + try { + if (Platform.isIOS) { + showCupertinoDialog( + barrierDismissible: false, + context: context, + builder: (context) { + return const CupertinoAlertDialog( + content: Row( + children: [ + CupertinoActivityIndicator(), + SizedBox(width: 24), + Text("解除通知主題訂閱中..."), + ], + ), + ); + }, + ); + } else { + showDialog( + barrierDismissible: false, + context: context, + builder: (context) { + return const AlertDialog( + contentPadding: EdgeInsets.all(24), + content: Row( + children: [ + CircularProgressIndicator(), + SizedBox(width: 24), + Text("解除通知主題訂閱中..."), + ], + ), + ); + }, + ); + } + + final fcmToken = await messaging.getToken(); - messaging.getToken().then((fcmToken) { if (fcmToken == null) { + if (!mounted) return; + Navigator.pop(context); if (Platform.isIOS) { @@ -80,10 +84,21 @@ class _MePageState extends State { barrierDismissible: true, context: context, builder: (context) { - return const CupertinoAlertDialog( - title: Text("重置時發生錯誤"), - content: Text("無法取得已訂閱主題列表"), - actions: [CupertinoDialogAction(child: Text("確定"))], + return CupertinoAlertDialog( + title: const Text("重置時發生錯誤"), + content: const Text( + "無法取得已訂閱主題列表", + style: TextStyle(fontSize: 16), + ), + actions: [ + CupertinoDialogAction( + isDefaultAction: true, + child: const Text("確定"), + onPressed: () { + Navigator.pop(context); + }, + ) + ], ); }, ); @@ -96,47 +111,91 @@ class _MePageState extends State { return; } - Global.api.getNotificationTopics(fcmToken).then((topics) async { - final topicKeepList = ["DPIP"]; + final topics = await Global.api.getNotificationTopics(fcmToken); + final topicKeepList = ["DPIP"]; - if (Global.preference.getString("loc-city") != null) { - final city = Global.preference.getString("loc-city")!; - topicKeepList.add(safeBase64Encode(city)); - if (Global.preference.getString("loc-town") != null) { - final town = Global.preference.getString("loc-town")!; - topicKeepList.add(safeBase64Encode("$city$town")); - } + if (Global.preference.getString("loc-city") != null) { + final city = Global.preference.getString("loc-city")!; + topicKeepList.add(safeBase64Encode(city)); + if (Global.preference.getString("loc-town") != null) { + final town = Global.preference.getString("loc-town")!; + topicKeepList.add(safeBase64Encode("$city$town")); } + } - topics.removeWhere((topic) => topicKeepList.contains(topic)); + topics.removeWhere((topic) => topicKeepList.contains(topic)); - Future.forEach( - topics, - (topic) async => messaging.unsubscribeFromTopic(topic).catchError(print), - ).then((value) { - messaging.subscribeToTopic("DPIP"); + Future.forEach( + topics, + (topic) => messaging.unsubscribeFromTopic(topic).catchError(print), + ).then((value) { + messaging.subscribeToTopic("DPIP"); - if (Platform.isIOS) { - showCupertinoDialog( - barrierDismissible: true, - context: context, - builder: (context) { - return const CupertinoAlertDialog( - content: Text("已重置 FCM 主題訂閱"), - actions: [CupertinoDialogAction(child: Text("確定"))], - ); - }, - ); - } else { - context.scaffoldMessenger.showSnackBar( - const SnackBar(content: Text("已重置 FCM 主題訂閱")), - ); - } + Navigator.of(context).pop(); - Navigator.of(context).pop(); - }); + if (Platform.isIOS) { + showCupertinoDialog( + barrierDismissible: true, + context: context, + builder: (context) { + return CupertinoAlertDialog( + content: const Text( + "已重置 FCM 主題訂閱", + style: TextStyle(fontSize: 16), + ), + actions: [ + CupertinoDialogAction( + isDefaultAction: true, + child: const Text("確定"), + onPressed: () { + Navigator.pop(context); + }, + ) + ], + ); + }, + ); + } else { + context.scaffoldMessenger.showSnackBar( + const SnackBar(content: Text("已重置 FCM 主題訂閱")), + ); + } }); - }); + } catch (e) { + if (!mounted) return; + Navigator.pop(context); + + if (Platform.isIOS) { + showCupertinoDialog( + barrierDismissible: true, + context: context, + builder: (context) { + return CupertinoAlertDialog( + title: const Text("重置時發生錯誤"), + content: Text( + e.toString(), + style: const TextStyle(fontSize: 16), + ), + actions: [ + CupertinoDialogAction( + isDefaultAction: true, + child: const Text("確定"), + onPressed: () { + Navigator.pop(context); + }, + ) + ], + ); + }, + ); + } else { + context.scaffoldMessenger.showSnackBar( + SnackBar( + content: Text("重置 FCM 主題訂閱時發生錯誤:${e.toString()}"), + ), + ); + } + } } @override @@ -328,6 +387,10 @@ class _MePageState extends State { }); }, ), + CupertinoListTile( + title: const Text("重置 FCM 主題訂閱"), + onTap: unsubscribeAllTopics, + ), ], ), ], From 48045fcd7f2f47f3e958299f3bab9b4929ec4c81 Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Wed, 10 Apr 2024 18:23:05 +0800 Subject: [PATCH 14/19] chore: remove import --- lib/view/earthquake.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/view/earthquake.dart b/lib/view/earthquake.dart index 71dcab629..c85df1eac 100644 --- a/lib/view/earthquake.dart +++ b/lib/view/earthquake.dart @@ -6,7 +6,6 @@ import 'package:dpip/util/extension.dart'; import 'package:dpip/view/about_rts.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'package:http/http.dart' as http; import '../core/utils.dart'; From ed403b0b3477ac471da65f9ead92358003364ccc Mon Sep 17 00:00:00 2001 From: YuYu1015 <44525760+whes1015@users.noreply.github.com> Date: Wed, 10 Apr 2024 19:29:00 +0800 Subject: [PATCH 15/19] Create FUNDING.yml --- .github/FUNDING.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..c4c8847ca --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,14 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: https://ko-fi.com/exptech # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +polar: # Replace with a single Polar username +buy_me_a_coffee: # Replace with a single Buy Me a Coffee username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] From d8841acbcbf37738f95882ac9d52374fbe1817d8 Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Wed, 10 Apr 2024 19:30:06 +0800 Subject: [PATCH 16/19] fix: api url --- lib/core/api.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/api.dart b/lib/core/api.dart index 9a2a14981..820136d19 100644 --- a/lib/core/api.dart +++ b/lib/core/api.dart @@ -10,7 +10,7 @@ class ExpTechApi { ExpTechApi({this.apikey}); Future> getReportList({int limit = 20}) async { - final response = await http.get(Uri.parse('https://lb-3.exptech.com.tw/api/v2/eq/report?limit=$limit')); + final response = await http.get(Uri.parse('https://api-2.exptech.com.tw/api/v2/eq/report?limit=$limit')); if (response.statusCode == 200) { return (jsonDecode(response.body) as List).map((e) => PartialEarthquakeReport.fromJson(e)).toList(); @@ -20,7 +20,7 @@ class ExpTechApi { } Future getReport(String id) async { - final response = await http.get(Uri.parse('https://lb-3.exptech.com.tw/api/v2/eq/report/$id')); + final response = await http.get(Uri.parse('https://api-2.exptech.com.tw/api/v2/eq/report/$id')); if (response.statusCode == 200) { return EarthquakeReport.fromJson(jsonDecode(response.body)); From 8d9d829e5cc1b1877013a1c01a984fec22be4cf0 Mon Sep 17 00:00:00 2001 From: YuYu1015 <44525760+whes1015@users.noreply.github.com> Date: Wed, 10 Apr 2024 19:32:45 +0800 Subject: [PATCH 17/19] Update FUNDING.yml --- .github/FUNDING.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index c4c8847ca..518f2aa18 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -3,7 +3,7 @@ github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username -ko_fi: https://ko-fi.com/exptech # Replace with a single Ko-fi username +ko_fi: exptech # Replace with a single Ko-fi username tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username From 25b0b5d3bafc459b56e3d7b1d90c0224075c770d Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Wed, 10 Apr 2024 22:11:57 +0800 Subject: [PATCH 18/19] fix: use random url --- lib/core/api.dart | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/core/api.dart b/lib/core/api.dart index 820136d19..6c0ea03ab 100644 --- a/lib/core/api.dart +++ b/lib/core/api.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:math'; import 'package:dpip/model/earthquake_report.dart'; import 'package:dpip/model/partial_earthquake_report.dart'; @@ -10,7 +11,8 @@ class ExpTechApi { ExpTechApi({this.apikey}); Future> getReportList({int limit = 20}) async { - final response = await http.get(Uri.parse('https://api-2.exptech.com.tw/api/v2/eq/report?limit=$limit')); + final response = await http + .get(Uri.parse('https://api-${Random().nextInt(2) + 1}.exptech.com.tw/api/v2/eq/report?limit=$limit')); if (response.statusCode == 200) { return (jsonDecode(response.body) as List).map((e) => PartialEarthquakeReport.fromJson(e)).toList(); @@ -20,7 +22,8 @@ class ExpTechApi { } Future getReport(String id) async { - final response = await http.get(Uri.parse('https://api-2.exptech.com.tw/api/v2/eq/report/$id')); + final response = + await http.get(Uri.parse('https://api-${Random().nextInt(2) + 1}.exptech.com.tw/api/v2/eq/report/$id')); if (response.statusCode == 200) { return EarthquakeReport.fromJson(jsonDecode(response.body)); @@ -30,7 +33,8 @@ class ExpTechApi { } Future> getNotificationTopics(String fcmToken) async { - final response = await http.get(Uri.parse('https://api-2.exptech.com.tw/api/v2/dpip/topic?token=$fcmToken')); + final response = await http + .get(Uri.parse('https://api-${Random().nextInt(2) + 1}.exptech.com.tw/api/v2/dpip/topic?token=$fcmToken')); if (response.statusCode == 200) { return List.from(jsonDecode(response.body) as List); From 06fa9d17cb4818a166d666e472bfaf6fb4058739 Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Wed, 10 Apr 2024 22:28:59 +0800 Subject: [PATCH 19/19] bump: v1.1.5 --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 5375d65f4..cc8013e9c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: dpip description: Disaster Prevention Information Platform publish_to: "none" -version: 1.1.4 +version: 1.1.5 environment: sdk: ">=3.2.0 <4.0.0"