Skip to content

Commit

Permalink
[FEATURE] Deep Linkの実装・通知タップ時の画面遷移実装 (#712)
Browse files Browse the repository at this point in the history
* add
  • Loading branch information
YumNumm authored May 31, 2024
1 parent 1bfdd1a commit bdd26b1
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 92 deletions.
28 changes: 8 additions & 20 deletions app/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,9 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Distribution: Ryotaro Onoue (CPL7H8SHVM)";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1169;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = CPL7H8SHVM;
DEVELOPMENT_TEAM = CPL7H8SHVM;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = EQMonitor;
Expand All @@ -601,7 +599,6 @@
PRODUCT_BUNDLE_IDENTIFIER = net.yumnumm.eqmonitor;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match AppStore net.yumnumm.eqmonitor";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -621,11 +618,9 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = FcmServiceExtension/FcmServiceExtension.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development: Ryotaro Onoue (7PWJ49VWRZ)";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1169;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = CPL7H8SHVM;
DEVELOPMENT_TEAM = CPL7H8SHVM;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -645,7 +640,6 @@
PRODUCT_BUNDLE_IDENTIFIER = net.yumnumm.eqmonitor.FcmServiceExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match Development net.yumnumm.eqmonitor.FcmServiceExtension";
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -861,11 +855,9 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development: Ryotaro Onoue (7PWJ49VWRZ)";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1169;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = CPL7H8SHVM;
DEVELOPMENT_TEAM = CPL7H8SHVM;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = EQMonitor;
Expand All @@ -878,7 +870,6 @@
PRODUCT_BUNDLE_IDENTIFIER = net.yumnumm.eqmonitor;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match Development net.yumnumm.eqmonitor";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
Expand All @@ -895,11 +886,9 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Distribution: Ryotaro Onoue (CPL7H8SHVM)";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1169;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = CPL7H8SHVM;
DEVELOPMENT_TEAM = CPL7H8SHVM;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = EQMonitor;
Expand All @@ -912,7 +901,6 @@
PRODUCT_BUNDLE_IDENTIFIER = net.yumnumm.eqmonitor;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match AppStore net.yumnumm.eqmonitor";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
Expand Down
2 changes: 2 additions & 0 deletions app/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>FlutterDeepLinkingEnabled</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
Expand Down
5 changes: 5 additions & 0 deletions app/ios/Runner/Runner.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
<dict>
<key>aps-environment</key>
<string>production</string>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:deeplink.eqmonitor.app</string>
<string>applinks:deeplink.eqmonitor.app?mode=developer</string>
</array>
<key>com.apple.developer.usernotifications.critical-alerts</key>
<true/>
<key>com.apple.developer.usernotifications.time-sensitive</key>
Expand Down
6 changes: 6 additions & 0 deletions app/lib/core/theme/build_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ ThemeData buildTheme({
extensions: [if (customColors != null) customColors],
useMaterial3: true,
fontFamily: FontFamily.notoSansJP,
pageTransitionsTheme: const PageTransitionsTheme(
builders: {
// MEMO(YumNumm): PredictiveBackを使うと、MediaQuery.sizeOf(context)の値が変わるので無効
// TargetPlatform.android: PredictiveBackPageTransitionsBuilder(),
},
),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@ class EarthquakeHistoryDetailsNotifier
final target = earthquakes?.$1.firstWhereOrNull(
(earthquake) => earthquake.eventId == eventId,
);
if (target != null) {
if (target.intensityRegions != null) {
state = AsyncData(target);
} else {
ref.invalidateSelf();
}
if (target?.intensityRegions != null) {
state = AsyncData(target!);
}
}
});
Expand Down
1 change: 0 additions & 1 deletion app/lib/feature/home/component/sheet/status_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class SheetStatusWidget extends ConsumerWidget {
}

return BorderedContainer(
elevation: 1,
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
Expand Down
78 changes: 41 additions & 37 deletions app/lib/feature/home/features/map/viewmodel/main_map_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,21 @@ class _EewHypocenterService {

double _lastOpacity = 0;

Future<void> _changeOpacity(double opacity) => (
controller.setLayerProperties(
hypocenterIconId,
SymbolLayerProperties(
iconOpacity: opacity,
),
),
controller.setLayerProperties(
hypocenterLowPreciseIconId,
SymbolLayerProperties(
iconOpacity: opacity,
),
),
).wait;

Future<void> tick() async {
if (!hasInitialized) {
return;
Expand All @@ -768,24 +783,13 @@ class _EewHypocenterService {
if (_lastOpacity == 1.0) {
return;
}
_lastOpacity = 1.0;
await controller.setLayerProperties(
hypocenterIconId,
const SymbolLayerProperties(
iconOpacity: 1.0,
),
);
await _changeOpacity(1);
} else {
if (_lastOpacity == 0.5) {
return;
}
_lastOpacity = 0.5;
await controller.setLayerProperties(
hypocenterIconId,
const SymbolLayerProperties(
iconOpacity: 0.5,
),
);
await _changeOpacity(0.5);
}
}

Expand Down Expand Up @@ -834,7 +838,7 @@ class _EewPsWaveService {
_EewPWaveLineService(controller: controller),
_EewSWaveLineService(controller: controller),
// _EewPWaveFillService(controller: controller),
// _EewSWaveFillService(controller: controller),
_EewSWaveFillService(controller: controller),
);

final MaplibreMapController controller;
Expand All @@ -844,7 +848,7 @@ class _EewPsWaveService {
_EewPWaveLineService,
_EewSWaveLineService,
// _EewPWaveFillService,
// _EewSWaveFillService
_EewSWaveFillService
) _children;

Future<void> init() async {
Expand All @@ -860,7 +864,7 @@ class _EewPsWaveService {
_children.$2.init(),
).wait;
// fill
// await _children.$3.init();
await _children.$3.init();
//_children.$4.init(),
}

Expand Down Expand Up @@ -930,26 +934,28 @@ class _EewPsWaveService {
{
'type': 'Feature',
'geometry': {
'type': 'LineString',
'type': 'Polygon',
'coordinates': [
// 0...360
for (final bearing
in List<int>.generate(361, (index) => index))
() {
final latLng = const latlong2.Distance().offset(
latlong2.LatLng(
result.$2.lat,
result.$2.lon,
),
((type == _WaveType.sWave
? result.$1.sDistance ?? 0
: result.$1.pDistance ?? 0) *
1000)
.toInt(),
bearing,
);
return [latLng.longitude, latLng.latitude];
}(),
[
// 0...360
for (final bearing
in List<int>.generate(181, (index) => index * 2))
() {
final latLng = const latlong2.Distance().offset(
latlong2.LatLng(
result.$2.lat,
result.$2.lon,
),
((type == _WaveType.sWave
? result.$1.sDistance ?? 0
: result.$1.pDistance ?? 0) *
1000)
.toInt(),
bearing,
);
return [latLng.longitude, latLng.latitude];
}(),
]
],
},
'properties': {
Expand Down Expand Up @@ -1044,7 +1050,6 @@ class _EewSWaveLineService {
static String get layerId => 's-wave-line';
}

/*
class _EewPWaveFillService {
_EewPWaveFillService({
required this.controller,
Expand Down Expand Up @@ -1104,7 +1109,6 @@ class _EewSWaveFillService {

static String get layerId => 's-wave-fill';
}
*/

@freezed
class _EewHypocenterProperties with _$EewHypocenterProperties {
Expand Down
68 changes: 40 additions & 28 deletions app/lib/feature/home/view/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,24 +232,28 @@ class _HomeBodyWidget extends HookConsumerWidget {
firebaseMessagingInteractionProvider,
(_, next) async {
if (next case AsyncData(:final value)) {
ref.read(talkerProvider).log(
'Handle Firebase Message: '
"${const JsonEncoder.withIndent(' ').convert(value.toMap())}",
);
await WidgetsBinding.instance.endOfFrame.then((_) async {
ref.read(talkerProvider).log(
'Handle Firebase Message: '
"${const JsonEncoder.withIndent(' ').convert(value.toMap())}",
);

final route = value.data['route'];
if (route is String) {
ref.read(goRouterProvider).go(route);
return;
}
final url = value.data['url'];
if (url is String) {
final canLaunch = await canLaunchUrlString(url);
if (canLaunch) {
await launchUrlString(url);
final route = value.data['route'];
if (route is String) {
unawaited(
ref.read(goRouterProvider).push<void>(route),
);
return;
}
final url = value.data['url'];
if (url is String) {
final canLaunch = await canLaunchUrlString(url);
if (canLaunch) {
await launchUrlString(url);
}
return;
}
return;
}
});
}
},
);
Expand Down Expand Up @@ -495,12 +499,15 @@ class _NotificationMigrationWidget extends ConsumerWidget {
return switch (state) {
AsyncLoading() => const ListTile(
title: Text('通知設定の移行中'),
leading: CircularProgressIndicator(),
leading: CircularProgressIndicator.adaptive(),
),
AsyncError(:final error) => ListTile(
title: const Text('通知設定の移行に失敗しました'),
subtitle: Text(error.toString()),
leading: const Icon(Icons.error),
AsyncError(:final error) => BorderedContainer(
elevation: 1,
child: ListTile(
title: const Text('通知設定の初期化に失敗しました。アプリケーションを再起動することで 再度初期化を試みます。'),
subtitle: Text(error.runtimeType.toString()),
leading: const Icon(Icons.error),
),
),
AsyncData(:final value) => switch (value) {
NotificationRemoteSettingsSetupState.initial ||
Expand All @@ -511,23 +518,28 @@ class _NotificationMigrationWidget extends ConsumerWidget {
child: switch (value) {
NotificationRemoteSettingsSetupState.waitingForFcmToken =>
const ListTile(
title: Text('FCMトークンの取得中'),
leading: CircularProgressIndicator(),
title: Text('通知配信用トークンの取得中...'),
leading: CircularProgressIndicator.adaptive(),
),
NotificationRemoteSettingsSetupState.registering =>
const ListTile(
title: Text('FCMトークンの登録中'),
leading: CircularProgressIndicator(),
title: Text('通知配信用トークンの登録中...'),
leading: CircularProgressIndicator.adaptive(),
),
NotificationRemoteSettingsSetupState.migrating =>
const ListTile(
title: Text('通知設定の移行中'),
leading: CircularProgressIndicator(),
title: Text('通知設定の初期化中...'),
leading: CircularProgressIndicator.adaptive(),
),
NotificationRemoteSettingsSetupState.unsubscribingOldTopics =>
const ListTile(
title: Text('旧通知設定の解除中'),
leading: CircularProgressIndicator(),
leading: CircularProgressIndicator.adaptive(),
),
NotificationRemoteSettingsSetupState.completing =>
const ListTile(
title: Text('通知設定のセットアップが完了しました'),
leading: Icon(Icons.check),
),
_ => const SizedBox.shrink(),
},
Expand Down
Loading

0 comments on commit bdd26b1

Please sign in to comment.