11
2+ import androidx.compose.foundation.border
3+ import androidx.compose.foundation.clickable
4+ import androidx.compose.foundation.layout.Box
5+ import androidx.compose.foundation.layout.Column
6+ import androidx.compose.foundation.layout.fillMaxSize
7+ import androidx.compose.foundation.layout.fillMaxWidth
8+ import androidx.compose.foundation.layout.height
9+ import androidx.compose.foundation.layout.padding
10+ import androidx.compose.foundation.shape.RoundedCornerShape
11+ import androidx.compose.foundation.window.WindowDraggableArea
12+ import androidx.compose.material.Icon
13+ import androidx.compose.material.Text
14+ import androidx.compose.material.TopAppBar
15+ import androidx.compose.material.icons.Icons
16+ import androidx.compose.material.icons.rounded.Close
17+ import androidx.compose.material.icons.rounded.KeyboardArrowDown
18+ import androidx.compose.runtime.Composable
219import androidx.compose.ui.Alignment
20+ import androidx.compose.ui.Modifier
21+ import androidx.compose.ui.draw.clip
22+ import androidx.compose.ui.graphics.Color
23+ import androidx.compose.ui.text.font.FontWeight
24+ import androidx.compose.ui.text.style.TextAlign
325import androidx.compose.ui.unit.dp
426import androidx.compose.ui.window.Window
527import androidx.compose.ui.window.WindowPosition
28+ import androidx.compose.ui.window.WindowScope
629import androidx.compose.ui.window.WindowState
730import androidx.compose.ui.window.application
31+ import theme.TextFieldBackground
832
933fun main () = application {
1034 val windowState = WindowState (
11- width = 1280 .dp,
35+ width = 1280 .dp,
1236 height = 720 .dp,
1337 position = WindowPosition (Alignment .Center )
1438 )
@@ -17,7 +41,53 @@ fun main() = application {
1741 title = " String Translator Desktop App" ,
1842 state = windowState,
1943 resizable = false ,
44+ undecorated = true
2045 ) {
21- App ()
46+ Column (Modifier .fillMaxSize()
47+ .border(width = 2 .dp, color = TextFieldBackground , shape = RoundedCornerShape (2 .dp))
48+ .clip(RoundedCornerShape (bottomStart = 120 .dp, bottomEnd = 120 .dp))) {
49+ AppWindowTitleBar (windowState) { exitApplication() }
50+ App ()
51+ }
52+ }
53+ }
54+
55+ @Composable
56+ private fun WindowScope.AppWindowTitleBar (state : WindowState , onClose : () -> Unit ) =
57+ WindowDraggableArea {
58+ Box (
59+ Modifier .fillMaxWidth()
60+ .height(48 .dp)
61+ .padding(horizontal = 16 .dp),
62+ contentAlignment = Alignment .CenterEnd
63+ ) {
64+ TopAppBar (
65+ title = {
66+ Text (
67+ " String Translator Desktop App" ,
68+ textAlign = TextAlign .Center ,
69+ fontWeight = FontWeight .Bold ,
70+ modifier = Modifier .fillMaxWidth()
71+ )
72+ },
73+ contentColor = Color .White ,
74+ backgroundColor = TextFieldBackground ,
75+ modifier = Modifier .fillMaxSize().padding(horizontal = 160 .dp)
76+ .clip(RoundedCornerShape (bottomStart = 100 .dp, bottomEnd = 100 .dp))
77+ )
78+
79+ Icon (
80+ imageVector = Icons .Rounded .KeyboardArrowDown ,
81+ contentDescription = " Minimise" ,
82+ tint = TextFieldBackground ,
83+ modifier = Modifier .padding(end = 32 .dp).clickable { state.isMinimized = true }
84+ )
85+
86+ Icon (
87+ imageVector = Icons .Rounded .Close ,
88+ contentDescription = " Close" ,
89+ tint = TextFieldBackground ,
90+ modifier = Modifier .padding(start = 8 .dp).clickable { onClose() }
91+ )
92+ }
2293 }
23- }
0 commit comments