Skip to content

Commit

Permalink
Merge pull request #36 from ExpTechTW/master
Browse files Browse the repository at this point in the history
release: v1.1.5
  • Loading branch information
kamiya10 authored Apr 13, 2024
2 parents 1633df4 + a8bcd85 commit 53b8016
Show file tree
Hide file tree
Showing 25 changed files with 370 additions and 331 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"image": "ghcr.io/cirruslabs/flutter:3.19.5"
}
14 changes: 14 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -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: 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']
124 changes: 114 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -7,30 +12,129 @@
.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
*.g.dart

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

/android/app/debug
/android/app/profile
/android/app/release
# 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

# Generated
*.g.dart
# 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
30 changes: 19 additions & 11 deletions lib/core/api.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -10,28 +11,35 @@ class ExpTechApi {
ExpTechApi({this.apikey});

Future<List<PartialEarthquakeReport>> 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-${Random().nextInt(2) + 1}.exptech.com.tw/api/v2/eq/report?limit=$limit'));

if (response.statusCode == 200) {
return (jsonDecode(response.body) as List<dynamic>)
.map((e) => PartialEarthquakeReport.fromJson(e))
.toList();
return (jsonDecode(response.body) as List<dynamic>).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<EarthquakeReport> 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-${Random().nextInt(2) + 1}.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<List<String>> getNotificationTopics(String fcmToken) async {
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<String>.from(jsonDecode(response.body) as List);
} else {
throw Exception('The server returned a status code of ${response.statusCode}');
}
}
}
73 changes: 45 additions & 28 deletions lib/view/earthquake.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,37 @@ class _EarthquakePage extends State<EarthquakePage> 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(),
),
),
],
),
),
),
);
Expand Down Expand Up @@ -183,20 +200,20 @@ class _EarthquakePage extends State<EarthquakePage> 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(),
),
),
],
),
Expand Down
3 changes: 0 additions & 3 deletions lib/view/init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ class _InitPageState extends State<InitPage> {
});
});

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(
Expand Down
Loading

0 comments on commit 53b8016

Please sign in to comment.