@@ -6,6 +6,7 @@ import android.os.Build
66import android.os.Environment
77import android.provider.MediaStore
88import android.widget.Toast
9+ import androidx.compose.animation.core.*
910import androidx.compose.foundation.background
1011import androidx.compose.foundation.border
1112import androidx.compose.foundation.clickable
@@ -66,33 +67,34 @@ fun GalleryScreen(
6667 Column (modifier = Modifier .padding(start = 24 .dp, end = 24 .dp, top = 8 .dp, bottom = 20 .dp)) {
6768 Text (
6869 text = t.header_gallery,
69- fontFamily = FontFamily .Monospace ,
70- fontWeight = FontWeight .Bold ,
71- fontSize = 28 .sp,
72- color = Color .White
70+ fontFamily = FontFamily .Monospace ,
71+ fontWeight = FontWeight .Bold ,
72+ fontSize = 28 .sp,
73+ color = Color .White
7374 )
7475 Text (
7576 text = t.sub_gallery,
76- fontSize = 13 .sp,
77- color = theme.mutedColor(),
78- modifier = Modifier .padding(top = 2 .dp)
77+ fontSize = 13 .sp,
78+ color = theme.mutedColor(),
79+ modifier = Modifier .padding(top = 2 .dp)
7980 )
8081 }
8182
8283 when {
83- loading -> Box (
84- modifier = Modifier .fillMaxSize(),
85- contentAlignment = Alignment .Center
86- ) {
84+ loading -> Box (modifier = Modifier .fillMaxSize(), contentAlignment = Alignment .Center ) {
8785 Column (horizontalAlignment = Alignment .CenterHorizontally ) {
88- CircularProgressIndicator (color = theme.primaryColor(), modifier = Modifier .size(48 .dp))
86+ CircularProgressIndicator (
87+ color = theme.primaryColor(),
88+ modifier = Modifier .size(48 .dp)
89+ )
8990 Spacer (Modifier .height(16 .dp))
9091 val infiniteTransition = rememberInfiniteTransition(label = " pulse" )
9192 val alpha by infiniteTransition.animateFloat(
92- initialValue = 0.3f , targetValue = 1f ,
93+ initialValue = 0.3f ,
94+ targetValue = 1f ,
9395 animationSpec = infiniteRepeatable(
94- androidx.compose. animation.core. tween(800 ),
95- RepeatMode .Reverse
96+ animation = tween(800 ),
97+ repeatMode = RepeatMode .Reverse
9698 ),
9799 label = " alpha"
98100 )
@@ -106,78 +108,74 @@ fun GalleryScreen(
106108 }
107109 error -> Box (
108110 modifier = Modifier .fillMaxSize().padding(32 .dp),
109- contentAlignment = Alignment .Center
111+ contentAlignment = Alignment .Center
110112 ) {
111113 Column (horizontalAlignment = Alignment .CenterHorizontally ) {
112- Surface (
113- shape = CircleShape ,
114- color = Color (0xFFEF4444 ).copy(alpha = 0.1f )
115- ) {
114+ Surface (shape = CircleShape , color = Color (0xFFEF4444 ).copy(alpha = 0.1f )) {
116115 Icon (Icons .Default .WifiOff , null ,
117- tint = Color (0xFFEF4444 ),
118- modifier = Modifier .size(40 .dp).padding(8 .dp))
116+ tint = Color (0xFFEF4444 ),
117+ modifier = Modifier .size(40 .dp).padding(8 .dp))
119118 }
120119 Spacer (Modifier .height(12 .dp))
121120 Text (t.error_signal, color = Color (0xFFEF4444 ), fontWeight = FontWeight .Bold )
122121 Spacer (Modifier .height(16 .dp))
123122 Button (onClick = onRetry,
124- colors = ButtonDefaults .buttonColors(containerColor = Color (0xFFEF4444 ))) {
123+ colors = ButtonDefaults .buttonColors(containerColor = Color (0xFFEF4444 ))) {
125124 Text (t.retry, fontWeight = FontWeight .Bold )
126- }
125+ }
127126 }
128127 }
129128 images.isEmpty() -> Box (
130129 modifier = Modifier .fillMaxSize(),
131- contentAlignment = Alignment .Center
130+ contentAlignment = Alignment .Center
132131 ) {
133132 Column (horizontalAlignment = Alignment .CenterHorizontally ) {
134133 Icon (Icons .Default .PhotoCamera , null ,
135- tint = theme.mutedColor().copy(alpha = 0.2f ),
136- modifier = Modifier .size(56 .dp))
134+ tint = theme.mutedColor().copy(alpha = 0.2f ),
135+ modifier = Modifier .size(56 .dp))
137136 Spacer (Modifier .height(12 .dp))
138137 Text (t.gallery_empty, color = theme.mutedColor(), fontSize = 13 .sp)
139138 }
140139 }
141140 else -> LazyVerticalGrid (
142141 columns = GridCells .Fixed (2 ),
143- contentPadding = PaddingValues (start = 16 .dp, end = 16 .dp, bottom = 100 .dp),
144- horizontalArrangement = Arrangement .spacedBy(10 .dp),
145- verticalArrangement = Arrangement .spacedBy(10 .dp)
142+ contentPadding = PaddingValues (start = 16 .dp, end = 16 .dp, bottom = 100 .dp),
143+ horizontalArrangement = Arrangement .spacedBy(10 .dp),
144+ verticalArrangement = Arrangement .spacedBy(10 .dp)
146145 ) {
147146 items(images, key = { it.sha }) { img ->
148147 Box (
149148 modifier = Modifier
150- .fillMaxWidth()
151- .aspectRatio(1f )
152- .clip(RoundedCornerShape (14 .dp))
153- .border(1 .dp, Color .White .copy(alpha = 0.05f ), RoundedCornerShape (14 .dp))
154- .clickable { selectedImage = img }
149+ .fillMaxWidth()
150+ .aspectRatio(1f )
151+ .clip(RoundedCornerShape (14 .dp))
152+ .border(1 .dp, Color .White .copy(alpha = 0.05f ), RoundedCornerShape (14 .dp))
153+ .clickable { selectedImage = img }
155154 ) {
156155 AsyncImage (
157156 model = img.download_url,
158157 contentDescription = img.name,
159158 contentScale = ContentScale .Crop ,
160159 modifier = Modifier .fillMaxSize(),
161- alpha = 0.85f
160+ alpha = 0.85f
162161 )
163- // Hover name overlay at bottom
164162 Box (
165163 modifier = Modifier
166- .fillMaxWidth()
167- .align(Alignment .BottomCenter )
168- .background(
169- androidx.compose.ui.graphics.Brush .verticalGradient(
170- colors = listOf (Color .Transparent , Color .Black .copy(0.65f ))
171- )
164+ .fillMaxWidth()
165+ .align(Alignment .BottomCenter )
166+ .background(
167+ androidx.compose.ui.graphics.Brush .verticalGradient(
168+ colors = listOf (Color .Transparent , Color .Black .copy(0.65f ))
172169 )
173- .padding(8 .dp)
170+ )
171+ .padding(8 .dp)
174172 ) {
175173 Text (
176174 text = img.name,
177- fontSize = 9 .sp,
178- fontFamily = FontFamily .Monospace ,
179- color = Color .White ,
180- maxLines = 1
175+ fontSize = 9 .sp,
176+ fontFamily = FontFamily .Monospace ,
177+ color = Color .White ,
178+ maxLines = 1
181179 )
182180 }
183181 }
@@ -194,27 +192,27 @@ fun GalleryScreen(
194192 ) {
195193 Box (
196194 modifier = Modifier
197- .fillMaxSize()
198- .background(Color .Black .copy(alpha = 0.97f )),
195+ .fillMaxSize()
196+ .background(Color .Black .copy(alpha = 0.97f )),
199197 contentAlignment = Alignment .Center
200198 ) {
201199 IconButton (
202200 onClick = { selectedImage = null },
203201 modifier = Modifier
204- .align(Alignment .TopEnd )
205- .padding(16 .dp)
206- .clip(CircleShape )
207- .background(Color .White .copy(alpha = 0.1f ))
202+ .align(Alignment .TopEnd )
203+ .padding(16 .dp)
204+ .clip(CircleShape )
205+ .background(Color .White .copy(alpha = 0.1f ))
208206 ) {
209207 Icon (Icons .Default .Close , null , tint = Color .White .copy(alpha = 0.8f ))
210208 }
211209
212210 Box (
213211 modifier = Modifier
214- .fillMaxWidth(0.92f )
215- .fillMaxHeight(0.72f )
216- .clip(RoundedCornerShape (16 .dp))
217- .border(1 .dp, Color .White .copy(alpha = 0.1f ), RoundedCornerShape (16 .dp))
212+ .fillMaxWidth(0.92f )
213+ .fillMaxHeight(0.72f )
214+ .clip(RoundedCornerShape (16 .dp))
215+ .border(1 .dp, Color .White .copy(alpha = 0.1f ), RoundedCornerShape (16 .dp))
218216 ) {
219217 AsyncImage (
220218 model = img.download_url,
@@ -245,7 +243,7 @@ fun GalleryScreen(
245243 MediaStore .Downloads .EXTERNAL_CONTENT_URI , values)
246244 uri?.let {
247245 context.contentResolver.openOutputStream(it)
248- ?.use { os -> os.write(bytes) }
246+ ?.use { os -> os.write(bytes) }
249247 }
250248 } else {
251249 val dir = Environment .getExternalStoragePublicDirectory(
@@ -261,25 +259,25 @@ fun GalleryScreen(
261259 },
262260 enabled = ! downloading,
263261 colors = ButtonDefaults .buttonColors(containerColor = theme.primaryColor()),
264- shape = RoundedCornerShape (14 .dp),
265- modifier = Modifier
266- .align(Alignment .BottomCenter )
267- .fillMaxWidth(0.85f )
268- .padding(bottom = 40 .dp)
269- .height(56 .dp)
262+ shape = RoundedCornerShape (14 .dp),
263+ modifier = Modifier
264+ .align(Alignment .BottomCenter )
265+ .fillMaxWidth(0.85f )
266+ .padding(bottom = 40 .dp)
267+ .height(56 .dp)
270268 ) {
271269 if (downloading) {
272270 CircularProgressIndicator (color = theme.backgroundColor(),
273- modifier = Modifier .size(20 .dp), strokeWidth = 2 .dp)
271+ modifier = Modifier .size(20 .dp), strokeWidth = 2 .dp)
274272 Spacer (Modifier .width(12 .dp))
275273 Text (t.downloading, fontWeight = FontWeight .Bold , fontSize = 15 .sp,
276- color = theme.backgroundColor())
274+ color = theme.backgroundColor())
277275 } else {
278276 Icon (Icons .Default .Download , null , tint = theme.backgroundColor(),
279- modifier = Modifier .size(22 .dp))
277+ modifier = Modifier .size(22 .dp))
280278 Spacer (Modifier .width(12 .dp))
281279 Text (t.download_save, fontWeight = FontWeight .Bold , fontSize = 15 .sp,
282- color = theme.backgroundColor())
280+ color = theme.backgroundColor())
283281 }
284282 }
285283 }
0 commit comments