diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 2eddf8176..a8b5eca3e 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,20 +1,20 @@ -name: Android CI - -on: - - pull_request - - push - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: set up JDK 17 - uses: actions/setup-java@v1 - with: - java-version: 17 - - name: Build with Gradle - run: ./scripts/build.sh - - name: Print Logs - if: failure() - run: ./scripts/print_build_logs.sh +#name: Android CI +# +#on: +# - pull_request +# - push +# +#jobs: +# build: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - name: set up JDK 17 +# uses: actions/setup-java@v1 +# with: +# java-version: 17 +# - name: Build with Gradle +# run: ./scripts/build.sh +# - name: Print Logs +# if: failure() +# run: ./scripts/print_build_logs.sh diff --git a/.github/workflows/e2e_firebase_android_test.yml b/.github/workflows/e2e_firebase_android_test.yml new file mode 100644 index 000000000..b01957fc3 --- /dev/null +++ b/.github/workflows/e2e_firebase_android_test.yml @@ -0,0 +1,63 @@ +name: e2e-firebase-android + +on: + push: +# branches: [ master ] + +# Triggers only when authCompose module changes +# paths: +# - 'authCompose/**' +# - 'build.gradle' +# - 'settings.gradle' + +# pull_request: +# branches: [ master ] + +# Triggers only when authCompose module changes +# paths: +# - 'authCompose/**' +# - 'build.gradle' +# - 'settings.gradle' + +jobs: + test: + runs-on: ubuntu-latest + timeout-minutes: 45 + + steps: + - uses: actions/checkout@v4 + + - name: Cache Gradle packages + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + + - name: Firebase Emulator Cache + uses: actions/cache@v4 + with: + path: ~/.cache/firebase/emulators + key: firebase-emulators-v3-${{ runner.os }} + + - name: Install Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + + - name: Install Tools + run: | + npm i -g firebase-tools + + - name: Start Firebase Auth Emulator Only + run: ./.github/workflows/scripts/start-firebase-emulator.sh + + - name: Run tests for authCompose + run: ./gradlew testRobo \ No newline at end of file diff --git a/.github/workflows/scripts/start-firebase-emulator.sh b/.github/workflows/scripts/start-firebase-emulator.sh new file mode 100755 index 000000000..3466af9fb --- /dev/null +++ b/.github/workflows/scripts/start-firebase-emulator.sh @@ -0,0 +1,65 @@ +#!/bin/bash +if ! [ -x "$(command -v firebase)" ]; then + echo "❌ Firebase tools CLI is missing." + exit 1 +fi + +if ! [ -x "$(command -v node)" ]; then + echo "❌ Node.js is missing." + exit 1 +fi + +if ! [ -x "$(command -v npm)" ]; then + echo "❌ NPM is missing." + exit 1 +fi + +# Extract project ID from .firebaserc +export FIREBASE_PROJECT_ID=$(cat authCompose/.firebaserc | jq -r '.projects.default') + +# Extract auth port from firebase.json +AUTH_PORT=$(cat authCompose/firebase.json | jq -r '.emulators.auth.port') +export FIREBASE_AUTH_EMULATOR_URL="http://127.0.0.1:${AUTH_PORT}" + +# Starts firebase auth emulator only +EMU_START_COMMAND="firebase emulators:start --only auth --project ${FIREBASE_PROJECT_ID}" + +MAX_RETRIES=3 +MAX_CHECKATTEMPTS=60 +CHECKATTEMPTS_WAIT=1 + +RETRIES=1 +while [ $RETRIES -le $MAX_RETRIES ]; do + + if [[ -z "${CI}" ]]; then + echo "Starting Firebase Emulator Suite in foreground." + $EMU_START_COMMAND + exit 0 + else + echo "Starting Firebase Emulator Suite in background." + $EMU_START_COMMAND & + CHECKATTEMPTS=1 + while [ $CHECKATTEMPTS -le $MAX_CHECKATTEMPTS ]; do + sleep $CHECKATTEMPTS_WAIT + if curl --output /dev/null --silent --fail ${FIREBASE_AUTH_EMULATOR_URL}; then + # Check again since it can exit before the emulator is ready. + sleep 15 + if curl --output /dev/null --silent --fail ${FIREBASE_AUTH_EMULATOR_URL}; then + echo "Firebase Emulator Suite is online!" + exit 0 + else + echo "❌ Firebase Emulator exited after startup." + exit 1 + fi + fi + echo "Waiting for Firebase Emulator Suite to come online, check $CHECKATTEMPTS of $MAX_CHECKATTEMPTS..." + ((CHECKATTEMPTS = CHECKATTEMPTS + 1)) + done + fi + + echo "Firebase Emulator Suite did not come online in $MAX_CHECKATTEMPTS checks. Try $RETRIES of $MAX_RETRIES." + ((RETRIES = RETRIES + 1)) + +done +echo "Firebase Emulator Suite did not come online after $MAX_RETRIES attempts." +exit 1 diff --git a/appcompose/.gitignore b/appcompose/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/appcompose/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/appcompose/build.gradle.kts b/appcompose/build.gradle.kts new file mode 100644 index 000000000..5ebd25d43 --- /dev/null +++ b/appcompose/build.gradle.kts @@ -0,0 +1,73 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") + id("org.jetbrains.kotlin.plugin.compose") version "2.1.0" + alias(libs.plugins.jetbrains.kotlin.serialization) +} + +android { + namespace = "com.firebase.ui.appcompose" + compileSdk = 36 + + defaultConfig { + applicationId = "com.firebase.ui.appcompose" + minSdk = 23 + targetSdk = 34 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + kotlinOptions { + jvmTarget = "11" + } + buildFeatures { + compose = true + } +} + +dependencies { + + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.activity.compose) + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.ui) + implementation(libs.androidx.ui.graphics) + implementation(libs.androidx.ui.tooling.preview) + implementation(libs.androidx.material3) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.junit) + androidTestImplementation(libs.androidx.espresso.core) + androidTestImplementation(platform(libs.androidx.compose.bom)) + androidTestImplementation(libs.androidx.ui.test.junit4) + debugImplementation(libs.androidx.ui.tooling) + debugImplementation(libs.androidx.ui.test.manifest) + + // Local module dependency + implementation(project(":authCompose")) + + // Navigation + implementation(libs.androidx.navigation3.ui) + implementation(libs.androidx.navigation3.runtime) + implementation(libs.androidx.lifecycle.viewmodel.navigation3) + implementation(libs.androidx.material3.adaptive.navigation3) + implementation(libs.kotlinx.serialization.core) +} + +// Enable Google Services plugin to process google-services.json for Firebase init +apply(plugin = "com.google.gms.google-services") diff --git a/appcompose/proguard-rules.pro b/appcompose/proguard-rules.pro new file mode 100644 index 000000000..481bb4348 --- /dev/null +++ b/appcompose/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/appcompose/src/androidTest/java/com/firebase/ui/appcompose/ExampleInstrumentedTest.kt b/appcompose/src/androidTest/java/com/firebase/ui/appcompose/ExampleInstrumentedTest.kt new file mode 100644 index 000000000..5dcea3770 --- /dev/null +++ b/appcompose/src/androidTest/java/com/firebase/ui/appcompose/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.firebase.ui.appcompose + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.firebase.ui.appcompose", appContext.packageName) + } +} \ No newline at end of file diff --git a/appcompose/src/main/AndroidManifest.xml b/appcompose/src/main/AndroidManifest.xml new file mode 100644 index 000000000..b82d59b3d --- /dev/null +++ b/appcompose/src/main/AndroidManifest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/appcompose/src/main/java/com/firebase/ui/appcompose/MainActivity.kt b/appcompose/src/main/java/com/firebase/ui/appcompose/MainActivity.kt new file mode 100644 index 000000000..5fc0d87db --- /dev/null +++ b/appcompose/src/main/java/com/firebase/ui/appcompose/MainActivity.kt @@ -0,0 +1,35 @@ +package com.firebase.ui.appcompose + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge +import com.firebase.ui.authcompose.core.AuthUIConfig +import com.firebase.ui.authcompose.core.AuthUIProvider +import com.firebase.ui.appcompose.app.App +import com.firebase.ui.appcompose.ui.theme.FirebaseUIAndroidTheme +import com.firebase.ui.authcompose.FirebaseAuthUI +import com.google.firebase.FirebaseApp + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + FirebaseAuthUI.initialize( + app = FirebaseApp.getInstance(), + config = AuthUIConfig( + providers = listOf( + // AuthUIProvider.Google(), + AuthUIProvider.Google(clientId = "771411398215-o39fujhds88bs4mb5ai7u6o73g86fspp.apps.googleusercontent.com"), + // AuthUIProvider.Email(enableEmailLinkSignIn = true), + AuthUIProvider.Email() + ) + ) + ) + enableEdgeToEdge() + setContent { + FirebaseUIAndroidTheme { + App() + } + } + } +} \ No newline at end of file diff --git a/appcompose/src/main/java/com/firebase/ui/appcompose/app/App.kt b/appcompose/src/main/java/com/firebase/ui/appcompose/app/App.kt new file mode 100644 index 000000000..e1ae2e422 --- /dev/null +++ b/appcompose/src/main/java/com/firebase/ui/appcompose/app/App.kt @@ -0,0 +1,62 @@ +package com.firebase.ui.appcompose.app + +import androidx.activity.compose.BackHandler +import androidx.compose.animation.slideInHorizontally +import androidx.compose.animation.slideOutHorizontally +import androidx.compose.animation.togetherWith +import androidx.compose.runtime.Composable +import androidx.navigation3.runtime.NavEntry +import androidx.navigation3.runtime.rememberNavBackStack +import androidx.navigation3.ui.NavDisplay +import com.firebase.ui.appcompose.router.Route +import com.firebase.ui.appcompose.router.Router +import com.firebase.ui.appcompose.ui.views.AuthView +import com.firebase.ui.appcompose.ui.views.HomeView +import com.firebase.ui.appcompose.ui.views.MainView +import com.firebase.ui.appcompose.ui.views.UnknownView + +@Composable +fun App() { + val backStack = rememberNavBackStack(Route.Initial) + val router = Router(backStack) + + NavDisplay( + backStack = router.backStack, + transitionSpec = { + // Slide in from right when navigating forward + slideInHorizontally(initialOffsetX = { it }) togetherWith + slideOutHorizontally(targetOffsetX = { -it }) + }, + popTransitionSpec = { + // Slide in from left when navigating back + slideInHorizontally(initialOffsetX = { -it }) togetherWith + slideOutHorizontally(targetOffsetX = { it }) + }, + onBack = { + if (router.backStack.size > 1) { + router.pop() + } + }, + entryProvider = { entry -> + val route = entry as Route + + when (route) { + is Route.Initial -> NavEntry(route) { + MainView(router) + } + + is Route.Auth -> NavEntry(route) { + AuthView(router) + } + + is Route.Home -> NavEntry(route) { + HomeView(router, currentUserName = route.currentUserName) + } + + is Route.Unknown -> NavEntry(route) { + UnknownView() + } + } + } + ) +} \ No newline at end of file diff --git a/appcompose/src/main/java/com/firebase/ui/appcompose/router/Router.kt b/appcompose/src/main/java/com/firebase/ui/appcompose/router/Router.kt new file mode 100644 index 000000000..2145d4f0e --- /dev/null +++ b/appcompose/src/main/java/com/firebase/ui/appcompose/router/Router.kt @@ -0,0 +1,35 @@ +package com.firebase.ui.appcompose.router + +import androidx.navigation3.runtime.NavBackStack +import androidx.navigation3.runtime.NavKey +import kotlinx.serialization.Serializable + +@Serializable +sealed class Route(val path: String) : NavKey { + @Serializable + object Initial : Route(path = "/") + + @Serializable + object Auth : Route(path = "/auth") + + @Serializable + class Home(val currentUserName: String) : Route(path = "/home") + + @Serializable + object Unknown : Route(path = "/unknown") +} + +class Router(val backStack: NavBackStack) { + fun push(route: Route) { + backStack.add(route) + } + + fun pushAndRemoveUntil(route: Route) { + backStack.clear() + backStack.add(route) + } + + fun pop() { + backStack.removeLastOrNull() + } +} diff --git a/appcompose/src/main/java/com/firebase/ui/appcompose/ui/theme/Color.kt b/appcompose/src/main/java/com/firebase/ui/appcompose/ui/theme/Color.kt new file mode 100644 index 000000000..1f9ec920e --- /dev/null +++ b/appcompose/src/main/java/com/firebase/ui/appcompose/ui/theme/Color.kt @@ -0,0 +1,11 @@ +package com.firebase.ui.appcompose.ui.theme + +import androidx.compose.ui.graphics.Color + +val Purple80 = Color(0xFFD0BCFF) +val PurpleGrey80 = Color(0xFFCCC2DC) +val Pink80 = Color(0xFFEFB8C8) + +val Purple40 = Color(0xFF6650a4) +val PurpleGrey40 = Color(0xFF625b71) +val Pink40 = Color(0xFF7D5260) \ No newline at end of file diff --git a/appcompose/src/main/java/com/firebase/ui/appcompose/ui/theme/Theme.kt b/appcompose/src/main/java/com/firebase/ui/appcompose/ui/theme/Theme.kt new file mode 100644 index 000000000..3dda90b67 --- /dev/null +++ b/appcompose/src/main/java/com/firebase/ui/appcompose/ui/theme/Theme.kt @@ -0,0 +1,58 @@ +package com.firebase.ui.appcompose.ui.theme + +import android.app.Activity +import android.os.Build +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalContext + +private val DarkColorScheme = darkColorScheme( + primary = Purple80, + secondary = PurpleGrey80, + tertiary = Pink80 +) + +private val LightColorScheme = lightColorScheme( + primary = Purple40, + secondary = PurpleGrey40, + tertiary = Pink40 + + /* Other default colors to override + background = Color(0xFFFFFBFE), + surface = Color(0xFFFFFBFE), + onPrimary = Color.White, + onSecondary = Color.White, + onTertiary = Color.White, + onBackground = Color(0xFF1C1B1F), + onSurface = Color(0xFF1C1B1F), + */ +) + +@Composable +fun FirebaseUIAndroidTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + // Dynamic color is available on Android 12+ + dynamicColor: Boolean = true, + content: @Composable () -> Unit +) { + val colorScheme = when { + dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } + + darkTheme -> DarkColorScheme + else -> LightColorScheme + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} \ No newline at end of file diff --git a/appcompose/src/main/java/com/firebase/ui/appcompose/ui/theme/Type.kt b/appcompose/src/main/java/com/firebase/ui/appcompose/ui/theme/Type.kt new file mode 100644 index 000000000..97d0f262d --- /dev/null +++ b/appcompose/src/main/java/com/firebase/ui/appcompose/ui/theme/Type.kt @@ -0,0 +1,34 @@ +package com.firebase.ui.appcompose.ui.theme + +import androidx.compose.material3.Typography +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp + +// Set of Material typography styles to start with +val Typography = Typography( + bodyLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp + ) + /* Other default text styles to override + titleLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 22.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp + ), + labelSmall = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp + ) + */ +) \ No newline at end of file diff --git a/appcompose/src/main/java/com/firebase/ui/appcompose/ui/views/AuthView.kt b/appcompose/src/main/java/com/firebase/ui/appcompose/ui/views/AuthView.kt new file mode 100644 index 000000000..0fc5dd151 --- /dev/null +++ b/appcompose/src/main/java/com/firebase/ui/appcompose/ui/views/AuthView.kt @@ -0,0 +1,55 @@ +package com.firebase.ui.appcompose.ui.views + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Scaffold +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import com.firebase.ui.authcompose.core.AuthUIResult +import com.firebase.ui.appcompose.router.Route +import com.firebase.ui.appcompose.router.Route.* +import com.firebase.ui.appcompose.router.Router +import com.firebase.ui.authcompose.FirebaseAuthUI +import com.firebase.ui.authcompose.FirebaseAuthScreen + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun AuthView(router: Router) { + FirebaseAuthScreen( + authUI = FirebaseAuthUI.instance, + onResult = { result -> + when (result) { + is AuthUIResult.Success -> { + router.pushAndRemoveUntil( + Home( + currentUserName = result.user.displayName ?: result.user.email + ?: "User" + ) + ) + println("✅Sign-in successful: ${result.user.displayName}") + } + + is AuthUIResult.Failure -> { + println("❌ Sign-in failed: ${result.exception.message}") + } + + is AuthUIResult.Cancelled -> { + println("🚫 Sign-in cancelled") + } + + null -> { + + } + } + }, + canPop = true, + onDismiss = { + router.pop() + } + ) +} \ No newline at end of file diff --git a/appcompose/src/main/java/com/firebase/ui/appcompose/ui/views/HomeView.kt b/appcompose/src/main/java/com/firebase/ui/appcompose/ui/views/HomeView.kt new file mode 100644 index 000000000..c36837034 --- /dev/null +++ b/appcompose/src/main/java/com/firebase/ui/appcompose/ui/views/HomeView.kt @@ -0,0 +1,40 @@ +package com.firebase.ui.appcompose.ui.views + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Button +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import com.firebase.ui.appcompose.router.Route +import com.firebase.ui.appcompose.router.Router +import com.firebase.ui.authcompose.FirebaseAuthUI + +@Composable +fun HomeView(router: Router, currentUserName: String) { + Scaffold( + modifier = Modifier.fillMaxSize() + ) { innerPadding -> + Column( + modifier = Modifier + .fillMaxSize() + .padding(innerPadding), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Text("Welcome, $currentUserName") + Button( + onClick = { + FirebaseAuthUI.instance.signOut() + router.pushAndRemoveUntil(Route.Initial) + } + ) { + Text("Sign Out") + } + } + } +} \ No newline at end of file diff --git a/appcompose/src/main/java/com/firebase/ui/appcompose/ui/views/MainView.kt b/appcompose/src/main/java/com/firebase/ui/appcompose/ui/views/MainView.kt new file mode 100644 index 000000000..9dc073c00 --- /dev/null +++ b/appcompose/src/main/java/com/firebase/ui/appcompose/ui/views/MainView.kt @@ -0,0 +1,77 @@ +package com.firebase.ui.appcompose.ui.views + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material3.Button +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import androidx.navigation3.runtime.rememberNavBackStack +import com.firebase.ui.appcompose.router.Route +import com.firebase.ui.appcompose.router.Router +import com.firebase.ui.appcompose.ui.theme.FirebaseUIAndroidTheme + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun MainView(router: Router) { + Scaffold( + topBar = { + TopAppBar( + title = { + Text("Auth UI Compose Demo") + }, + navigationIcon = { + if (router.backStack.size > 1) { + IconButton( + onClick = { + router.pop() + } + ) { + Icon( + Icons.AutoMirrored.Filled.ArrowBack, + contentDescription = "Back" + ) + } + } + } + ) + }, + ) { innerPadding -> + Column( + modifier = Modifier + .padding(innerPadding) + .fillMaxSize(), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Button( + onClick = { + router.push(Route.Auth) + } + ) { + Text("Go to Auth") + } + } + } +} + +@Preview(showBackground = true) +@Composable +fun PreviewMainView() { + val backStack = rememberNavBackStack(Route.Initial) + + FirebaseUIAndroidTheme { + MainView(router = Router(backStack = backStack)) + } +} diff --git a/appcompose/src/main/java/com/firebase/ui/appcompose/ui/views/UnknownView.kt b/appcompose/src/main/java/com/firebase/ui/appcompose/ui/views/UnknownView.kt new file mode 100644 index 000000000..8a2f09703 --- /dev/null +++ b/appcompose/src/main/java/com/firebase/ui/appcompose/ui/views/UnknownView.kt @@ -0,0 +1,9 @@ +package com.firebase.ui.appcompose.ui.views + +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable + +@Composable +fun UnknownView() { + Text("404 Not Found") +} \ No newline at end of file diff --git a/appcompose/src/main/res/drawable-v24/ic_launcher_foreground.xml b/appcompose/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 000000000..fde1368fc --- /dev/null +++ b/appcompose/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/appcompose/src/main/res/drawable/ic_launcher_background.xml b/appcompose/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 000000000..1e4408cae --- /dev/null +++ b/appcompose/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/appcompose/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/appcompose/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 000000000..6f3b755bf --- /dev/null +++ b/appcompose/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/appcompose/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/appcompose/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 000000000..6f3b755bf --- /dev/null +++ b/appcompose/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/appcompose/src/main/res/mipmap-hdpi/ic_launcher.webp b/appcompose/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 000000000..c209e78ec Binary files /dev/null and b/appcompose/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/appcompose/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/appcompose/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 000000000..b2dfe3d1b Binary files /dev/null and b/appcompose/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/appcompose/src/main/res/mipmap-mdpi/ic_launcher.webp b/appcompose/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 000000000..4f0f1d64e Binary files /dev/null and b/appcompose/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/appcompose/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/appcompose/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 000000000..62b611da0 Binary files /dev/null and b/appcompose/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/appcompose/src/main/res/mipmap-xhdpi/ic_launcher.webp b/appcompose/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 000000000..948a3070f Binary files /dev/null and b/appcompose/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/appcompose/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/appcompose/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 000000000..1b9a6956b Binary files /dev/null and b/appcompose/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/appcompose/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/appcompose/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 000000000..28d4b77f9 Binary files /dev/null and b/appcompose/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/appcompose/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/appcompose/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 000000000..9287f5083 Binary files /dev/null and b/appcompose/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/appcompose/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/appcompose/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 000000000..aa7d6427e Binary files /dev/null and b/appcompose/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/appcompose/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/appcompose/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 000000000..9126ae37c Binary files /dev/null and b/appcompose/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/appcompose/src/main/res/values/colors.xml b/appcompose/src/main/res/values/colors.xml new file mode 100644 index 000000000..f8c6127d3 --- /dev/null +++ b/appcompose/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/appcompose/src/main/res/values/strings.xml b/appcompose/src/main/res/values/strings.xml new file mode 100644 index 000000000..83143172a --- /dev/null +++ b/appcompose/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + appCompose + \ No newline at end of file diff --git a/appcompose/src/main/res/values/themes.xml b/appcompose/src/main/res/values/themes.xml new file mode 100644 index 000000000..1f225670b --- /dev/null +++ b/appcompose/src/main/res/values/themes.xml @@ -0,0 +1,5 @@ + + + +