Skip to content

Commit 6f280ed

Browse files
committed
Create Separate recording screen for Landscape views
1 parent 9bcde31 commit 6f280ed

1 file changed

Lines changed: 150 additions & 0 deletions

File tree

shared/src/commonMain/kotlin/com/module/notelycompose/audio/ui/recorder/RecordingScreen.kt

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ import androidx.compose.foundation.layout.size
2424
import androidx.compose.foundation.layout.width
2525
import androidx.compose.foundation.layout.windowInsetsPadding
2626
import androidx.compose.foundation.layout.wrapContentHeight
27+
import androidx.compose.foundation.rememberScrollState
2728
import androidx.compose.foundation.shape.CircleShape
2829
import androidx.compose.foundation.shape.RoundedCornerShape
30+
import androidx.compose.foundation.verticalScroll
2931
import androidx.compose.material.icons.Icons
3032
import androidx.compose.material.icons.automirrored.filled.ArrowBack
3133
import androidx.compose.material.icons.filled.PlayArrow
@@ -52,6 +54,7 @@ import androidx.compose.ui.graphics.Path
5254
import androidx.compose.ui.graphics.StrokeCap
5355
import androidx.compose.ui.graphics.StrokeJoin
5456
import androidx.compose.ui.graphics.drawscope.Stroke
57+
import androidx.compose.ui.platform.LocalWindowInfo
5558
import androidx.compose.ui.text.font.FontWeight
5659
import androidx.compose.ui.unit.dp
5760
import androidx.compose.ui.unit.sp
@@ -210,6 +213,153 @@ private fun RecordingInProgressScreen(
210213
onResumeRecording: () -> Unit,
211214
isRecordPaused: Boolean
212215
) {
216+
217+
val windowInfo = LocalWindowInfo.current
218+
val isLandscape = windowInfo.containerSize.width > windowInfo.containerSize.height
219+
220+
if(isLandscape) {
221+
LandscapeRecordingInProgressScreen(
222+
counterTimeString = counterTimeString,
223+
onNavigateBack = onNavigateBack,
224+
onStopRecording = onStopRecording,
225+
onPauseRecording = onPauseRecording,
226+
onResumeRecording = onResumeRecording,
227+
isRecordPaused = isRecordPaused
228+
)
229+
} else {
230+
PotraitRecordingInProgressScreen(
231+
counterTimeString = counterTimeString,
232+
onNavigateBack = onNavigateBack,
233+
onStopRecording = onStopRecording,
234+
onPauseRecording = onPauseRecording,
235+
onResumeRecording = onResumeRecording,
236+
isRecordPaused = isRecordPaused
237+
)
238+
}
239+
}
240+
241+
@Composable
242+
private fun LandscapeRecordingInProgressScreen(
243+
counterTimeString: String,
244+
onNavigateBack: () -> Unit,
245+
onStopRecording: () -> Unit,
246+
onPauseRecording: () -> Unit,
247+
onResumeRecording: () -> Unit,
248+
isRecordPaused: Boolean
249+
) {
250+
Column(
251+
modifier = Modifier
252+
.fillMaxSize()
253+
.background(LocalCustomColors.current.bodyBackgroundColor)
254+
.verticalScroll(rememberScrollState())
255+
) {
256+
RecordingUiComponentBackButton(
257+
onNavigateBack = onNavigateBack,
258+
onStopRecording = onStopRecording
259+
)
260+
261+
Column(
262+
modifier = Modifier
263+
.fillMaxWidth()
264+
.padding(vertical = 32.dp),
265+
horizontalAlignment = Alignment.CenterHorizontally
266+
) {
267+
Box(
268+
contentAlignment = Alignment.Center,
269+
modifier = Modifier.size(200.dp)
270+
) {
271+
LoadingAnimation(
272+
isRecordPaused = isRecordPaused
273+
)
274+
Text(
275+
text = counterTimeString,
276+
style = MaterialTheme.typography.headlineLarge,
277+
fontWeight = FontWeight.Normal,
278+
color = LocalCustomColors.current.bodyContentColor
279+
)
280+
}
281+
}
282+
283+
Box(
284+
modifier = Modifier
285+
.fillMaxWidth()
286+
.padding(bottom = 80.dp)
287+
.padding(vertical = 32.dp),
288+
contentAlignment = Alignment.Center
289+
) {
290+
Column(
291+
horizontalAlignment = Alignment.CenterHorizontally
292+
) {
293+
Row(
294+
verticalAlignment = Alignment.CenterVertically,
295+
horizontalArrangement = Arrangement.spacedBy(16.dp)
296+
) {
297+
298+
Box(
299+
modifier = Modifier
300+
.size(64.dp)
301+
.clip(CircleShape)
302+
.border(2.dp, LocalCustomColors.current.bodyContentColor, CircleShape)
303+
.padding(vertical = 2.dp, horizontal = 2.dp),
304+
contentAlignment = Alignment.Center
305+
) {
306+
Icon(
307+
imageVector = if (!isRecordPaused) Images.Icons.IcPause else Icons.Filled.PlayArrow,
308+
contentDescription = stringResource(Res.string.transcription_icon),
309+
tint = LocalCustomColors.current.bodyContentColor,
310+
modifier = Modifier
311+
.size(32.dp)
312+
.clickable {
313+
if (isRecordPaused) {
314+
onResumeRecording()
315+
} else {
316+
onPauseRecording()
317+
}
318+
}
319+
)
320+
}
321+
322+
Box(
323+
modifier = Modifier
324+
.size(64.dp)
325+
.clip(CircleShape)
326+
.border(2.dp, LocalCustomColors.current.bodyContentColor, CircleShape)
327+
.padding(2.dp),
328+
contentAlignment = Alignment.Center
329+
) {
330+
Box(
331+
modifier = Modifier
332+
.size(32.dp)
333+
.clip(RoundedCornerShape(4.dp))
334+
.background(Color.Red)
335+
.clickable {
336+
onStopRecording()
337+
}
338+
)
339+
}
340+
}
341+
342+
Text(
343+
text = stringResource(Res.string.recording_ui_tap_stop_record),
344+
color = LocalCustomColors.current.bodyContentColor,
345+
fontSize = 16.sp,
346+
fontWeight = FontWeight.Normal,
347+
modifier = Modifier.padding(top = 24.dp)
348+
)
349+
}
350+
}
351+
}
352+
}
353+
354+
@Composable
355+
private fun PotraitRecordingInProgressScreen(
356+
counterTimeString: String,
357+
onNavigateBack: () -> Unit,
358+
onStopRecording: () -> Unit,
359+
onPauseRecording: () -> Unit,
360+
onResumeRecording: () -> Unit,
361+
isRecordPaused: Boolean
362+
) {
213363
Box(
214364
modifier = Modifier
215365
.fillMaxSize()

0 commit comments

Comments
 (0)