Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
lings03 committed Jan 24, 2025
1 parent 489088b commit aa6afcd
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 96 deletions.
22 changes: 13 additions & 9 deletions app/src/main/kotlin/top/laoxin/modmanager/ui/view/Console.kt
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,10 @@ fun SettingInformationCard(uiState: ConsoleUiState) {
1 -> stringResource(id = R.string.permission, "DOCUMENT")
2 -> stringResource(id = R.string.permission, "PACKAGE_NAME")
3 -> stringResource(id = R.string.permission, "SHIZUKU")
else -> stringResource(id = R.string.permission,
stringResource(R.string.console_status_no_permission))
else -> stringResource(
id = R.string.permission,
stringResource(R.string.console_status_no_permission)
)
}
}, style = typography.labelLarge
)
Expand Down Expand Up @@ -460,20 +462,22 @@ fun ConsoleTopBar(
modifier: Modifier = Modifier,
configuration: Int
) {
TopAppBar(colors = TopAppBarDefaults.topAppBarColors(
containerColor = if (configuration == Configuration.ORIENTATION_LANDSCAPE) MaterialTheme.colorScheme.surface else MaterialTheme.colorScheme.surfaceContainer,
//titleContentColor = MaterialTheme.colorScheme.onSecondaryContainer,
//navigationIconContentColor = MaterialTheme.colorScheme.onSecondaryContainer,
), modifier = modifier,

TopAppBar(
colors = TopAppBarDefaults.topAppBarColors(
containerColor = if (configuration == Configuration.ORIENTATION_LANDSCAPE) MaterialTheme.colorScheme.surface else MaterialTheme.colorScheme.surfaceContainer,
//titleContentColor = MaterialTheme.colorScheme.onSecondaryContainer,
//navigationIconContentColor = MaterialTheme.colorScheme.onSecondaryContainer,
),
modifier = modifier,
title = {
if (configuration != Configuration.ORIENTATION_LANDSCAPE) {
Text(
stringResource(id = R.string.console), style = typography.titleLarge

)
}
}, actions = {
},
actions = {
Text(text = stringResource(R.string.console_top_bar_start_game))
IconButton(onClick = {
// 在这里处理图标按钮的点击事件
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import top.laoxin.modmanager.ui.view.modView.ModPage
import top.laoxin.modmanager.ui.view.modView.ModTopBar
import top.laoxin.modmanager.ui.viewmodel.ConsoleViewModel
import top.laoxin.modmanager.ui.viewmodel.ModViewModel
import top.laoxin.modmanager.ui.viewmodel.SettingViewModel
import kotlin.math.abs

// 导航栏索引
Expand All @@ -80,6 +81,7 @@ enum class NavigationIndex(
fun ModManagerApp() {
val modViewModel: ModViewModel = viewModel(factory = ModViewModel.Factory)
val consoleViewModel: ConsoleViewModel = viewModel(factory = ConsoleViewModel.Factory)
val settingViewModel: SettingViewModel = viewModel(factory = SettingViewModel.Factory)
val pageList = NavigationIndex.entries
val configuration = LocalConfiguration.current

Expand Down Expand Up @@ -116,6 +118,7 @@ fun ModManagerApp() {
)

NavigationIndex.SETTINGS.ordinal -> SettingTopBar(
settingViewModel,
configuration = configuration.orientation
)
}
Expand Down Expand Up @@ -216,7 +219,7 @@ fun ModManagerApp() {
when (page) {
NavigationIndex.CONSOLE.ordinal -> ConsolePage(consoleViewModel)
NavigationIndex.MOD.ordinal -> ModPage(modViewModel)
NavigationIndex.SETTINGS.ordinal -> SettingPage()
NavigationIndex.SETTINGS.ordinal -> SettingPage(settingViewModel)
}
}
}
Expand Down
73 changes: 54 additions & 19 deletions app/src/main/kotlin/top/laoxin/modmanager/ui/view/Setting.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.icons.filled.Update
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Card
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
Expand All @@ -40,7 +42,6 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import top.laoxin.modmanager.R
import top.laoxin.modmanager.bean.DownloadGameConfigBean
import top.laoxin.modmanager.bean.GameInfoBean
Expand All @@ -52,10 +53,7 @@ import top.laoxin.modmanager.ui.view.commen.RequestUriPermission
import top.laoxin.modmanager.ui.viewmodel.SettingViewModel

@Composable
fun SettingPage() {
val viewModel: SettingViewModel = viewModel(
factory = SettingViewModel.Factory
)
fun SettingPage(viewModel: SettingViewModel) {
val uiState by viewModel.uiState.collectAsState()
val context = LocalContext.current

Expand Down Expand Up @@ -444,24 +442,61 @@ fun ThinksDialogCommon(

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SettingTopBar(modifier: Modifier = Modifier, configuration: Int) {
if (configuration != Configuration.ORIENTATION_LANDSCAPE) {
TopAppBar(
modifier = modifier,
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.surfaceContainer,

),
title = {

fun SettingTopBar(
viewModel: SettingViewModel,
modifier: Modifier = Modifier,
configuration: Int
) {
val context = LocalContext.current
TopAppBar(
modifier = modifier,
colors = TopAppBarDefaults.topAppBarColors(
containerColor =
if (configuration == Configuration.ORIENTATION_LANDSCAPE) MaterialTheme.colorScheme.surface
else MaterialTheme.colorScheme.surfaceContainer,
),
title = {
if (configuration != Configuration.ORIENTATION_LANDSCAPE) {
Text(
stringResource(id = R.string.settings),
style = MaterialTheme.typography.titleLarge
)

})
}

}
},
actions = {
IconButton(
onClick = {
viewModel.openUrl(context, context.getString(R.string.github_url))
},
) {
Icon(
painter = painterResource(id = R.drawable.github_icon),
contentDescription = null,
Modifier.size(28.dp)
)
}
IconButton(onClick = {
viewModel.openUrl(context, context.getString(R.string.alipay_url))
}) {
Icon(
painter = painterResource(id = R.drawable.alipay_icon),
contentDescription = null,
Modifier.size(28.dp)
)
}
IconButton(
onClick = {
viewModel.checkUpdate()
},
) {
Icon(
imageVector = Icons.Filled.Update,
contentDescription = null,
modifier = Modifier.size(28.dp)
)
}
}
)
}

@Preview
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import android.os.Environment
import androidx.activity.compose.BackHandler
import androidx.annotation.DrawableRes
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.animateContentSize
import androidx.compose.animation.core.tween
import androidx.compose.animation.slideInHorizontally
Expand Down Expand Up @@ -109,23 +111,7 @@ fun ModsBrowser(viewModel: ModViewModel, uiState: ModUiState) {
AnimatedContent(
targetState = currentPath,
transitionSpec = {
if (targetState > initialState) {
slideInHorizontally(
initialOffsetX = { fullWidth -> fullWidth },
animationSpec = tween(durationMillis = 200)
) togetherWith slideOutHorizontally(
targetOffsetX = { fullWidth -> -fullWidth },
animationSpec = tween(durationMillis = 200)
)
} else {
slideInHorizontally(
initialOffsetX = { fullWidth -> -fullWidth },
animationSpec = tween(durationMillis = 200)
) togetherWith slideOutHorizontally(
targetOffsetX = { fullWidth -> fullWidth },
animationSpec = tween(durationMillis = 200)
)
}
EnterTransition.None togetherWith ExitTransition.None
}
) { path ->
val mods = files.flatMap { file ->
Expand All @@ -143,7 +129,6 @@ fun ModsBrowser(viewModel: ModViewModel, uiState: ModUiState) {
if (uiState.currentFiles.isEmpty() && uiState.currentMods.isEmpty()) {
NoModInDir()
} else {

LazyColumn(state = listState) {

items(files) { file: File ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import android.content.res.Configuration
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
Expand Down Expand Up @@ -99,29 +102,28 @@ fun MultiSelectTopBar(
containerColor = if (configuration == Configuration.ORIENTATION_LANDSCAPE) MaterialTheme.colorScheme.surface else MaterialTheme.colorScheme.surfaceContainer,
),
navigationIcon = {
if (uiState.modsView == NavigationIndex.MODS_BROWSER && uiState.isBackPathExist) {
if (uiState.modsView == NavigationIndex.MODS_BROWSER)
Button(
onClick = {
viewModel.setDoBackFunction(true)
},
modifier = Modifier.size(35.dp),
shape = RoundedCornerShape(8.dp),
contentPadding = PaddingValues(0.dp),
enabled = uiState.isBackPathExist,
) {
Box(
contentAlignment = Alignment.CenterStart
contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxSize()
) {
Row(
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
imageVector = Icons.Filled.ArrowBackIosNew,
contentDescription = "back",
Modifier.size(12.dp)
)
}
Icon(
imageVector = Icons.Filled.ArrowBackIosNew,
contentDescription = "back",
modifier = Modifier.size(16.dp)
)
}
}
} else {
null
}
else null
},
title = {
Box(contentAlignment = Alignment.CenterStart) {
Expand All @@ -133,18 +135,9 @@ fun MultiSelectTopBar(
Row(
modifier = Modifier.padding(top = 40.dp),
) {

/* if (uiState.modsSelected.isNotEmpty()){
Text(
text = "已选:${uiState.modsSelected.size}",
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.onPrimary,
textAlign = TextAlign.Start,
)
Spacer(modifier = Modifier.width(8.dp))
}*/
val total =
if (uiState.modsSelected.isNotEmpty()) "${uiState.modsSelected.size}/${modList.size}" else "${modList.size}"
if (uiState.modsSelected.isNotEmpty()) "${uiState.modsSelected.size}/${modList.size}"
else "${modList.size}"

Text(
text = stringResource(R.string.mod_top_bar_count, total),
Expand Down Expand Up @@ -264,29 +257,28 @@ fun GeneralTopBar(
containerColor = if (configuration == Configuration.ORIENTATION_LANDSCAPE) MaterialTheme.colorScheme.surface else MaterialTheme.colorScheme.surfaceContainer,
),
navigationIcon = {
if (uiState.modsView == NavigationIndex.MODS_BROWSER && uiState.isBackPathExist) {
if (uiState.modsView == NavigationIndex.MODS_BROWSER)
Button(
onClick = {
viewModel.setDoBackFunction(true)
},
modifier = Modifier.size(35.dp),
shape = RoundedCornerShape(8.dp),
contentPadding = PaddingValues(0.dp),
enabled = uiState.isBackPathExist,
) {
Box(
contentAlignment = Alignment.CenterStart
contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxSize()
) {
Row(
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
imageVector = Icons.Filled.ArrowBackIosNew,
contentDescription = "back",
Modifier.size(12.dp)
)
}
Icon(
imageVector = Icons.Filled.ArrowBackIosNew,
contentDescription = "back",
modifier = Modifier.size(16.dp)
)
}
}
} else {
null
}
else null
},
title = {
Box(contentAlignment = Alignment.CenterStart) {
Expand Down Expand Up @@ -315,16 +307,6 @@ fun GeneralTopBar(

},
actions = {
// IconButton(onClick = {
// // 在这里处理图标按钮的点击事件
// viewModel.setUserTipsDialog(true)
// }) {
// Icon(
// imageVector = Icons.Default.Info, // 使用信息图标
// contentDescription = "Info", // 为辅助功能提供描述
// //tint = MaterialTheme.colorScheme.primaryContainer
// )
// }
IconButton(onClick = {
viewModel.setSearchBoxVisible(true)
when (uiState.modsView) {
Expand Down

0 comments on commit aa6afcd

Please sign in to comment.