Skip to content
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

Add Sign-in prompt #2063

Merged
merged 3 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions datalayer/phone-ui/api/current.api
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,16 @@ package com.google.android.horologist.datalayer.phone.ui.prompt.reengage {

}

package com.google.android.horologist.datalayer.phone.ui.prompt.signin {

public final class SignInBottomSheetKt {
method @androidx.compose.runtime.Composable public static void SignInBottomSheet(kotlin.jvm.functions.Function0<kotlin.Unit>? image, String topMessage, String bottomMessage, kotlin.jvm.functions.Function0<kotlin.Unit> onDismissRequest, kotlin.jvm.functions.Function0<kotlin.Unit> onConfirmation, optional androidx.compose.ui.Modifier modifier, optional String? positiveButtonLabel, optional String? negativeButtonLabel, optional androidx.compose.material3.SheetState sheetState);
}

public final class SignInPrompt {
ctor public SignInPrompt(kotlinx.coroutines.CoroutineScope coroutineScope);
method public android.content.Intent getIntent(android.content.Context context, String nodeId, @DrawableRes int image, String topMessage, String bottomMessage, optional String? positiveButtonLabel, optional String? negativeButtonLabel);
}

}

6 changes: 6 additions & 0 deletions datalayer/phone-ui/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,11 @@
android:excludeFromRecents="true"
android:exported="false"
android:theme="@style/HorologistTheme.Transparent" />

<activity
android:name=".prompt.signin.SignInBottomSheetActivity"
android:excludeFromRecents="true"
android:exported="false"
android:theme="@style/HorologistTheme.Transparent" />
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public class PhoneUiDataLayerHelper {
* ActivityResultContracts.StartActivityForResult()
* ) { result ->
* if (result.resultCode == RESULT_OK) {
* // user pushed try!
* // user pushed the positive button!
* }
* }
*
Expand All @@ -160,7 +160,7 @@ public class PhoneUiDataLayerHelper {
* ActivityResultContracts.StartActivityForResult()
* ) { result ->
* if (result.resultCode == RESULT_OK) {
* // user pushed try!
* // user pushed the positive button!
* }
* }
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ public fun ReEngageBottomSheet(
image = image,
topMessage = topMessage,
bottomMessage = bottomMessage,
positiveButtonLabel = positiveButtonLabel ?: stringResource(id = R.string.horologist_reengage_prompt_ok_btn_label),
negativeButtonLabel = negativeButtonLabel ?: stringResource(id = R.string.horologist_reengage_prompt_cancel_btn_label),
positiveButtonLabel = positiveButtonLabel
?: stringResource(id = R.string.horologist_reengage_prompt_ok_btn_label),
negativeButtonLabel = negativeButtonLabel
?: stringResource(id = R.string.horologist_reengage_prompt_cancel_btn_label),
onDismissRequest = onDismissRequest,
onConfirmation = onConfirmation,
)
Expand All @@ -92,6 +94,10 @@ public fun ReEngageBottomSheet(
image = image,
topMessage = topMessage,
bottomMessage = bottomMessage,
positiveButtonLabel = positiveButtonLabel
?: stringResource(id = R.string.horologist_reengage_prompt_ok_btn_label),
negativeButtonLabel = negativeButtonLabel
?: stringResource(id = R.string.horologist_reengage_prompt_cancel_btn_label),
onDismissRequest = onDismissRequest,
onConfirmation = onConfirmation,
)
Expand Down Expand Up @@ -183,6 +189,8 @@ internal fun ReEngageBottomSheetLandscapeContent(
image: @Composable (() -> Unit)?,
topMessage: String,
bottomMessage: String,
positiveButtonLabel: String,
negativeButtonLabel: String,
onDismissRequest: () -> Unit,
onConfirmation: () -> Unit,
modifier: Modifier = Modifier,
Expand Down Expand Up @@ -239,13 +247,13 @@ internal fun ReEngageBottomSheetLandscapeContent(
modifier = Modifier
.padding(end = PADDING_GREEN),
) {
Text(stringResource(id = R.string.horologist_install_app_prompt_cancel_btn_label))
Text(text = negativeButtonLabel)
}

Button(
onClick = onConfirmation,
) {
Text(stringResource(id = R.string.horologist_install_app_prompt_ok_btn_label))
Text(text = positiveButtonLabel)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.android.horologist.datalayer.phone.ui.prompt.signin

import kotlinx.coroutines.CoroutineScope

internal object CoroutineScopeHolder {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still curious what this looks like in other similar libraries, but will take a look myself.

Not an issue in practice, or principle, I'm just curious about it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please let me know your findings 👍

lateinit var coroutineScope: CoroutineScope
}
Loading
Loading