Skip to content

Commit f57f9cc

Browse files
authored
Merge pull request #603 from iruizmar/auth_ui_experimental_annotation
Add AuthUiExperimental annotation
2 parents 10957f9 + 6209ecd commit f57f9cc

File tree

8 files changed

+33
-24
lines changed

8 files changed

+33
-24
lines changed

plugins/ComposeAuthUI/src/commonMain/kotlin/io/github/jan/supabase/compose/auth/ui/AuthState.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import androidx.compose.runtime.compositionLocalOf
66
import androidx.compose.runtime.mutableStateMapOf
77
import androidx.compose.runtime.saveable.mapSaver
88
import androidx.compose.runtime.saveable.rememberSaveable
9-
import io.github.jan.supabase.annotations.SupabaseExperimental
109
import io.github.jan.supabase.annotations.SupabaseInternal
10+
import io.github.jan.supabase.compose.auth.ui.annotations.AuthUiExperimental
1111

1212
/**
1313
* Represents the state of auth forms.
1414
*/
15-
@SupabaseExperimental
15+
@AuthUiExperimental
1616
class AuthState(
1717
states: Map<String, Boolean> = emptyMap()
1818
) {
@@ -65,6 +65,7 @@ class AuthState(
6565
/**
6666
* Local composition for [AuthState]. Use [AuthForm] for automatic saving and restoring.
6767
*/
68+
@AuthUiExperimental
6869
val LocalAuthState = compositionLocalOf {
6970
AuthState() //possibly to throw an error here
7071
}
@@ -74,6 +75,7 @@ val LocalAuthState = compositionLocalOf {
7475
* @param state The [AuthState] to provide.
7576
* @param content The content to provide the [AuthState] to.
7677
*/
78+
@AuthUiExperimental
7779
@Composable
7880
fun AuthForm(
7981
state: AuthState = rememberSaveable(saver = AuthState.SAVER) { AuthState() },

plugins/ComposeAuthUI/src/commonMain/kotlin/io/github/jan/supabase/compose/auth/ui/FormComponent.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import androidx.compose.runtime.LaunchedEffect
55
import androidx.compose.runtime.MutableState
66
import androidx.compose.runtime.mutableStateOf
77
import androidx.compose.runtime.saveable.rememberSaveable
8-
import io.github.jan.supabase.annotations.SupabaseExperimental
8+
import io.github.jan.supabase.compose.auth.ui.annotations.AuthUiExperimental
99

1010
/**
1111
* A component that represents a form field.
@@ -14,7 +14,7 @@ import io.github.jan.supabase.annotations.SupabaseExperimental
1414
* @param mandatory Whether the form field is mandatory or not. If false, will not affect the [AuthState.validForm] value. Default is true.
1515
* @param content The composable function that defines the content of the form field and receives a mutable state object as a parameter.
1616
*/
17-
@SupabaseExperimental
17+
@AuthUiExperimental
1818
@Composable
1919
fun FormComponent(key: String, mandatory: Boolean = true, content: @Composable (valid: MutableState<Boolean>) -> Unit) {
2020
val state = LocalAuthState.current

plugins/ComposeAuthUI/src/commonMain/kotlin/io/github/jan/supabase/compose/auth/ui/ProviderButton.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import androidx.compose.ui.Modifier
1111
import androidx.compose.ui.graphics.Color
1212
import androidx.compose.ui.platform.LocalDensity
1313
import androidx.compose.ui.unit.dp
14-
import io.github.jan.supabase.annotations.SupabaseExperimental
14+
import io.github.jan.supabase.compose.auth.ui.annotations.AuthUiExperimental
1515
import io.github.jan.supabase.gotrue.providers.OAuthProvider
1616

1717
internal val DEFAULT_ICON_SIZE = 24.dp //from Material3
@@ -23,7 +23,7 @@ internal val DEFAULT_ICON_SIZE = 24.dp //from Material3
2323
* @param contentDescription The content description for the icon.
2424
* @param modifier The modifier to be applied to the icon. Note that the size of the icon is not fixed.
2525
*/
26-
@SupabaseExperimental
26+
@AuthUiExperimental
2727
@Composable
2828
fun ProviderIcon(provider: OAuthProvider, contentDescription: String?, modifier: Modifier = Modifier) {
2929
providerPainter(provider, LocalDensity.current)?.let {
@@ -42,7 +42,7 @@ fun ProviderIcon(provider: OAuthProvider, contentDescription: String?, modifier:
4242
* @param provider The OAuth provider to authenticate with.
4343
* @param text The text to display in the button. Default value is "Login in with" followed by the capitalized provider name.
4444
*/
45-
@SupabaseExperimental
45+
@AuthUiExperimental
4646
@Composable
4747
fun RowScope.ProviderButtonContent(provider: OAuthProvider, text: String = "Login with ${provider.name.capitalize()}") {
4848
ProviderIcon(provider, "Login with ${provider.name}", Modifier.size(DEFAULT_ICON_SIZE))
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package io.github.jan.supabase.compose.auth.ui.annotations
2+
3+
/**
4+
* Used to mark experimental Compose Auth Ui APIs
5+
*/
6+
@RequiresOptIn(level = RequiresOptIn.Level.ERROR, message = "This API is experimental and may not be stable yet")
7+
annotation class AuthUiExperimental

plugins/ComposeAuthUI/src/commonMain/kotlin/io/github/jan/supabase/compose/auth/ui/email/EmailField.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import androidx.compose.ui.graphics.Shape
2020
import androidx.compose.ui.text.TextStyle
2121
import androidx.compose.ui.text.input.KeyboardType
2222
import androidx.compose.ui.text.input.TextFieldValue
23-
import io.github.jan.supabase.annotations.SupabaseExperimental
2423
import io.github.jan.supabase.compose.auth.ui.AuthIcons
2524
import io.github.jan.supabase.compose.auth.ui.FormComponent
2625
import io.github.jan.supabase.compose.auth.ui.FormValidator
26+
import io.github.jan.supabase.compose.auth.ui.annotations.AuthUiExperimental
2727
import io.github.jan.supabase.compose.auth.ui.rememberMailIcon
2828

2929
/**
@@ -50,7 +50,7 @@ import io.github.jan.supabase.compose.auth.ui.rememberMailIcon
5050
* @param mandatory Whether the form field is mandatory or not. If false, will not affect the [AuthState.validForm] value. You can also make this value dynamic and only make the field mandatory, if e.g. the [value] is not empty. Default is true.
5151
*/
5252
@ExperimentalMaterial3Api
53-
@SupabaseExperimental
53+
@AuthUiExperimental
5454
@Composable
5555
fun EmailField(
5656
value: String,
@@ -130,7 +130,7 @@ fun EmailField(
130130
* @param formKey The key to store the validity of the email field in the AuthState. Defaults to "EMAIL".
131131
* @param mandatory Whether the form field is mandatory or not. If false, will not affect the [AuthState.validForm] value. You can also make this value dynamic and only make the field mandatory, if e.g. the [value] is not empty. Default is true.
132132
*/
133-
@SupabaseExperimental
133+
@AuthUiExperimental
134134
@ExperimentalMaterial3Api
135135
@Composable
136136
fun EmailField(
@@ -211,7 +211,7 @@ fun EmailField(
211211
* @param formKey The key to store the validity of the email field in the AuthState. Defaults to "EMAIL".
212212
* @param mandatory Whether the form field is mandatory or not. If false, will not affect the [AuthState.validForm] value. You can also make this value dynamic and only make the field mandatory, if e.g. the [value] is not empty. Default is true.
213213
*/
214-
@SupabaseExperimental
214+
@AuthUiExperimental
215215
@ExperimentalMaterial3Api
216216
@Composable
217217
fun OutlinedEmailField(
@@ -292,7 +292,7 @@ fun OutlinedEmailField(
292292
* @param formKey The key to store the validity of the email field in the AuthState. Defaults to "EMAIL".
293293
* @param mandatory Whether the form field is mandatory or not. If false, will not affect the [AuthState.validForm] value. You can also make this value dynamic and only make the field mandatory, if e.g. the [value] is not empty. Default is true.
294294
*/
295-
@SupabaseExperimental
295+
@AuthUiExperimental
296296
@ExperimentalMaterial3Api
297297
@Composable
298298
fun OutlinedEmailField(

plugins/ComposeAuthUI/src/commonMain/kotlin/io/github/jan/supabase/compose/auth/ui/password/PasswordField.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import androidx.compose.ui.text.input.KeyboardType
2525
import androidx.compose.ui.text.input.PasswordVisualTransformation
2626
import androidx.compose.ui.text.input.TextFieldValue
2727
import androidx.compose.ui.text.input.VisualTransformation
28-
import io.github.jan.supabase.annotations.SupabaseExperimental
2928
import io.github.jan.supabase.compose.auth.ui.AuthIcons
3029
import io.github.jan.supabase.compose.auth.ui.FormComponent
30+
import io.github.jan.supabase.compose.auth.ui.annotations.AuthUiExperimental
3131
import io.github.jan.supabase.compose.auth.ui.rememberLockIcon
3232
import io.github.jan.supabase.compose.auth.ui.rememberVisibilityIcon
3333
import io.github.jan.supabase.compose.auth.ui.rememberVisibilityOffIcon
@@ -55,7 +55,7 @@ import io.github.jan.supabase.compose.auth.ui.rememberVisibilityOffIcon
5555
* @param formKey The key to store the validity of the password field in the AuthState. Defaults to "EMAIL".
5656
* @param mandatory Whether the form field is mandatory or not. If false, will not affect the [AuthState.validForm] value. You can also make this value dynamic and only make the field mandatory, if e.g. the [value] is not empty. Default is true.
5757
*/
58-
@SupabaseExperimental
58+
@AuthUiExperimental
5959
@ExperimentalMaterial3Api
6060
@Composable
6161
fun PasswordField(
@@ -141,7 +141,7 @@ fun PasswordField(
141141
* @param formKey The key to store the validity of the password field in the AuthState. Defaults to "EMAIL".
142142
* @param mandatory Whether the form field is mandatory or not. If false, will not affect the [AuthState.validForm] value. You can also make this value dynamic and only make the field mandatory, if e.g. the [value] is not empty. Default is true.
143143
*/
144-
@SupabaseExperimental
144+
@AuthUiExperimental
145145
@ExperimentalMaterial3Api
146146
@Composable
147147
fun PasswordField(
@@ -228,7 +228,7 @@ fun PasswordField(
228228
* @param formKey The key to store the validity of the password field in the AuthState. Defaults to "EMAIL".
229229
* @param mandatory Whether the form field is mandatory or not. If false, will not affect the [AuthState.validForm] value. You can also make this value dynamic and only make the field mandatory, if e.g. the [value] is not empty. Default is true.
230230
*/
231-
@SupabaseExperimental
231+
@AuthUiExperimental
232232
@ExperimentalMaterial3Api
233233
@Composable
234234
fun OutlinedPasswordField(
@@ -314,7 +314,7 @@ fun OutlinedPasswordField(
314314
* @param formKey The key to store the validity of the password field in the AuthState. Defaults to "EMAIL".
315315
* @param mandatory Whether the form field is mandatory or not. If false, will not affect the [AuthState.validForm] value. You can also make this value dynamic and only make the field mandatory, if e.g. the [value] is not empty. Default is true.
316316
*/
317-
@SupabaseExperimental
317+
@AuthUiExperimental
318318
@ExperimentalMaterial3Api
319319
@Composable
320320
fun OutlinedPasswordField(

plugins/ComposeAuthUI/src/commonMain/kotlin/io/github/jan/supabase/compose/auth/ui/phone/PhoneField.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import androidx.compose.ui.text.TextStyle
2020
import androidx.compose.ui.text.input.KeyboardType
2121
import androidx.compose.ui.text.input.TextFieldValue
2222
import androidx.compose.ui.text.input.VisualTransformation
23-
import io.github.jan.supabase.annotations.SupabaseExperimental
2423
import io.github.jan.supabase.compose.auth.ui.AuthIcons
2524
import io.github.jan.supabase.compose.auth.ui.FormComponent
2625
import io.github.jan.supabase.compose.auth.ui.FormValidator
26+
import io.github.jan.supabase.compose.auth.ui.annotations.AuthUiExperimental
2727
import io.github.jan.supabase.compose.auth.ui.rememberCallIcon
2828

2929
private const val DEFAULT_MASK = "+## ### #########"
@@ -54,7 +54,7 @@ private const val DEFAULT_MASK_CHAR = '#'
5454
* @param formKey The key to store the validity of the phone field in the AuthState. Defaults to "EMAIL".
5555
* @param mandatory Whether the form field is mandatory or not. If false, will not affect the [AuthState.validForm] value. You can also make this value dynamic and only make the field mandatory, if e.g. the [value] is not empty. Default is true.
5656
*/
57-
@SupabaseExperimental
57+
@AuthUiExperimental
5858
@Composable
5959
fun PhoneField(
6060
value: String,
@@ -143,7 +143,7 @@ fun PhoneField(
143143
* @param formKey The key to store the validity of the phone field in the AuthState. Defaults to "EMAIL".
144144
* @param mandatory Whether the form field is mandatory or not. If false, will not affect the [AuthState.validForm] value. You can also make this value dynamic and only make the field mandatory, if e.g. the [value] is not empty. Default is true.
145145
*/
146-
@SupabaseExperimental
146+
@AuthUiExperimental
147147
@Composable
148148
fun PhoneField(
149149
value: TextFieldValue,
@@ -232,7 +232,7 @@ fun PhoneField(
232232
* @param formKey The key to store the validity of the phone field in the AuthState. Defaults to "EMAIL".
233233
* @param mandatory Whether the form field is mandatory or not. If false, will not affect the [AuthState.validForm] value. You can also make this value dynamic and only make the field mandatory, if e.g. the [value] is not empty. Default is true.
234234
*/
235-
@SupabaseExperimental
235+
@AuthUiExperimental
236236
@Composable
237237
fun OutlinedPhoneField(
238238
value: TextFieldValue,
@@ -321,7 +321,7 @@ fun OutlinedPhoneField(
321321
* @param formKey The key to store the validity of the phone field in the AuthState. Defaults to "EMAIL".
322322
* @param mandatory Whether the form field is mandatory or not. If false, will not affect the [AuthState.validForm] value. You can also make this value dynamic and only make the field mandatory, if e.g. the [value] is not empty. Default is true.
323323
*/
324-
@SupabaseExperimental
324+
@AuthUiExperimental
325325
@Composable
326326
fun OutlinedPhoneField(
327327
value: String,

plugins/ComposeAuthUI/src/commonMain/kotlin/io/github/jan/supabase/compose/auth/ui/phone/PhoneVisualTransformation.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import androidx.compose.ui.text.buildAnnotatedString
55
import androidx.compose.ui.text.input.OffsetMapping
66
import androidx.compose.ui.text.input.TransformedText
77
import androidx.compose.ui.text.input.VisualTransformation
8-
import io.github.jan.supabase.annotations.SupabaseExperimental
8+
import io.github.jan.supabase.compose.auth.ui.annotations.AuthUiExperimental
99

1010
/**
1111
* Represents a phone number visual transformation.
@@ -14,7 +14,7 @@ import io.github.jan.supabase.annotations.SupabaseExperimental
1414
* @param maskNumber The character used in the mask to represent a digit.
1515
*
1616
*/
17-
@SupabaseExperimental
17+
@AuthUiExperimental
1818
class PhoneVisualTransformation(val mask: String, val maskNumber: Char) : VisualTransformation {
1919

2020
private val maxLength = mask.count { it == maskNumber }

0 commit comments

Comments
 (0)