mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-1503 Sample | Design | Base dialog (#170)
This commit is contained in:
parent
e74a56fc0f
commit
1acedec330
8 changed files with 193 additions and 1 deletions
|
@ -3,6 +3,7 @@ plugins {
|
|||
id "kotlin-android"
|
||||
id "kotlin-android-extensions"
|
||||
id "kotlin-kapt"
|
||||
id 'com.google.gms.google-services'
|
||||
}
|
||||
|
||||
android {
|
||||
|
@ -84,4 +85,6 @@ dependencies {
|
|||
testImplementation libs.robolectric
|
||||
testImplementation libs.androidXTestCore
|
||||
testImplementation libs.mockitoKotlin
|
||||
|
||||
implementation platform('com.google.firebase:firebase-bom:32.1.1')
|
||||
}
|
||||
|
|
39
sample/google-services.json
Normal file
39
sample/google-services.json
Normal file
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"project_info": {
|
||||
"project_number": "75520222594",
|
||||
"project_id": "anytype-sample-app",
|
||||
"storage_bucket": "anytype-sample-app.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:75520222594:android:d4012298e84c02fd701b9b",
|
||||
"android_client_info": {
|
||||
"package_name": "com.anytypeio.anytype.sample"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "75520222594-b8cfi2o2kc9opuc4q5jak0lq0itf9omb.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyADvkkkSxg41N_t6DKYh23-fiYRwAzFB7U"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "75520222594-b8cfi2o2kc9opuc4q5jak0lq0itf9omb.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
|
@ -27,6 +27,7 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.unit.dp
|
||||
import com.anytypeio.anytype.core_ui.views.ButtonSecondaryLoading
|
||||
import com.anytypeio.anytype.core_ui.views.ButtonPrimary
|
||||
import com.anytypeio.anytype.core_ui.views.ButtonPrimaryDarkTheme
|
||||
import com.anytypeio.anytype.core_ui.views.ButtonSecondary
|
||||
import com.anytypeio.anytype.core_ui.views.ButtonSize
|
||||
import com.anytypeio.anytype.core_ui.views.ButtonWarning
|
||||
|
@ -132,6 +133,14 @@ class ComposeButtonsPrimaryFragment : BaseComposeFragment() {
|
|||
modifierButton = Modifier
|
||||
.wrapContentHeight()
|
||||
)
|
||||
ButtonPrimaryDarkTheme(
|
||||
onClick = {},
|
||||
modifier = Modifier
|
||||
.wrapContentHeight()
|
||||
.align(CenterHorizontally),
|
||||
text = "Button Dark",
|
||||
size = ButtonSize.XSmall
|
||||
)
|
||||
Text(
|
||||
text = "Button.Small",
|
||||
modifier = Modifier
|
||||
|
@ -206,6 +215,14 @@ class ComposeButtonsPrimaryFragment : BaseComposeFragment() {
|
|||
modifierButton = Modifier
|
||||
.wrapContentHeight()
|
||||
)
|
||||
ButtonPrimaryDarkTheme(
|
||||
onClick = {},
|
||||
modifier = Modifier
|
||||
.wrapContentHeight()
|
||||
.align(CenterHorizontally),
|
||||
text = "Button Dark",
|
||||
size = ButtonSize.Small
|
||||
)
|
||||
Text(
|
||||
text = "Button.Medium",
|
||||
modifier = Modifier
|
||||
|
@ -288,6 +305,15 @@ class ComposeButtonsPrimaryFragment : BaseComposeFragment() {
|
|||
.wrapContentHeight()
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||
)
|
||||
ButtonPrimaryDarkTheme(
|
||||
onClick = {},
|
||||
modifier = Modifier
|
||||
.wrapContentHeight()
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||
.align(CenterHorizontally),
|
||||
text = "Button Dark",
|
||||
size = ButtonSize.Medium
|
||||
)
|
||||
Text(
|
||||
text = "Button.Large",
|
||||
modifier = Modifier
|
||||
|
@ -373,6 +399,16 @@ class ComposeButtonsPrimaryFragment : BaseComposeFragment() {
|
|||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||
)
|
||||
ButtonPrimaryDarkTheme(
|
||||
onClick = {},
|
||||
modifier = Modifier
|
||||
.wrapContentHeight()
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||
.align(CenterHorizontally),
|
||||
text = "Button Dark",
|
||||
size = ButtonSize.Large
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
package com.anytypeio.anytype.sample.design_system
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.ExperimentalComposeUiApi
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.compose.ui.platform.ViewCompositionStrategy
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anytypeio.anytype.core_ui.views.BaseAlertDialog
|
||||
import com.anytypeio.anytype.core_ui.views.ButtonPrimary
|
||||
import com.anytypeio.anytype.core_ui.views.ButtonSize
|
||||
import com.anytypeio.anytype.core_ui.views.HeadlineHeading
|
||||
import com.anytypeio.anytype.core_utils.ui.BaseComposeFragment
|
||||
import com.anytypeio.anytype.sample.R
|
||||
import com.google.accompanist.pager.ExperimentalPagerApi
|
||||
import kotlinx.coroutines.FlowPreview
|
||||
|
||||
class ComposeDialogFragment : BaseComposeFragment() {
|
||||
|
||||
@FlowPreview
|
||||
@ExperimentalPagerApi
|
||||
@ExperimentalMaterialApi
|
||||
@ExperimentalComposeUiApi
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View {
|
||||
return ComposeView(requireContext()).apply {
|
||||
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
|
||||
setContent {
|
||||
|
||||
val showDialog = remember { mutableStateOf(false) }
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(vertical = 16.dp)
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.verticalScroll(rememberScrollState())
|
||||
) {
|
||||
Text(
|
||||
text = "Dialogs",
|
||||
modifier = Modifier.align(Alignment.CenterHorizontally),
|
||||
style = HeadlineHeading,
|
||||
color = colorResource(id = R.color.text_primary)
|
||||
)
|
||||
ButtonPrimary(
|
||||
onClick = { showDialog.value = true },
|
||||
modifier = Modifier
|
||||
.wrapContentHeight()
|
||||
.padding(horizontal = 16.dp, vertical = 32.dp)
|
||||
.align(Alignment.CenterHorizontally),
|
||||
text = "Show Dialog",
|
||||
size = ButtonSize.Medium
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (showDialog.value) {
|
||||
BaseAlertDialog(
|
||||
onDismissRequest = { showDialog.value = false },
|
||||
onButtonClick = { showDialog.value = false },
|
||||
dialogText = "Here’s some alert text. It can span multiple lines if needed!",
|
||||
buttonText = "Ok"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun injectDependencies() {}
|
||||
|
||||
override fun releaseDependencies() {}
|
||||
}
|
|
@ -4,7 +4,6 @@ import android.os.Bundle
|
|||
import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.anytypeio.anytype.sample.R
|
||||
import com.anytypeio.anytype.sample.databinding.FragmentButtonsBinding
|
||||
import com.anytypeio.anytype.sample.databinding.FragmentContentStyleMultilineBinding
|
||||
|
||||
class ContentStyleMultiline: Fragment(R.layout.fragment_content_style_multiline) {
|
||||
|
|
|
@ -71,6 +71,14 @@ class DesignSystemActivity : AppCompatActivity(), Navigate {
|
|||
.addToBackStack(null)
|
||||
.commit()
|
||||
}
|
||||
|
||||
override fun toDialogsCompose() {
|
||||
supportFragmentManager
|
||||
.beginTransaction()
|
||||
.replace(R.id.root, ComposeDialogFragment())
|
||||
.addToBackStack(null)
|
||||
.commit()
|
||||
}
|
||||
}
|
||||
|
||||
interface Navigate {
|
||||
|
@ -81,4 +89,5 @@ interface Navigate {
|
|||
fun toButtonsSecondary()
|
||||
fun toButtonsWarning()
|
||||
fun toButtonsCompose()
|
||||
fun toDialogsCompose()
|
||||
}
|
|
@ -34,6 +34,9 @@ class NavigateFragment : Fragment(R.layout.fragment_navigate) {
|
|||
view.findViewById<TextView>(R.id.btnCompose).setOnClickListener {
|
||||
(activity as Navigate).toButtonsCompose()
|
||||
}
|
||||
view.findViewById<TextView>(R.id.btnDialogsCompose).setOnClickListener {
|
||||
(activity as Navigate).toDialogsCompose()
|
||||
}
|
||||
view.findViewById<Switch>(R.id.switch3).setOnClickListener {
|
||||
it as Switch
|
||||
if (it.isChecked) {
|
||||
|
|
|
@ -86,4 +86,14 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button20" />
|
||||
|
||||
<com.anytypeio.anytype.core_ui.views.ButtonPrimaryMedium
|
||||
android:id="@+id/btnDialogsCompose"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:text="Dialogs Compose"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button20" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Add table
Add a link
Reference in a new issue