11package com.platon.easymusicandroid
22
3+ import android.annotation.SuppressLint
34import android.content.Intent
5+ import android.net.Uri
46import android.os.Bundle
7+ import android.view.View
8+ import android.widget.Toast
59import androidx.activity.ComponentActivity
610import androidx.activity.compose.setContent
711import androidx.compose.foundation.background
@@ -26,6 +30,8 @@ import androidx.compose.ui.unit.dp
2630import androidx.compose.ui.unit.sp
2731import com.google.android.exoplayer2.ExoPlayer
2832import com.google.android.exoplayer2.MediaItem
33+ import androidx.activity.enableEdgeToEdge
34+ import androidx.compose.ui.platform.LocalContext
2935
3036data class Station (
3137 val name : String ,
@@ -74,7 +80,9 @@ class MainActivity : ComponentActivity() {
7480 private var currentStationIndex = mutableStateOf(0 )
7581
7682 override fun onCreate (savedInstanceState : Bundle ? ) {
83+ enableEdgeToEdge()
7784 super .onCreate(savedInstanceState)
85+ window.isNavigationBarContrastEnforced = false
7886
7987 // Initialize ExoPlayer
8088 player = ExoPlayer .Builder (this ).build()
@@ -119,6 +127,8 @@ class MainActivity : ComponentActivity() {
119127 }
120128}
121129
130+ @SuppressLint(" UnusedMaterial3ScaffoldPaddingParameter" )
131+ @OptIn(ExperimentalMaterial3Api ::class )
122132@Composable
123133fun EasyMusicApp (
124134 stations : List <Station >,
@@ -128,91 +138,115 @@ fun EasyMusicApp(
128138 onStationChange : (Int ) -> Unit
129139) {
130140 val station = stations[currentStationIndex]
141+ val context = LocalContext .current
142+ val intent = remember { Intent (Intent .ACTION_VIEW , Uri .parse(" https://t.me/easymusicplatonoferon/" )) }
131143
132- Box (
144+ Scaffold (
133145 modifier = Modifier
134- .fillMaxSize()
135146 .background(
136147 brush = Brush .verticalGradient(
137148 colors = station.gradientColors
138149 )
139- ),
140- contentAlignment = Alignment .Center
150+ )
151+ .safeDrawingPadding(),
152+ containerColor = Color .Transparent
141153 ) {
142- Column (
143- modifier = Modifier
144- .fillMaxSize()
145- .padding(16 .dp),
146- horizontalAlignment = Alignment .CenterHorizontally
147- ) {
148- Spacer (modifier = Modifier .height(16 .dp))
149-
150- Text (
151- text = station.name,
152- style = MaterialTheme .typography.titleLarge.copy(
153- fontSize = 28 .sp,
154- fontWeight = FontWeight .Bold ,
155- fontFamily = FontFamily .SansSerif
154+ Box {
155+ TextButton (
156+ onClick = {
157+ try {
158+ context.startActivity(intent)
159+ }
160+ catch (e: Exception ) {
161+ Toast .makeText(context, " Ошибка. Ищи вручную:\n @easymusicplatonoferon" , Toast .LENGTH_LONG ).show()
162+ }
163+ },
164+ colors = ButtonDefaults .buttonColors(
165+ containerColor = Color .Transparent ,
166+ contentColor = Color (0xA0FFFFFF )
156167 ),
157- color = Color .White ,
158- modifier = Modifier .padding(bottom = 8 .dp)
159- )
168+ modifier = Modifier .padding(horizontal = 20 .dp)
169+ ) {
170+ Text (text = " тг чат" )
171+ }
160172
161- Text (
162- text = station.description,
163- style = MaterialTheme .typography.bodyMedium.copy(
164- fontFamily = FontFamily .SansSerif
165- ),
166- color = Color .White ,
167- textAlign = TextAlign .Center ,
168- modifier = Modifier .padding(horizontal = 16 .dp)
169- )
173+ Column (
174+ modifier = Modifier
175+ .fillMaxSize()
176+ .padding(16 .dp),
177+ horizontalAlignment = Alignment .CenterHorizontally
178+ ) {
179+ Spacer (modifier = Modifier .height(16 .dp))
180+
181+ Text (
182+ text = station.name,
183+ style = MaterialTheme .typography.titleLarge.copy(
184+ fontSize = 28 .sp,
185+ fontWeight = FontWeight .Bold ,
186+ fontFamily = FontFamily .SansSerif
187+ ),
188+ color = Color .White ,
189+ modifier = Modifier .padding(bottom = 8 .dp)
190+ )
170191
171- Spacer (modifier = Modifier .weight(1f ))
192+ Text (
193+ text = station.description,
194+ style = MaterialTheme .typography.bodyMedium.copy(
195+ fontFamily = FontFamily .SansSerif
196+ ),
197+ color = Color .White ,
198+ textAlign = TextAlign .Center ,
199+ modifier = Modifier .padding(horizontal = 16 .dp)
200+ )
172201
173- Text (
174- text = if (isPlaying) " Now Playing: Streaming" else " Now Playing: Paused" ,
175- color = Color .White ,
176- modifier = Modifier .padding(bottom = 32 .dp)
177- )
202+ Spacer (modifier = Modifier .weight(1f ))
178203
179- Row (
180- modifier = Modifier .fillMaxWidth(),
181- horizontalArrangement = Arrangement .SpaceBetween ,
182- verticalAlignment = Alignment .CenterVertically
183- ) {
184- IconButton (onClick = {
185- if (currentStationIndex > 0 ) onStationChange(currentStationIndex - 1 )
186- }) {
187- Icon (
188- imageVector = Icons .Filled .ArrowBack ,
189- contentDescription = " Previous" ,
190- tint = Color .White
191- )
192- }
204+ Text (
205+ text = if (isPlaying) " Now Playing: Streaming" else " Now Playing: Paused" ,
206+ color = Color .White ,
207+ modifier = Modifier .padding(bottom = 32 .dp)
208+ )
193209
194- Box (
195- modifier = Modifier
196- .size(80 .dp)
197- .background(Color .White , CircleShape )
198- .clickable { onPlayPauseToggle() },
199- contentAlignment = Alignment .Center
210+ Row (
211+ modifier = Modifier .fillMaxWidth(),
212+ horizontalArrangement = Arrangement .SpaceBetween ,
213+ verticalAlignment = Alignment .CenterVertically
200214 ) {
201- Icon (
202- imageVector = if (isPlaying) Icons .Filled .Close else Icons .Filled .PlayArrow ,
203- contentDescription = if (isPlaying) " Pause" else " Play" ,
204- tint = Color .Red
205- )
206- }
215+ IconButton (onClick = {
216+ if (currentStationIndex > 0 ) onStationChange(currentStationIndex - 1 )
217+ }) {
218+ Icon (
219+ imageVector = Icons .Filled .ArrowBack ,
220+ contentDescription = " Previous" ,
221+ tint = Color .White
222+ )
223+ }
207224
208- IconButton (onClick = {
209- if (currentStationIndex < stations.size - 1 ) onStationChange(currentStationIndex + 1 )
210- }) {
211- Icon (
212- imageVector = Icons .Filled .ArrowForward ,
213- contentDescription = " Next" ,
214- tint = Color .White
215- )
225+ Box (
226+ modifier = Modifier
227+ .size(80 .dp)
228+ .background(Color .White , CircleShape )
229+ .clickable { onPlayPauseToggle() },
230+ contentAlignment = Alignment .Center
231+ ) {
232+ Icon (
233+ imageVector = if (isPlaying) Icons .Filled .Close else Icons .Filled .PlayArrow ,
234+ contentDescription = if (isPlaying) " Pause" else " Play" ,
235+ tint = Color .Red
236+ )
237+ }
238+
239+ IconButton (onClick = {
240+ if (currentStationIndex < stations.size - 1 ) onStationChange(
241+ currentStationIndex + 1
242+ )
243+ }) {
244+ Icon (
245+ imageVector = Icons .Filled .ArrowForward ,
246+ contentDescription = " Next" ,
247+ tint = Color .White
248+ )
249+ }
216250 }
217251 }
218252 }
0 commit comments