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

Improve documentation #134

Closed
1 task done
emmanuelHa opened this issue Apr 10, 2024 · 5 comments
Closed
1 task done

Improve documentation #134

emmanuelHa opened this issue Apr 10, 2024 · 5 comments
Labels
authenticator This issue relates to the Authenticator component question Further information is requested

Comments

@emmanuelHa
Copy link

emmanuelHa commented Apr 10, 2024

Before opening, please confirm:

Which UI component is this feature-request for?

Authenticator

Please include any relevant guides or documentation you're referencing

https://ui.docs.amplify.aws/android/connected-components/authenticator/configuration

Please describe your feature-request in detail.

In the parent page (https://ui.docs.amplify.aws/android/connected-components/authenticator), it is written to add the following snipet:
`class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContent {
  Authenticator { state ->
      SignedInContent(state)
  }
}

SignedInContent ? This code does not compile.
When this feature is done with javascript the ui component woks out of the box.
I am expecting from such a common feature as Signin/Signup workflow a simple code to copy/paste.

Initialization steps (if applicable)

No response

Code Snippet

// Put your code below this line.

amplifyconfiguration.json

No response

Additional information and screenshots

No response

@github-actions github-actions bot added the pending-triage Issue is pending triage label Apr 10, 2024
@mattcreaser mattcreaser added question Further information is requested authenticator This issue relates to the Authenticator component labels Apr 10, 2024
@github-actions github-actions bot removed the pending-triage Issue is pending triage label Apr 10, 2024
@mattcreaser
Copy link
Member

Hi @emmanuelHa - can you elaborate on the compilation error you're seeing?

SignedInContent is just a placeholder for your own composable, it should be whatever content you want to show for a signed-in user.

@emmanuelHa
Copy link
Author

emmanuelHa commented Apr 11, 2024

Yes now I know that SignedInContent is "just" a placeholder. But for newcomers that's not what they want. They want something that allow a use case to work from end to end, copy paste a bit of code, test it and then they adapt this code. That' a a simple rule for coding: always quickly loop through code and test. By the way this code does not compile simply because this SignedInContent does not exist.
I propose to add a basic implementation (for android use case) with coroutines:

import androidx.compose.runtime.Composable
import com.amplifyframework.ui.authenticator.SignedInState
import androidx.compose.foundation.layout.Column
import androidx.compose.material3.Text
import androidx.compose.material3.Button
import androidx.compose.runtime.rememberCoroutineScope

...

    @Composable
    fun SignedInContent(state: SignedInState) {
        val scope = rememberCoroutineScope()
        Column {
            Text("You've signed in as ${state.user.username}!")
            Button(onClick = { scope.launch { state.signOut() } }) {
                Text("Sign Out")
            }
        }
    }

Is that ok for you ?

@mattcreaser
Copy link
Member

Thanks for the suggestion @emmanuelHa. I'll update the documentation accordingly.

@emmanuelHa
Copy link
Author

Thanks @mattcreaser !

Copy link
Contributor

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
authenticator This issue relates to the Authenticator component question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants