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

Compose code database #1644

Open
wants to merge 4 commits into
base: compose
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion database/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ check.dependsOn 'assembleDebugAndroidTest'

android {
namespace 'com.google.firebase.quickstart.database'
compileSdk 33
compileSdk 34

defaultConfig {
applicationId "com.google.firebase.quickstart.database"
Expand Down Expand Up @@ -89,6 +89,8 @@ dependencies {

// Needed to fix a dependency conflict with FirebaseUI'
implementation 'androidx.arch.core:core-runtime:2.1.0'
implementation 'androidx.compose.runtime:runtime-livedata:1.6.8'
implementation 'androidx.navigation:navigation-compose:2.7.7'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Expand Down
8 changes: 7 additions & 1 deletion database/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:enableOnBackInvokedCallback="true">

<activity android:name=".EntryChoiceActivity"
android:exported="true">
Expand All @@ -26,6 +27,11 @@
android:name=".kotlin.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" />

<activity
android:name=".kotlin.compose.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@ class EntryChoiceActivity : BaseEntryChoiceActivity() {

override fun getChoices(): List<Choice> {
return listOf(
Choice(
"Java",
"Run the Firebase Realtime Database quickstart written in Java.",
Intent(this, com.google.firebase.quickstart.database.java.MainActivity::class.java)),
Choice(
"Kotlin",
"Run the Firebase Realtime Database quickstart written in Kotlin.",
Intent(this, com.google.firebase.quickstart.database.kotlin.MainActivity::class.java))
Choice(
"Java",
"Run the Firebase Realtime Database quickstart written in Java.",
Intent(this, com.google.firebase.quickstart.database.java.MainActivity::class.java)
),
Choice(
"Kotlin",
"Run the Firebase Realtime Database quickstart written in Kotlin.",
Intent(this, com.google.firebase.quickstart.database.kotlin.MainActivity::class.java)
),
Choice(
"Kotlin",
"Run the Firebase Realtime Database quickstart written in Compose.",
Intent(this, com.google.firebase.quickstart.database.kotlin.compose.MainActivity::class.java)
)
)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
package com.google.firebase.quickstart.database.kotlin

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.navigation.findNavController
import com.google.firebase.quickstart.database.R
import com.google.firebase.quickstart.database.databinding.ActivityMainBinding
import androidx.compose.runtime.Composable
import com.google.firebase.quickstart.database.kotlin.compose.navigation.contents.Navigation

class MainActivity : AppCompatActivity() {

private lateinit var binding: ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
val toolbar = binding.toolbar
setSupportActionBar(toolbar)

val fab = binding.fab
val navController = findNavController(R.id.nav_host_fragment)
navController.setGraph(R.navigation.nav_graph_kotlin)
navController.addOnDestinationChangedListener { _, destination, _ ->
if (destination.id == R.id.MainFragment) {
fab.isVisible = true
fab.setOnClickListener {
navController.navigate(R.id.action_MainFragment_to_NewPostFragment)
}
} else {
fab.isGone = true
}
}
setContent { Navigate() }
}
}

@Composable
fun Navigate() {
Navigation()
}

This file was deleted.

This file was deleted.

Loading