Skip to content

Commit 562e561

Browse files
committed
🌟 add full screen mode and improve master-detail screen
1 parent ae63506 commit 562e561

19 files changed

Lines changed: 208 additions & 110 deletions

File tree

‎.idea/codeStyles/Project.xml‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/runConfigurations.xml‎

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎data/src/main/kotlin/com/theapache64/stackzy/data/local/AlphabetCircle.kt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ abstract class BaseAlphabetCircle {
88
abstract fun imageUrl(): String?
99
open fun getAlphabet() = getTitle().first()
1010
open fun isNew(): Boolean = false
11+
abstract fun isActive(): Boolean
1112
}

‎src/main/kotlin/com/theapache64/stackzy/model/AndroidAppWrapper.kt‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
package com.theapache64.stackzy.model
22

3+
import androidx.compose.runtime.getValue
4+
import androidx.compose.runtime.mutableStateOf
5+
import androidx.compose.runtime.setValue
36
import com.theapache64.stackzy.data.local.AndroidApp
47
import com.theapache64.stackzy.data.local.AndroidAppDefinition
58
import java.util.*
69

710
class AndroidAppWrapper(
811
val androidApp: AndroidApp,
9-
val shouldUseVersionNameAsSubTitle: Boolean = false
12+
val shouldUseVersionNameAsSubTitle: Boolean = false,
1013
) : AndroidAppDefinition by androidApp, AlphabetCircle() {
14+
15+
var isAppActive by mutableStateOf(false)
16+
1117
companion object {
1218
/**
1319
* Remove these keywords when to GUESS app name from package name
@@ -45,4 +51,8 @@ class AndroidAppWrapper(
4551
override fun getAlphabet(): Char {
4652
return getTitle().first()
4753
}
54+
55+
override fun isActive(): Boolean {
56+
return isAppActive
57+
}
4858
}

‎src/main/kotlin/com/theapache64/stackzy/model/AndroidDeviceWrapper.kt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ class AndroidDeviceWrapper(
1010
override fun getTitle() = model
1111
override fun getSubtitle() = name
1212
override fun imageUrl(): String? = null
13+
override fun isActive(): Boolean = false
1314
}

‎src/main/kotlin/com/theapache64/stackzy/model/LibraryWrapper.kt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ class LibraryWrapper(
3131
override fun isNew(): Boolean {
3232
return isNewLib
3333
}
34+
35+
override fun isActive(): Boolean = false
3436
}

‎src/main/kotlin/com/theapache64/stackzy/ui/common/Selectable.kt‎

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import androidx.compose.ui.text.font.FontWeight
1919
import androidx.compose.ui.text.style.TextOverflow
2020
import androidx.compose.ui.unit.Dp
2121
import androidx.compose.ui.unit.dp
22-
import androidx.compose.ui.unit.sp
2322
import androidx.compose.ui.window.Window
2423
import androidx.compose.ui.window.application
2524
import androidx.compose.ui.window.singleWindowApplication
@@ -41,10 +40,11 @@ fun Modifier.addHoverEffect(
4140
normalColor: Color = MaterialTheme.colors.secondary,
4241
normalAlpha: Float = 0f,
4342
hoverAlpha: Float = 0.8f,
44-
cornerRadius: Dp = 5.dp
43+
cornerRadius: Dp = 5.dp,
44+
isActive: Boolean = false,
4545
): Modifier {
4646
var isHovered by remember { mutableStateOf(false) }
47-
val backgroundAlpha = if (isHovered) {
47+
val backgroundAlpha = if (isHovered || isActive) {
4848
hoverAlpha
4949
} else {
5050
normalAlpha
@@ -82,6 +82,10 @@ fun main() = application {
8282
override fun getSubtitle() = "v1.0.0"
8383
override fun imageUrl() =
8484
"https://play-lh.googleusercontent.com/X64En0aW6jkvDnd5kr16u-YuUsoJ1W2cBzJab3CQ5lObLeQ3T61DpB7AwIoZ7uqgCn4"
85+
86+
override fun isActive(): Boolean {
87+
TODO("Not yet implemented")
88+
}
8589
},
8690
onSelected = {
8791

@@ -118,42 +122,39 @@ fun <T : AlphabetCircle> Selectable(
118122
data: T,
119123
onSelected: (T) -> Unit,
120124
modifier: Modifier = Modifier,
121-
isCompact: Boolean = false,
122-
padding: Dp = if (isCompact) {
123-
5.dp
124-
} else {
125-
10.dp
126-
}
125+
isCopyableTitle: Boolean = false,
127126
) {
127+
val iconSize = 60.dp
128128
Row(
129129
modifier = modifier
130130
.fillMaxWidth()
131131
.addHoverEffect(
132132
onClicked = {
133133
onSelected(data)
134-
}
134+
},
135+
isActive = data.isActive()
135136
)
136-
.padding(padding),
137+
.padding(10.dp),
137138
verticalAlignment = Alignment.CenterVertically
138139
) {
139140

140141
if (data.imageUrl() == null) {
141142
// Show only alphabet
142-
AlphabetCircle(data = data, isCompact = isCompact)
143+
AlphabetCircle(data = data, iconSize)
143144
} else {
144145
// Show alphabet then image
145146
KamelImage(
146147
resource = lazyPainterResource(data.imageUrl()!!),
147148
contentScale = ContentScale.FillBounds,
148149
contentDescription = "app logo",
149150
onLoading = {
150-
AlphabetCircle(data = data, isCompact = isCompact)
151+
AlphabetCircle(data = data, iconSize)
151152
},
152153
onFailure = {
153-
AlphabetCircle(data = data, isCompact = isCompact)
154+
AlphabetCircle(data = data, iconSize)
154155
},
155156

156-
modifier = Modifier.size(if (isCompact) 30.dp else 60.dp)
157+
modifier = Modifier.size(iconSize)
157158
.clip(CircleShape)
158159
.background(MaterialTheme.colors.primary) // outer blue
159160
.padding(2.dp)
@@ -171,29 +172,22 @@ fun <T : AlphabetCircle> Selectable(
171172
Column {
172173

173174
// App Title
174-
SelectionContainer {
175-
Text(
176-
text = data.getTitle(),
177-
maxLines = 1,
178-
style = if (isCompact) MaterialTheme.typography.body2 else MaterialTheme.typography.body1,
179-
overflow = TextOverflow.Ellipsis
180-
)
175+
if (isCopyableTitle) {
176+
SelectionContainer {
177+
Title(data.getTitle())
178+
}
179+
} else {
180+
Title(data.getTitle())
181181
}
182182

183183
// Subtitle
184-
SelectionContainer {
185-
Text(
186-
text = data.getSubtitle(),
187-
maxLines = 1,
188-
style = if (isCompact) {
189-
MaterialTheme.typography.body2.copy(fontSize = 10.sp)
190-
} else {
191-
MaterialTheme.typography.body2
192-
},
193-
overflow = TextOverflow.Ellipsis,
194-
color = MaterialTheme.colors.onSurface.copy(alpha = 0.5f)
195-
)
196-
}
184+
Text(
185+
text = data.getSubtitle(),
186+
maxLines = 1,
187+
style = MaterialTheme.typography.body2,
188+
overflow = TextOverflow.Ellipsis,
189+
color = MaterialTheme.colors.onSurface.copy(alpha = 0.5f)
190+
)
197191

198192
// Subtitle 2
199193
data.getSubtitle2()?.let { subTitle2 ->
@@ -218,22 +212,31 @@ fun <T : AlphabetCircle> Selectable(
218212
}
219213
}
220214

215+
@Composable
216+
private fun Title(title: String) {
217+
Text(
218+
text = title,
219+
maxLines = 1,
220+
style = MaterialTheme.typography.body1,
221+
overflow = TextOverflow.Ellipsis
222+
)
223+
}
224+
221225
@Composable
222226
fun LabelNew() {
223227

224228
}
225229

226230
@Composable
227-
private fun <T : AlphabetCircle> AlphabetCircle(data: T, isCompact: Boolean) {
231+
private fun <T : AlphabetCircle> AlphabetCircle(
232+
data: T,
233+
iconSize: Dp,
234+
) {
228235
AlphabetCircle(
229236
character = data.getAlphabet(),
230237
color = data.getGradientColor(),
231-
modifier = Modifier.size(if (isCompact) 30.dp else 60.dp),
238+
modifier = Modifier.size(iconSize),
232239
isNew = data.isNew(),
233-
textStyle = if (isCompact) {
234-
MaterialTheme.typography.subtitle1.copy(fontWeight = FontWeight.Bold)
235-
} else {
236-
MaterialTheme.typography.h5.copy(fontWeight = FontWeight.Bold)
237-
}
240+
textStyle = MaterialTheme.typography.h5.copy(fontWeight = FontWeight.Bold)
238241
)
239242
}

‎src/main/kotlin/com/theapache64/stackzy/ui/common/loading/funfact/FunFact.kt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import androidx.compose.runtime.*
88
import androidx.compose.ui.Alignment
99
import androidx.compose.ui.Modifier
1010
import androidx.compose.ui.text.font.FontStyle
11+
import androidx.compose.ui.text.style.TextAlign
1112
import androidx.compose.ui.unit.sp
1213
import androidx.compose.ui.window.singleWindowApplication
1314
import com.theapache64.stackzy.data.remote.FunFact
@@ -39,7 +40,8 @@ fun FunFact(
3940
text = "\"${currentFunFact.funFact}\"",
4041
fontStyle = FontStyle.Italic,
4142
color = MaterialTheme.colors.onSurface.copy(alpha = 0.5f),
42-
fontSize = 15.sp
43+
fontSize = 15.sp,
44+
textAlign = TextAlign.Center
4345
)
4446

4547
if (!isClicked) {

‎src/main/kotlin/com/theapache64/stackzy/ui/common/loading/funfact/FunFactViewModel.kt‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎src/main/kotlin/com/theapache64/stackzy/ui/feature/MainActivity.kt‎

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
package com.theapache64.stackzy.ui.feature
22

3+
import androidx.compose.foundation.layout.Column
4+
import androidx.compose.foundation.layout.Spacer
5+
import androidx.compose.foundation.layout.height
6+
import androidx.compose.material.MaterialTheme
7+
import androidx.compose.material.Text
8+
import androidx.compose.ui.Alignment
9+
import androidx.compose.ui.Modifier
310
import androidx.compose.ui.res.painterResource
411
import androidx.compose.ui.unit.dp
12+
import androidx.compose.ui.window.Window
513
import androidx.compose.ui.window.application
614
import androidx.compose.ui.window.rememberWindowState
715
import com.arkivanov.decompose.DefaultComponentContext
@@ -12,10 +20,12 @@ import com.theapache64.stackzy.App
1220
import com.theapache64.stackzy.ui.navigation.NavHostComponent
1321
import com.theapache64.stackzy.ui.theme.R
1422
import com.theapache64.stackzy.ui.theme.StackzyTheme
23+
import com.theapache64.stackzy.util.OSType
24+
import com.theapache64.stackzy.util.OsCheck
1525
import java.awt.Taskbar
26+
import java.awt.Toolkit
1627
import java.awt.image.BufferedImage
1728
import javax.imageio.ImageIO
18-
import androidx.compose.ui.window.Window as setContent
1929

2030

2131
class MainActivity : Activity() {
@@ -43,21 +53,50 @@ class MainActivity : Activity() {
4353
val root = NavHostComponent(DefaultComponentContext(lifecycle))
4454

4555
application {
46-
setContent(
56+
57+
val title = "${App.appArgs.appName} (${App.appArgs.version})"
58+
59+
val screenSize = Toolkit.getDefaultToolkit().screenSize
60+
61+
Window(
4762
onCloseRequest = ::exitApplication,
48-
title = "${App.appArgs.appName} (${App.appArgs.version})",
63+
title = if (OsCheck.operatingSystemType != OSType.MacOS) {
64+
title
65+
} else {
66+
""
67+
},
4968
icon = painterResource(R.drawables.appIcon),
5069
state = rememberWindowState(
51-
width = 1224.dp,
52-
height = 800.dp
70+
width = (screenSize.width * 0.9).dp,
71+
height = (screenSize.height * 0.8).dp
5372
),
5473
) {
74+
75+
if (OsCheck.operatingSystemType == OSType.MacOS) {
76+
window.rootPane.apply {
77+
rootPane.putClientProperty("apple.awt.fullWindowContent", true)
78+
rootPane.putClientProperty("apple.awt.transparentTitleBar", true)
79+
}
80+
}
81+
5582
StackzyTheme {
56-
// Igniting navigation
57-
root.render()
83+
if (OsCheck.operatingSystemType == OSType.MacOS) {
84+
Column(horizontalAlignment = Alignment.CenterHorizontally) {
85+
Spacer(modifier = Modifier.height(10.dp))
86+
Text(text = title, style = MaterialTheme.typography.subtitle1)
87+
88+
// Igniting navigation
89+
root.render()
90+
}
91+
} else {
92+
// Igniting navigation
93+
root.render()
94+
}
5895
}
5996
}
6097
}
98+
99+
61100
}
62101
}
63102

0 commit comments

Comments
 (0)