refactor: move test dialog activity to samples
This commit is contained in:
parent
5fe629c33f
commit
b28a3f755a
6 changed files with 45 additions and 6 deletions
|
@ -58,7 +58,7 @@
|
|||
android:label="@string/manage_blocked_numbers" />
|
||||
|
||||
<activity
|
||||
android:name="com.simplemobiletools.commons.activities.TestDialogActivity"
|
||||
android:name="com.simplemobiletools.commons.samples.activities.TestDialogActivity"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
android:exported="false" />
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ val dialogContainerColor
|
|||
else -> MaterialTheme.colorScheme.surface
|
||||
}
|
||||
|
||||
val dialogShape get() = Shapes.large
|
||||
val dialogShape = Shapes.large
|
||||
|
||||
val dialogElevation = 0.dp
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package com.simplemobiletools.commons.interfaces
|
||||
|
||||
interface LineColorPickerListener {
|
||||
fun interface LineColorPickerListener {
|
||||
fun colorChanged(index: Int, color: Int)
|
||||
}
|
||||
|
|
|
@ -41,6 +41,22 @@ android {
|
|||
buildFeatures {
|
||||
buildConfig = true
|
||||
viewBinding = true
|
||||
compose = true
|
||||
}
|
||||
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
||||
kotlinOptions.jvmTarget = project.libs.versions.app.build.kotlinJVMTarget.get()
|
||||
kotlinOptions.freeCompilerArgs = listOf(
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
"-opt-in=androidx.compose.material3.ExperimentalMaterial3Api",
|
||||
"-opt-in=androidx.compose.material.ExperimentalMaterialApi",
|
||||
"-opt-in=androidx.compose.foundation.ExperimentalFoundationApi",
|
||||
"-Xcontext-receivers"
|
||||
)
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
@ -57,4 +73,8 @@ dependencies {
|
|||
implementation(projects.commons)
|
||||
implementation(libs.material)
|
||||
implementation(libs.androidx.swiperefreshlayout)
|
||||
|
||||
implementation(libs.bundles.lifecycle)
|
||||
implementation(libs.bundles.compose)
|
||||
debugImplementation(libs.bundles.compose.preview)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.content.Intent
|
|||
import android.os.Bundle
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.activities.ManageBlockedNumbersActivity
|
||||
import com.simplemobiletools.commons.activities.TestDialogActivity
|
||||
import com.simplemobiletools.commons.dialogs.BottomSheetChooserDialog
|
||||
import com.simplemobiletools.commons.extensions.appLaunched
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.simplemobiletools.commons.activities
|
||||
package com.simplemobiletools.commons.samples.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.foundation.layout.*
|
||||
|
@ -16,6 +17,7 @@ import com.simplemobiletools.commons.compose.alert_dialog.AlertDialogState
|
|||
import com.simplemobiletools.commons.compose.alert_dialog.rememberAlertDialogState
|
||||
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
|
||||
import com.simplemobiletools.commons.dialogs.*
|
||||
import com.simplemobiletools.commons.extensions.baseConfig
|
||||
|
||||
class TestDialogActivity : ComponentActivity() {
|
||||
|
||||
|
@ -30,6 +32,7 @@ class TestDialogActivity : ComponentActivity() {
|
|||
val donateAlertDialogState = getDonateAlertDialogState()
|
||||
val featureLockedAlertDialogState = getFeatureLockedAlertDialogState()
|
||||
val purchaseThankYouAlertDialogState = getPurchaseThankYouAlertDialogState()
|
||||
val lineColorPickerAlertDialogState = getLineColorPickerAlertDialogState()
|
||||
Column(
|
||||
Modifier
|
||||
.fillMaxSize()
|
||||
|
@ -45,20 +48,37 @@ class TestDialogActivity : ComponentActivity() {
|
|||
ShowButton(donateAlertDialogState, text = "Donate")
|
||||
ShowButton(featureLockedAlertDialogState, text = "Feature Locked")
|
||||
ShowButton(purchaseThankYouAlertDialogState, text = "Purchase thank you")
|
||||
ShowButton(lineColorPickerAlertDialogState, text = "Line color picker")
|
||||
Spacer(modifier = Modifier.padding(bottom = 16.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun getLineColorPickerAlertDialogState() = rememberAlertDialogState().apply {
|
||||
DialogMember {
|
||||
LineColorPickerAlertDialog(
|
||||
alertDialogState = this,
|
||||
color = baseConfig.customPrimaryColor,
|
||||
isPrimaryColorPicker = true,
|
||||
onButtonPressed = { wasPositivePressed, color ->
|
||||
Log.d("LineColorPickerAlertDialog", "wasPositivePressed $wasPositivePressed color $color")
|
||||
}, onActiveColorChange = {
|
||||
Log.d("LineColorPickerAlertDialog", "onActiveColorChange $it")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun getPurchaseThankYouAlertDialogState() = rememberAlertDialogState().apply {
|
||||
DialogMember {
|
||||
PurchaseThankYouAlertDialog(alertDialogState = this)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun getFeatureLockedAlertDialogState()= rememberAlertDialogState().apply {
|
||||
private fun getFeatureLockedAlertDialogState() = rememberAlertDialogState().apply {
|
||||
DialogMember {
|
||||
FeatureLockedAlertDialog(alertDialogState = this, callback = {})
|
||||
}
|
Loading…
Reference in a new issue