Skip to content

Commit

Permalink
fix: 部分对话框标题间距修复
Browse files Browse the repository at this point in the history
  • Loading branch information
Mystery00 committed Feb 4, 2024
1 parent 9044692 commit e891a31
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 22 deletions.
1 change: 0 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ dependencies {
implementation("com.maxkeppeler.sheets-compose-dialogs:input:$sheetsComposeDialogsVersion")
implementation("com.maxkeppeler.sheets-compose-dialogs:list:$sheetsComposeDialogsVersion")
implementation("com.maxkeppeler.sheets-compose-dialogs:option:$sheetsComposeDialogsVersion")
implementation("com.maxkeppeler.sheets-compose-dialogs:state:$sheetsComposeDialogsVersion")
//lottie
implementation("com.airbnb.android:lottie-compose:6.3.0")
//room
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
Expand All @@ -68,6 +67,8 @@ import com.airbnb.lottie.compose.LottieAnimation
import com.airbnb.lottie.compose.LottieCompositionSpec
import com.airbnb.lottie.compose.LottieConstants
import com.airbnb.lottie.compose.rememberLottieComposition
import com.maxkeppeker.sheets.core.models.base.Header
import com.maxkeppeker.sheets.core.utils.BaseValues
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import org.koin.core.component.KoinComponent
Expand Down Expand Up @@ -274,7 +275,6 @@ abstract class BaseComposeActivity : ComponentActivity(), KoinComponent {
}
}

@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun BuildSearchText(
searchText: String,
Expand Down Expand Up @@ -380,4 +380,21 @@ abstract class BaseComposeActivity : ComponentActivity(), KoinComponent {
}
}.value
}

fun xhuHeader(title: String): Header =
Header.Custom {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(BaseValues.CONTENT_DEFAULT_PADDING)
.padding(top = 24.dp),
) {
Text(
text = title,
style = MaterialTheme.typography.headlineSmall,
color = MaterialTheme.colorScheme.onSurface,
textAlign = TextAlign.Start
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.maxkeppeker.sheets.core.models.base.Header
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.list.ListDialog
import com.maxkeppeler.sheets.list.models.ListOption
Expand Down Expand Up @@ -243,7 +242,7 @@ abstract class BaseSelectComposeActivity : BasePageComposeActivity() {
) {
if (show.showing) {
ListDialog(
header = Header.Default(title = dialogTitle),
header = xhuHeader(title = dialogTitle),
state = rememberUseCaseState(
visible = true,
onCloseRequest = { show.hide() }),
Expand Down Expand Up @@ -275,7 +274,7 @@ abstract class BaseSelectComposeActivity : BasePageComposeActivity() {
) {
if (state.showing) {
ListDialog(
header = Header.Default(title = dialogTitle),
header = xhuHeader(title = dialogTitle),
state = rememberUseCaseState(
visible = true,
onCloseRequest = { state.hide() }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.maxkeppeker.sheets.core.models.base.Header
import com.maxkeppeker.sheets.core.models.base.SelectionButton
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.input.InputDialog
Expand Down Expand Up @@ -288,7 +287,7 @@ class AccountSettingsActivity : BaseComposeActivity(), KoinComponent {
}),
)
InputDialog(
header = Header.Default(title = "请输入模板内容"),
header = xhuHeader(title = "请输入模板内容"),
state = rememberUseCaseState(
visible = true,
onCloseRequest = { show.hide() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.paging.LoadState
import com.maxkeppeker.sheets.core.models.base.Header
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.option.OptionDialog
import com.maxkeppeler.sheets.option.models.DisplayMode
Expand Down Expand Up @@ -152,7 +151,7 @@ class CourseRoomActivity : BaseSelectComposeActivity() {
config = OptionConfig(mode = DisplayMode.GRID_VERTICAL, gridColumns = columnSize)
}
OptionDialog(
header = Header.Default(title = title),
header = xhuHeader(title = title),
state = rememberUseCaseState(
visible = true,
onCloseRequest = { show.hide() }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.paging.LoadState
import com.maxkeppeker.sheets.core.models.base.Header
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.input.InputDialog
import com.maxkeppeler.sheets.input.models.InputConfig
Expand Down Expand Up @@ -272,7 +271,7 @@ class CustomCourseActivity : BaseSelectComposeActivity() {
)

InputDialog(
header = Header.Default(title = "请选择上课时间"),
header = xhuHeader(title = "请选择上课时间"),
state = rememberUseCaseState(visible = true, onCloseRequest = { state.hide() }),
config = InputConfig(columns = 2),
selection = InputSelection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.maxkeppeker.sheets.core.models.base.Header
import com.maxkeppeker.sheets.core.models.base.SelectionButton
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.input.InputDialog
Expand Down Expand Up @@ -336,7 +335,7 @@ class CustomUiActivity : BaseComposeActivity() {
}),
)
InputDialog(
header = Header.Default(title = "请输入模板内容"),
header = xhuHeader(title = "请输入模板内容"),
state = rememberUseCaseState(
visible = true,
onCloseRequest = { show.hide() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.rememberMultiplePermissionsState
import com.maxkeppeker.sheets.core.models.base.Header
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.list.ListDialog
import com.maxkeppeler.sheets.list.models.ListOption
Expand Down Expand Up @@ -200,7 +199,7 @@ class ExportCalendarActivity : BaseSelectComposeActivity() {
val options = listOf(5, 10, 15, 20, 30)
if (show.showing) {
ListDialog(
header = Header.Default(title = "请选择要添加的提醒时间"),
header = xhuHeader(title = "请选择要添加的提醒时间"),
state = rememberUseCaseState(
visible = true,
onCloseRequest = { show.hide() }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import cn.jpush.android.api.JPushInterface
import com.maxkeppeker.sheets.core.models.base.Header
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.list.ListDialog
import com.maxkeppeler.sheets.list.models.ListOption
Expand Down Expand Up @@ -166,7 +165,7 @@ class JobHistoryActivity : BaseComposeActivity() {
) {
if (dialogState.showing) {
ListDialog(
header = Header.Default(title = "请选择需要添加的任务类型"),
header = xhuHeader(title = "请选择需要添加的任务类型"),
state = rememberUseCaseState(
visible = true,
onDismissRequest = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.maxkeppeker.sheets.core.models.base.Header
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.list.ListDialog
import com.maxkeppeler.sheets.list.models.ListOption
import com.maxkeppeler.sheets.list.models.ListSelection
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import vip.mystery0.xhu.timetable.base.BaseComposeActivity
import vip.mystery0.xhu.timetable.config.store.Formatter
import vip.mystery0.xhu.timetable.model.response.Poems
import vip.mystery0.xhu.timetable.trackEvent
Expand Down Expand Up @@ -149,7 +149,7 @@ val todayCourseContent: TabContent = @Composable { ext ->
poems = poems,
)

ShowAddDialog(ext.addDialogState) {
ext.activity.ShowAddDialog(ext.addDialogState) {
ext.activity.startActivity(Intent(ext.activity, it.java))
}
}
Expand Down Expand Up @@ -635,13 +635,13 @@ private fun DrawCourseCard(

@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun ShowAddDialog(
private fun BaseComposeActivity.ShowAddDialog(
dialogState: XhuDialogState,
onIntent: (KClass<*>) -> Unit,
) {
if (dialogState.showing) {
ListDialog(
header = Header.Default(title = "请选择需要添加的数据类型"),
header = xhuHeader(title = "请选择需要添加的数据类型"),
state = rememberUseCaseState(
visible = true,
onDismissRequest = {
Expand Down

0 comments on commit e891a31

Please sign in to comment.