-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ [Compose Multiplatform] When you tap the action label on the snack bar that appears when you don't have permission to access the calendar, the iOS Settings app will now open. #907
Merged
takahirom
merged 7 commits into
DroidKaigi:main
from
Corvus400:feature/open_settings_app_from_timetable_detail_snack_bar_compose_multiplatform
Sep 1, 2024
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9f220fb
:sparkles: Added text to display in the snack bar.
Corvus400 5fac57f
:recycle: The action label is now displayed in the snack bar.
Corvus400 91967f9
:sparkles: A method for opening the settings app has been added in a …
Corvus400 160d9c7
:recycle: When you tap the action label on the snack bar, the iOS Set…
Corvus400 5354a6e
Merge branch 'main' of github.com:Corvus400/conference-app-2024 into …
Corvus400 d6911cb
Merge branch 'main' into feature/open_settings_app_from_timetable_det…
Corvus400 9806779
:wrench: The class hosting the ExternalNavController was changed from…
Corvus400 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
app-ios-shared/src/commonMain/composeResources/values-ja/strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="permission_required">セッションを予定として追加するには、カレンダーへのアクセス権限が必要です。</string> | ||
<string name="open_settings">設定を開く</string> | ||
</resources> |
1 change: 1 addition & 0 deletions
1
app-ios-shared/src/commonMain/composeResources/values/strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="permission_required">To add a session as a scheduled event, you need access permission to the calendar.</string> | ||
<string name="open_settings">Open settings.</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 25 additions & 8 deletions
33
...rc/commonMain/kotlin/io/github/droidkaigi/confsched/shared/IosComposeKaigiAppPresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,51 @@ | ||
package io.github.droidkaigi.confsched.shared | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import io.github.droidkaigi.confsched.compose.EventEffect | ||
import io.github.droidkaigi.confsched.compose.EventFlow | ||
import io.github.droidkaigi.confsched.droidkaigiui.UserMessageResult.ActionPerformed | ||
import io.github.droidkaigi.confsched.droidkaigiui.providePresenterDefaults | ||
import io.github.droidkaigi.confsched.shared.IosComposeKaigiAppEvent.SettingsAppNavigated | ||
import io.github.droidkaigi.confsched.shared.IosComposeKaigiAppEvent.ShowRequiresAuthorization | ||
|
||
sealed interface IosComposeKaigiAppEvent { | ||
val snackbarMessage: String | ||
|
||
data class ShowRequiresAuthorization( | ||
override val snackbarMessage: String, | ||
val snackbarMessage: String, | ||
val actionLabel: String, | ||
) : IosComposeKaigiAppEvent | ||
|
||
data object SettingsAppNavigated : IosComposeKaigiAppEvent | ||
} | ||
|
||
@Composable | ||
fun iosComposeKaigiAppPresenter( | ||
events: EventFlow<IosComposeKaigiAppEvent> | ||
) : IosComposeKaigiAppUiState = providePresenterDefaults { userMessageStateHolder -> | ||
var shouldGoToSettingsApp by remember { mutableStateOf(false) } | ||
|
||
EventEffect(events) { event -> | ||
when (event) { | ||
is ShowRequiresAuthorization -> { | ||
userMessageStateHolder.showMessage( | ||
val result = userMessageStateHolder.showMessage( | ||
message = event.snackbarMessage, | ||
// TODO Add code to transition to the settings screen when the action button is pressed. | ||
// TODO Perhaps UIApplication.openSettingsURLString can be used to achieve this. | ||
actionLabel = null, | ||
actionLabel = event.actionLabel, | ||
) | ||
if (result == ActionPerformed) { | ||
shouldGoToSettingsApp = true | ||
} | ||
} | ||
|
||
SettingsAppNavigated -> { | ||
shouldGoToSettingsApp = false | ||
} | ||
} | ||
} | ||
IosComposeKaigiAppUiState(userMessageStateHolder) | ||
IosComposeKaigiAppUiState( | ||
userMessageStateHolder = userMessageStateHolder, | ||
shouldGoToSettingsApp = shouldGoToSettingsApp, | ||
) | ||
} |
12 changes: 12 additions & 0 deletions
12
...ios-shared/src/commonMain/kotlin/io/github/droidkaigi/confsched/shared/OpenSettingsApp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.github.droidkaigi.confsched.shared | ||
|
||
import platform.Foundation.NSURL | ||
import platform.UIKit.UIApplication | ||
import platform.UIKit.UIApplicationOpenSettingsURLString | ||
|
||
fun openSettingsApp() { | ||
val settingsUrl = NSURL.URLWithString(UIApplicationOpenSettingsURLString) | ||
if (settingsUrl != null) { | ||
UIApplication.sharedApplication.openURL(settingsUrl) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I think we can include rememberExternalNavController() as a parameter in KaigiApp.