Skip to content

Commit

Permalink
refactor: Item 布局
Browse files Browse the repository at this point in the history
  • Loading branch information
jing332 committed Aug 28, 2023
1 parent 76bf1cf commit 0d10e0c
Show file tree
Hide file tree
Showing 21 changed files with 73 additions and 1,037 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import com.github.jing332.tts_server_android.constant.MsTtsApiType
import com.github.jing332.tts_server_android.data.entities.systts.SystemTts
import com.github.jing332.tts_server_android.model.speech.tts.MsTTS
import com.github.jing332.tts_server_android.model.speech.tts.MsTtsFormatManger
import com.github.jing332.tts_server_android.ui.systts.edit.microsoft.GeneralVoiceData
import com.github.jing332.tts_server_android.model.GeneralVoiceData
import com.github.jing332.tts_server_android.ui.view.AppDialogs.displayErrorDialog

class MsTtsUI : TtsUI() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.github.jing332.tts_server_android.compose.systts.list.edit.ui
import androidx.compose.runtime.mutableStateListOf
import androidx.lifecycle.ViewModel
import com.github.jing332.tts_server_android.constant.MsTtsApiType
import com.github.jing332.tts_server_android.ui.systts.edit.microsoft.GeneralVoiceData
import com.github.jing332.tts_server_android.ui.systts.edit.microsoft.MsTtsEditRepository
import com.github.jing332.tts_server_android.model.GeneralVoiceData
import com.github.jing332.tts_server_android.model.MsTtsEditRepository

class MsTtsViewModel : ViewModel() {
companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.github.jing332.tts_server_android.compose.widgets

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.stateDescription
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.github.jing332.tts_server_android.R
import kotlinx.coroutines.delay

@Composable
fun LoadingContent(modifier: Modifier, isLoading: Boolean, content: @Composable () -> Unit) {
val context = LocalContext.current
Box(modifier) {
Box(
Modifier
.wrapContentSize()
.alpha(if (isLoading) 0.2f else 1f)
) {
content()
}

AnimatedVisibility(
visible = isLoading, modifier = Modifier
.size(64.dp)
.align(Alignment.Center)
) {
CircularProgressIndicator(modifier = Modifier.semantics {
stateDescription = context.getString(R.string.loading)
}, strokeWidth = 8.dp)
}
}
}

@Preview
@Composable
fun PreviewLoadingContent() {
MaterialTheme {
var loading by remember { mutableStateOf(true) }
LaunchedEffect(Unit) {
delay(3000)
loading = false
}

LoadingContent(Modifier, loading) {
OutlinedTextField(value = "hello", onValueChange = {}, label = { Text("Label") })
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.jing332.tts_server_android.ui.systts.edit.microsoft
package com.github.jing332.tts_server_android.model

import com.drake.net.utils.withDefault
import com.drake.net.utils.withIO
Expand All @@ -8,7 +8,6 @@ import com.github.jing332.tts_server_android.constant.AppConst
import com.github.jing332.tts_server_android.constant.CnLocalMap
import com.github.jing332.tts_server_android.constant.MsTtsApiType
import com.github.jing332.tts_server_android.utils.FileUtils
import kotlinx.serialization.decodeFromString
import tts_server_lib.Tts_server_lib
import java.io.File
import java.util.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object ImportConfigFactory {

fun createFragment(type: String): BaseImportConfigBottomSheetFragment? {
return when (type) {
ID_LIST -> com.github.jing332.tts_server_android.ui.systts.list.ImportConfigBottomSheetFragment()
// ID_LIST -> com.github.jing332.tts_server_android.ui.systts.list.ImportConfigBottomSheetFragment()
// ID_PLUGIN -> com.github.jing332.tts_server_android.ui.systts.plugin.ImportBottomSheetFragment()
ID_REPLACE_RULE -> com.github.jing332.tts_server_android.ui.systts.replace.ImportConfigBottomSheetFragment()
// ID_SPEECH_RULE -> com.github.jing332.tts_server_android.ui.systts.speech_rule.ImportConfigBottomSheetFragment()
Expand Down
Loading

0 comments on commit 0d10e0c

Please sign in to comment.