Skip to content

Commit ec5ed83

Browse files
committed
Update main screen layout
1 parent bf16961 commit ec5ed83

1 file changed

Lines changed: 135 additions & 112 deletions

File tree

app/src/main/java/com/willbeeching/flix/ui/MainActivity.kt

Lines changed: 135 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -541,132 +541,155 @@ fun MainScreen(
541541
}
542542
}
543543
} else {
544-
// Not authenticated - Logo and buttons centered
545-
Column(
546-
modifier = Modifier
547-
.fillMaxSize()
548-
.verticalScroll(rememberScrollState())
549-
.padding(56.dp),
550-
horizontalAlignment = Alignment.CenterHorizontally,
551-
verticalArrangement = Arrangement.Center
544+
// Not authenticated - Two column layout
545+
val dividerColor = Color.White.copy(alpha = 0.1f)
546+
547+
Row(
548+
modifier = Modifier.fillMaxSize(),
549+
horizontalArrangement = Arrangement.SpaceEvenly
552550
) {
553-
// Logo
554-
Image(
555-
painter = painterResource(id = R.drawable.flix_logo),
556-
contentDescription = "Flix Logo",
551+
// Left Column: Logo
552+
Column(
557553
modifier = Modifier
558-
.width(400.dp)
559-
.height(129.dp)
560-
)
554+
.weight(1f)
555+
.fillMaxHeight(),
556+
horizontalAlignment = Alignment.CenterHorizontally,
557+
verticalArrangement = Arrangement.Center
558+
) {
559+
Image(
560+
painter = painterResource(id = R.drawable.flix_logo),
561+
contentDescription = "Flix Logo",
562+
modifier = Modifier
563+
.width(200.dp)
564+
.height(64.dp)
565+
)
566+
}
561567

562-
Spacer(modifier = Modifier.height(64.dp))
568+
// Center Vertical Divider
569+
Box(
570+
modifier = Modifier
571+
.width(1.dp)
572+
.fillMaxHeight()
573+
.background(dividerColor)
574+
)
563575

564-
// Not connected - show Connect to Plex and API Settings buttons
576+
// Right Column: Buttons
565577
Column(
566-
horizontalAlignment = Alignment.CenterHorizontally
578+
modifier = Modifier
579+
.weight(1f)
580+
.fillMaxHeight(),
581+
horizontalAlignment = Alignment.CenterHorizontally,
582+
verticalArrangement = Arrangement.Center
567583
) {
568-
Button(
569-
onClick = {
570-
isAuthenticating = true
571-
errorMessage = null
572-
573-
scope.launch {
574-
try {
575-
// Run network operations on IO dispatcher
576-
val result = withContext(Dispatchers.IO) {
577-
// Request PIN
578-
val pinResult = authManager.requestPin()
579-
580-
if (pinResult.isFailure) {
581-
return@withContext Result.failure<String>(
582-
pinResult.exceptionOrNull() ?: Exception("Unknown error")
583-
)
584-
}
585-
586-
val linkResult = pinResult.getOrNull()!!
587-
588-
// Update UI on main thread
589-
withContext(Dispatchers.Main) {
590-
linkCode = linkResult.code
591-
linkUrl = linkResult.linkUrl
584+
Column(
585+
modifier = Modifier.width(340.dp),
586+
horizontalAlignment = Alignment.CenterHorizontally
587+
) {
588+
// Connect to Plex Button (Primary)
589+
Button(
590+
onClick = {
591+
isAuthenticating = true
592+
errorMessage = null
593+
594+
scope.launch {
595+
try {
596+
// Run network operations on IO dispatcher
597+
val result = withContext(Dispatchers.IO) {
598+
// Request PIN
599+
val pinResult = authManager.requestPin()
600+
601+
if (pinResult.isFailure) {
602+
return@withContext Result.failure<String>(
603+
pinResult.exceptionOrNull() ?: Exception("Unknown error")
604+
)
605+
}
606+
607+
val linkResult = pinResult.getOrNull()!!
608+
609+
// Update UI on main thread
610+
withContext(Dispatchers.Main) {
611+
linkCode = linkResult.code
612+
linkUrl = linkResult.linkUrl
613+
}
614+
615+
// Poll for authorization
616+
authManager.pollForAuth(
617+
pinId = linkResult.pinId,
618+
timeoutSeconds = 300
619+
)
620+
}
621+
622+
if (result.isSuccess) {
623+
authenticated = true
624+
isAuthenticating = false
625+
linkCode = null
626+
linkUrl = null
627+
} else {
628+
errorMessage = "Failed to authenticate: ${result.exceptionOrNull()?.message}"
629+
isAuthenticating = false
630+
}
631+
} catch (e: Exception) {
632+
errorMessage = "Error: ${e.message}"
633+
isAuthenticating = false
592634
}
593-
594-
// Poll for authorization
595-
authManager.pollForAuth(
596-
pinId = linkResult.pinId,
597-
timeoutSeconds = 300
598-
)
599-
}
600-
601-
if (result.isSuccess) {
602-
authenticated = true
603-
isAuthenticating = false
604-
linkCode = null
605-
linkUrl = null
606-
} else {
607-
errorMessage = "Failed to authenticate: ${result.exceptionOrNull()?.message}"
608-
isAuthenticating = false
609635
}
610-
} catch (e: Exception) {
611-
errorMessage = "Error: ${e.message}"
612-
isAuthenticating = false
613-
}
636+
},
637+
colors = ButtonDefaults.buttonColors(
638+
containerColor = Color.White,
639+
contentColor = Color.Black
640+
),
641+
shape = RoundedCornerShape(12.dp),
642+
contentPadding = PaddingValues(horizontal = 24.dp, vertical = 12.dp),
643+
modifier = Modifier
644+
.width(340.dp)
645+
.height(48.dp)
646+
) {
647+
Text(
648+
"Connect to Plex",
649+
fontSize = 16.sp,
650+
fontWeight = FontWeight.SemiBold,
651+
fontFamily = GoogleSansFontFamily
652+
)
614653
}
615-
},
616-
colors = ButtonDefaults.buttonColors(
617-
containerColor = Color.White,
618-
contentColor = Color.Black
619-
),
620-
shape = RoundedCornerShape(12.dp),
621-
contentPadding = PaddingValues(horizontal = 32.dp, vertical = 16.dp),
622-
modifier = Modifier
623-
.width(280.dp)
624-
.height(56.dp)
625-
) {
626-
Text(
627-
"Connect to Plex",
628-
fontSize = 18.sp,
629-
fontWeight = FontWeight.SemiBold,
630-
fontFamily = GoogleSansFontFamily
631-
)
632-
}
633654

634-
Spacer(modifier = Modifier.height(16.dp))
655+
Spacer(modifier = Modifier.height(12.dp))
635656

636-
// API Settings Button
637-
Button(
638-
onClick = {
639-
context.startActivity(Intent(context, ApiSettingsActivity::class.java))
640-
},
641-
colors = ButtonDefaults.buttonColors(
642-
containerColor = buttonColor,
643-
contentColor = textColor
644-
),
645-
shape = RoundedCornerShape(12.dp),
646-
contentPadding = PaddingValues(horizontal = 32.dp, vertical = 16.dp),
647-
modifier = Modifier
648-
.width(280.dp)
649-
.height(56.dp)
650-
) {
651-
Text(
652-
"API Settings",
653-
fontSize = 18.sp,
654-
fontWeight = FontWeight.SemiBold,
655-
fontFamily = GoogleSansFontFamily
656-
)
657-
}
657+
// API Settings Button
658+
Button(
659+
onClick = {
660+
context.startActivity(Intent(context, ApiSettingsActivity::class.java))
661+
},
662+
colors = ButtonDefaults.buttonColors(
663+
containerColor = buttonColor,
664+
contentColor = textColor
665+
),
666+
shape = RoundedCornerShape(12.dp),
667+
contentPadding = PaddingValues(horizontal = 24.dp, vertical = 12.dp),
668+
modifier = Modifier
669+
.width(340.dp)
670+
.height(48.dp)
671+
) {
672+
Text(
673+
"API Settings",
674+
fontSize = 16.sp,
675+
fontWeight = FontWeight.SemiBold,
676+
fontFamily = GoogleSansFontFamily
677+
)
678+
}
658679

659-
if (errorMessage != null) {
660-
Spacer(modifier = Modifier.height(24.dp))
661-
Text(
662-
text = errorMessage!!,
663-
fontSize = 14.sp,
664-
fontFamily = GoogleSansFontFamily,
665-
color = errorColor
666-
)
680+
if (errorMessage != null) {
681+
Spacer(modifier = Modifier.height(24.dp))
682+
Text(
683+
text = errorMessage!!,
684+
fontSize = 14.sp,
685+
fontFamily = GoogleSansFontFamily,
686+
color = errorColor,
687+
modifier = Modifier.fillMaxWidth()
688+
)
689+
}
690+
}
667691
}
668692
}
669-
}
670693
}
671694
}
672695
}

0 commit comments

Comments
 (0)