Skip to content

Commit 5fb4786

Browse files
Add glassmorphism UI system and SheleeSpace-inspired layout
1 parent 3a06241 commit 5fb4786

3 files changed

Lines changed: 49 additions & 23 deletions

File tree

‎app/src/main/java/com/joebuildsthings/gamedeck/OverlayLifecycleOwner.kt‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ import androidx.savedstate.SavedStateRegistry
99
import androidx.savedstate.SavedStateRegistryController
1010
import androidx.savedstate.SavedStateRegistryOwner
1111

12-
/**
13-
* A ComposeView normally finds its lifecycle, saved state and view model owners
14-
* from an Activity. A Service has none of these, so Compose throws
15-
* "ViewTreeLifecycleOwner not found" the moment the view attaches to the window.
16-
* This class stands in for the Activity and is attached to the overlay view
17-
* before it is added to the WindowManager.
18-
*/
1912
class OverlayLifecycleOwner : LifecycleOwner, ViewModelStoreOwner, SavedStateRegistryOwner {
2013

2114
private val lifecycleRegistry = LifecycleRegistry(this)

‎app/src/main/java/com/joebuildsthings/gamedeck/OverlayService.kt‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import androidx.compose.material3.Text
2424
import androidx.compose.runtime.Composable
2525
import androidx.compose.ui.Modifier
2626
import androidx.compose.ui.draw.clip
27+
import androidx.compose.ui.graphics.Color
2728
import androidx.compose.ui.platform.ComposeView
2829
import androidx.compose.ui.platform.ViewCompositionStrategy
2930
import androidx.compose.ui.text.font.FontWeight
@@ -36,7 +37,6 @@ import androidx.lifecycle.setViewTreeViewModelStoreOwner
3637
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
3738
import com.joebuildsthings.gamedeck.ui.theme.AccentRed
3839
import com.joebuildsthings.gamedeck.ui.theme.AccentRedBright
39-
import com.joebuildsthings.gamedeck.ui.theme.AccentRedDim
4040
import com.joebuildsthings.gamedeck.ui.theme.GameDeckTheme
4141

4242
class OverlayService : Service() {
@@ -132,26 +132,21 @@ class OverlayService : Service() {
132132
}
133133
layoutParams = params
134134

135-
// 1. Create the lifecycle owner for our overlay
136135
val owner = OverlayLifecycleOwner()
137136
lifecycleOwner = owner
138137

139-
// 2. Create the ComposeView
140138
val composeView = ComposeView(this).apply {
141139
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnDetachedFromWindow)
142-
setContent { GameDeckTheme { Pill() } }
140+
setContent { GameDeckTheme { GlassPill() } }
143141
}
144142

145-
// 3. Create a plain View wrapper (FrameLayout) that will be the window's root
146143
val wrapper = TouchInterceptor(this).apply {
147-
// 4. IMPORTANT: Attach the lifecycle owners to the WRAPPER, not the ComposeView
148144
setViewTreeLifecycleOwner(owner)
149145
setViewTreeViewModelStoreOwner(owner)
150146
setViewTreeSavedStateRegistryOwner(owner)
151147
addView(composeView)
152148
}
153149

154-
// 5. Set touch listener on the wrapper for dragging
155150
var initialX = 0
156151
var initialY = 0
157152
var touchX = 0f
@@ -176,7 +171,6 @@ class OverlayService : Service() {
176171
}
177172

178173
owner.start()
179-
// 6. Add the WRAPPER to the WindowManager
180174
windowManager?.addView(wrapper, params)
181175
overlayView = wrapper
182176
}
@@ -190,18 +184,18 @@ class OverlayService : Service() {
190184
}
191185

192186
@Composable
193-
private fun Pill() {
187+
private fun GlassPill() {
194188
Box(
195189
Modifier
196-
.clip(RoundedCornerShape(20.dp))
197-
.background(AccentRedDim)
198-
.border(1.dp, AccentRed, RoundedCornerShape(20.dp))
199-
.padding(horizontal = 14.dp, vertical = 7.dp)
190+
.clip(RoundedCornerShape(50))
191+
.background(Color(0x33FFFFFF))
192+
.border(1.dp, Color(0x55FFFFFF), RoundedCornerShape(50))
193+
.padding(horizontal = 18.dp, vertical = 10.dp)
200194
) {
201195
Text(
202-
"-- FPS",
203-
color = AccentRedBright,
204-
fontSize = 12.sp,
196+
"60 FPS",
197+
color = Color.White,
198+
fontSize = 13.sp,
205199
fontWeight = FontWeight.SemiBold,
206200
letterSpacing = 1.sp
207201
)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.joebuildsthings.gamedeck.ui.theme
2+
3+
import androidx.compose.foundation.background
4+
import androidx.compose.foundation.border
5+
import androidx.compose.foundation.layout.*
6+
import androidx.compose.foundation.shape.RoundedCornerShape
7+
import androidx.compose.material3.*
8+
import androidx.compose.runtime.Composable
9+
import androidx.compose.ui.Modifier
10+
import androidx.compose.ui.draw.clip
11+
import androidx.compose.ui.graphics.Color
12+
import androidx.compose.ui.unit.dp
13+
14+
val GlassWhite = Color(0x1AFFFFFF)
15+
val GlassBorder = Color(0x33FFFFFF)
16+
val GlassDark = Color(0x33000000)
17+
val GlassAccent = Color(0x33EF4444)
18+
19+
@Composable
20+
fun GlassCard(
21+
modifier: Modifier = Modifier,
22+
accent: Color = GlassAccent,
23+
content: @Composable ColumnScope.() -> Unit
24+
) {
25+
Surface(
26+
modifier = modifier,
27+
shape = RoundedCornerShape(20.dp),
28+
color = Color.Transparent,
29+
) {
30+
Column(
31+
modifier = Modifier
32+
.clip(RoundedCornerShape(20.dp))
33+
.background(GlassWhite)
34+
.border(1.dp, GlassBorder, RoundedCornerShape(20.dp))
35+
.padding(16.dp),
36+
content = content
37+
)
38+
}
39+
}

0 commit comments

Comments
 (0)