Skip to content

Commit

Permalink
switch to using tabs and 1 main setting button
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Jan 9, 2023
1 parent 3555227 commit 15b568d
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 81 deletions.
3 changes: 3 additions & 0 deletions src/main/kotlin/com/mineinabyss/launchy/data/Typealiases.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.mineinabyss.launchy.data

import androidx.compose.runtime.Composable

typealias ModName = String
typealias GroupName = String
typealias DownloadURL = String
typealias ConfigURL = String
typealias ComposableFun = @Composable () -> Unit
18 changes: 11 additions & 7 deletions src/main/kotlin/com/mineinabyss/launchy/ui/TopBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import androidx.compose.animation.slideOut
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.window.WindowDraggableArea
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.*
import androidx.compose.material.icons.outlined.ManageAccounts
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material.icons.outlined.SettingsApplications
import androidx.compose.material.icons.rounded.ArrowBack
import androidx.compose.material.icons.rounded.Close
import androidx.compose.material.icons.rounded.CropSquare
import androidx.compose.material.icons.rounded.Minimize
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -66,13 +72,11 @@ fun TabIconBar(
Row(
Modifier.weight(1f),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center
) {
// TabIconButton("Accounts", Icons.Rounded.ManageAccounts) {
// Screen.Account
// }

TabIconButton("Mods", Icons.Rounded.Settings) { screen = Screen.Mods }

TabIconButton("Accounts", Icons.Outlined.ManageAccounts) { screen = Screen.Account }
TabIconButton("Java", Icons.Outlined.SettingsApplications) { screen = Screen.Java }
TabIconButton("Mods", Icons.Outlined.Settings) { screen = Screen.Mods }
}
Row {

Expand Down
24 changes: 13 additions & 11 deletions src/main/kotlin/com/mineinabyss/launchy/ui/screens/Screens.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import com.mineinabyss.launchy.data.ComposableFun
import com.mineinabyss.launchy.ui.AppTopBar
import com.mineinabyss.launchy.ui.screens.main.MainScreen
import com.mineinabyss.launchy.ui.screens.settings.AccountScreen
import com.mineinabyss.launchy.ui.screens.settings.JavaScreen
import com.mineinabyss.launchy.ui.screens.settings.ModsScreen
import com.mineinabyss.launchy.ui.screens.settings.Tabs
import com.mineinabyss.launchy.ui.state.TopBar

sealed class Screen(val transparentTopBar: Boolean = false) {
object Default : Screen(transparentTopBar = true)
object Java : Screen()
object Mods : Screen()
object Account : Screen()
object Settings : Screen()
Expand All @@ -35,14 +38,13 @@ fun Screens() {
}

TranslucentTopBar(screen) {
TransitionSlideUp(screen == Screen.Mods) {
ModsScreen()
}
}

TranslucentTopBar(screen) {
TransitionSlideUp(screen == Screen.Account) {
AccountScreen()
TransitionSlideUp(screen != Screen.Default) {
when (screen) {
Screen.Account -> AccountScreen()
Screen.Java -> JavaScreen()
Screen.Mods -> ModsScreen()
else -> {}
}
Tabs()
}
}
Expand All @@ -56,7 +58,7 @@ fun Screens() {
}

@Composable
fun TranslucentTopBar(currentScreen: Screen, content: @Composable () -> Unit) {
fun TranslucentTopBar(currentScreen: Screen, content: ComposableFun) {
Column {
AnimatedVisibility(!currentScreen.transparentTopBar, enter = fadeIn(), exit = fadeOut()) {
Spacer(Modifier.height(40.dp))
Expand All @@ -66,14 +68,14 @@ fun TranslucentTopBar(currentScreen: Screen, content: @Composable () -> Unit) {
}

@Composable
fun TransitionFade(enabled: Boolean, content: @Composable () -> Unit) {
fun TransitionFade(enabled: Boolean, content: ComposableFun) {
AnimatedVisibility(enabled, enter = fadeIn(), exit = fadeOut()) {
content()
}
}

@Composable
fun TransitionSlideUp(enabled: Boolean, content: @Composable () -> Unit) {
fun TransitionSlideUp(enabled: Boolean, content: ComposableFun) {
AnimatedVisibility(
enabled,
enter = fadeIn() + slideIn(initialOffset = { IntOffset(0, 100) }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.mineinabyss.launchy.LocalLaunchyState
import com.mineinabyss.launchy.ui.screens.main.buttons.AccountButton
import com.mineinabyss.launchy.ui.screens.main.buttons.InstallButton
import com.mineinabyss.launchy.ui.screens.main.buttons.ModsButton
import com.mineinabyss.launchy.ui.screens.main.buttons.PlayButton
import com.mineinabyss.launchy.ui.screens.main.buttons.SettingsButton
import com.mineinabyss.launchy.ui.state.windowScope

val showComingSoonDialog = mutableStateOf(false)
Expand Down Expand Up @@ -49,11 +48,7 @@ fun MainScreen() {
UpdateInfoButton()
}
Spacer(Modifier.width(10.dp))
// NewsButton(hasUpdates = true)
// Spacer(Modifier.width(10.dp))
ModsButton()
Spacer(Modifier.width(10.dp))
AccountButton()
SettingsButton(!state.isDownloading && state.operationsQueued && state.minecraftValid)
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import com.mineinabyss.launchy.ui.screens.Screen
import com.mineinabyss.launchy.ui.screens.screen

@Composable
fun ModsButton() {
Button(onClick = { screen = Screen.Mods }) {
Icon(Icons.Rounded.Settings, contentDescription = "Mods")
Text("Mods")
fun SettingsButton(enabled: Boolean) {
Button(enabled = enabled, onClick = { screen = Screen.Settings }) {
Icon(Icons.Rounded.Settings, contentDescription = "Settings")
Text("Settings")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,24 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.dp
import com.mineinabyss.launchy.LocalLaunchyState
import com.mineinabyss.launchy.ui.screens.main.buttons.LoginMicrosoftButton

@Composable
@Preview
fun AccountScreen() {
val state = LocalLaunchyState
Scaffold(
bottomBar = { InfoBar() },
) { paddingValues ->
Scaffold { paddingValues ->
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Surface(
shape = RoundedCornerShape(topStart = 10.dp, topEnd = 10.dp),
modifier = Modifier.padding(5.dp)
) {
Box(
Modifier.padding(paddingValues).padding(start = 10.dp, top = 5.dp)
Modifier.padding(paddingValues).padding(start = 10.dp, top = 40.dp)
) {
val lazyListState = rememberLazyListState()
LazyColumn(Modifier.fillMaxSize().padding(end = 12.dp), lazyListState) {
item("settings") {

item("account settings") {
LoginMicrosoftButton(true)
/*TextField(
"Account Name",
"Enter Player Name",
icon = Icons.Rounded.SupervisorAccount
)
TextField(
"Password",
"Enter Password",
KeyboardOptions(keyboardType = KeyboardType.Password),
Icons.Rounded.Password
)*/

Spacer(Modifier.height(10.dp))
SettingGroup()
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import kotlinx.serialization.Serializable
import kotlin.math.roundToInt

@Composable
fun SettingGroup() {
fun JavaGroup() {
var expanded by remember { mutableStateOf(false) }
val arrowRotationState by animateFloatAsState(targetValue = if (expanded) 180f else 0f)
val state = LocalLaunchyState
Expand All @@ -40,7 +40,7 @@ fun SettingGroup() {
Spacer(Modifier.width(10.dp))
Text("Settings", Modifier.weight(1f), style = MaterialTheme.typography.bodyLarge,)
Spacer(Modifier.width(10.dp))
Icon(Icons.Rounded.ArrowDropDown, "Show settings", Modifier.rotate(arrowRotationState))
Icon(Icons.Rounded.ArrowDropDown, "Show Java Settings", Modifier.rotate(arrowRotationState))
Spacer(Modifier.width(10.dp))
}
AnimatedVisibility(expanded) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.mineinabyss.launchy.ui.screens.settings

import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.foundation.VerticalScrollbar
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.rememberScrollbarAdapter
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.mineinabyss.launchy.LocalLaunchyState
import kotlin.math.roundToInt

@Composable
@Preview
fun JavaScreen() {
val state = LocalLaunchyState
Scaffold { paddingValues ->
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Surface(
shape = RoundedCornerShape(topStart = 10.dp, topEnd = 10.dp),
modifier = Modifier.padding(5.dp)
) {
Box(
Modifier.padding(paddingValues).padding(start = 10.dp, top = 40.dp)
) {
val lazyListState = rememberLazyListState()
LazyColumn(Modifier.fillMaxSize().padding(end = 12.dp), lazyListState) {
item("java settings") {
val minRam = SliderSwitch(label = "Minimum RAM", valueRange = 1..12).roundToInt()
val maxRam = SliderSwitch(label = "Maximum RAM:", valueRange = 1..12).roundToInt()
// Figure out way to handle this, probably storing via state or something
state.clientSettings = ClientSettings(state.clientSettings.minecraft, JavaSettings(minRam, maxRam))
}
}
VerticalScrollbar(
modifier = Modifier.fillMaxHeight().align(Alignment.CenterEnd),
adapter = rememberScrollbarAdapter(lazyListState)
)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fun ModsScreen() {
) {
Box(
Modifier.padding(paddingValues)
.padding(start = 10.dp, top = 5.dp)
.padding(start = 10.dp, top = 40.dp)
) {
val lazyListState = rememberLazyListState()
LazyColumn(Modifier.fillMaxSize().padding(end = 12.dp), lazyListState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,12 @@ package com.mineinabyss.launchy.ui.screens.settings
import androidx.compose.runtime.Composable
import com.mineinabyss.launchy.ui.TabIconBar
import com.mineinabyss.launchy.ui.screens.Screen
import com.mineinabyss.launchy.ui.screens.TransitionSlideUp
import com.mineinabyss.launchy.ui.screens.TranslucentTopBar
import com.mineinabyss.launchy.ui.screens.screen
import com.mineinabyss.launchy.ui.state.TopBar

@Composable
fun Tabs() {

TranslucentTopBar(screen) {
TransitionSlideUp(screen == Screen.Account) {
AccountScreen()
}
}

TabIconBar(
TopBar,
screen.transparentTopBar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.mineinabyss.launchy.LocalLaunchyState
import com.mineinabyss.launchy.data.ComposableFun
import com.mineinabyss.launchy.data.Group
import com.mineinabyss.launchy.data.Mod
import com.mineinabyss.launchy.util.Option
Expand Down Expand Up @@ -101,7 +102,7 @@ fun TripleSwitchButton(
onSwitch: (Option) -> Unit,
enabled: Boolean = true,
modifier: Modifier = Modifier,
content: @Composable () -> Unit,
content: ComposableFun,
) {
Button(
enabled = enabled,
Expand Down

0 comments on commit 15b568d

Please sign in to comment.