Skip to content

Commit d433089

Browse files
committed
Fix portrait mode scanning
1 parent 4c79e76 commit d433089

1 file changed

Lines changed: 64 additions & 29 deletions

File tree

  • app/src/main/java/org/osservatorionessuno/bugbane/screens

app/src/main/java/org/osservatorionessuno/bugbane/screens/ScanScreen.kt

Lines changed: 64 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -67,35 +67,70 @@ fun ScanScreen(
6767
) {
6868
if (isScanning) {
6969
Column(modifier = Modifier.fillMaxSize()) {
70-
Row(modifier = Modifier.weight(1f)) {
71-
Box(
72-
modifier = Modifier
73-
.weight(1f)
74-
.fillMaxHeight(),
75-
contentAlignment = Alignment.Center
76-
) {
77-
Column(horizontalAlignment = Alignment.CenterHorizontally) {
78-
if (totalModules > 0) {
79-
CircularProgressIndicator(
80-
progress = {
81-
(completedModules / totalModules.toFloat()).coerceIn(0f, 1f)
82-
}
83-
)
84-
Spacer(modifier = Modifier.height(8.dp))
85-
Text("$completedModules / $totalModules")
86-
} else {
87-
CircularProgressIndicator()
70+
if (isLandscape) {
71+
Row(modifier = Modifier.weight(1f)) {
72+
Box(
73+
modifier = Modifier
74+
.weight(1f)
75+
.fillMaxHeight(),
76+
contentAlignment = Alignment.Center
77+
) {
78+
Column(horizontalAlignment = Alignment.CenterHorizontally) {
79+
if (totalModules > 0) {
80+
CircularProgressIndicator(
81+
progress = {
82+
(completedModules / totalModules.toFloat()).coerceIn(0f, 1f)
83+
}
84+
)
85+
Spacer(modifier = Modifier.height(8.dp))
86+
Text("$completedModules / $totalModules")
87+
} else {
88+
CircularProgressIndicator()
89+
}
90+
}
91+
}
92+
LazyColumn(
93+
modifier = Modifier
94+
.weight(1f)
95+
.fillMaxHeight()
96+
.padding(16.dp),
97+
) {
98+
items(progressLogs) { log ->
99+
Text(log)
88100
}
89101
}
90102
}
91-
LazyColumn(
92-
modifier = Modifier
93-
.weight(1f)
94-
.fillMaxHeight()
95-
.padding(16.dp)
96-
) {
97-
items(progressLogs) { log ->
98-
Text(log)
103+
} else {
104+
Column(modifier = Modifier.weight(1f)) {
105+
Box(
106+
modifier = Modifier
107+
.weight(1f)
108+
.fillMaxWidth(),
109+
contentAlignment = Alignment.Center
110+
) {
111+
Column(horizontalAlignment = Alignment.CenterHorizontally) {
112+
if (totalModules > 0) {
113+
CircularProgressIndicator(
114+
progress = {
115+
(completedModules / totalModules.toFloat()).coerceIn(0f, 1f)
116+
}
117+
)
118+
Spacer(modifier = Modifier.height(8.dp))
119+
Text("$completedModules / $totalModules")
120+
} else {
121+
CircularProgressIndicator()
122+
}
123+
}
124+
}
125+
LazyColumn(
126+
modifier = Modifier
127+
.weight(1f)
128+
.fillMaxWidth()
129+
.padding(16.dp),
130+
) {
131+
items(progressLogs) { log ->
132+
Text(log)
133+
}
99134
}
100135
}
101136
}
@@ -104,17 +139,17 @@ fun ScanScreen(
104139
modifier = Modifier.fillMaxWidth(),
105140
colors = ButtonDefaults.buttonColors(
106141
containerColor = MaterialTheme.colorScheme.error
107-
)
142+
),
108143
) {
109144
Icon(
110145
imageVector = Icons.Default.Close,
111146
contentDescription = null,
112-
modifier = Modifier.size(20.dp)
147+
modifier = Modifier.size(20.dp),
113148
)
114149
Spacer(modifier = Modifier.width(8.dp))
115150
Text(
116151
text = stringResource(R.string.scan_cancel_button),
117-
style = MaterialTheme.typography.bodyLarge.copy(fontWeight = FontWeight.Medium)
152+
style = MaterialTheme.typography.bodyLarge.copy(fontWeight = FontWeight.Medium),
118153
)
119154
}
120155
}

0 commit comments

Comments
 (0)