Skip to content

Commit e8c702e

Browse files
committed
Enhance DiffCheckerScreen UI and add selected view indicator
This commit introduces several UI improvements to the `DiffCheckerScreen`: - **Selected View Indicator:** - Added a checkmark icon (Icons.Default.Check) to the `DropdownMenuItem` corresponding to the currently selected `DiffViewType` (TWO_SIDE, SEPARATE, UNIFIED). This provides clear visual feedback to the user about the active view mode. - **Visual Tweaks:** - Renamed "Column View" to "Separate View" in the dropdown menu for better clarity. - Adjusted padding around the "Live" text and Switch in the top app bar for a more polished look. - Removed vertical padding from the "Swap Texts" button. - Reduced overall screen padding from 16.dp to 10.dp. - **Diff Result Container:** - Wrapped the diff result display (TwoSideCharDiffText, ColumCharDiffText, UnifiedCharDiffText) in a `Box` with a white background and rounded corners. This visually separates the diff output from the input fields and controls. - The diff result container now uses `weight(1f)` to occupy the remaining vertical space. Additionally, the `.idea/appInsightsSettings.xml` file was updated to set "Android Vitals" as the selected tab in App Insights.
1 parent 7c920ba commit e8c702e

2 files changed

Lines changed: 57 additions & 11 deletions

File tree

.idea/appInsightsSettings.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/dev/jahidhasanco/diffly/presentation/screen/DiffCheckerScreen.kt

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dev.jahidhasanco.diffly.presentation.screen
22

33

4+
import androidx.compose.foundation.background
45
import androidx.compose.foundation.layout.Arrangement
56
import androidx.compose.foundation.layout.Box
67
import androidx.compose.foundation.layout.Column
@@ -12,9 +13,9 @@ import androidx.compose.foundation.layout.height
1213
import androidx.compose.foundation.layout.padding
1314
import androidx.compose.foundation.layout.size
1415
import androidx.compose.foundation.layout.wrapContentWidth
15-
import androidx.compose.foundation.rememberScrollState
1616
import androidx.compose.foundation.shape.RoundedCornerShape
1717
import androidx.compose.material.icons.Icons
18+
import androidx.compose.material.icons.filled.Check
1819
import androidx.compose.material.icons.filled.MoreVert
1920
import androidx.compose.material.icons.filled.SwapVert
2021
import androidx.compose.material3.Button
@@ -63,7 +64,6 @@ fun DiffCheckerScreen(viewModel: MainViewModel) {
6364
var realTimeDiff by remember { mutableStateOf(false) }
6465
var expanded by remember { mutableStateOf(false) }
6566
var selectedViewType by remember { mutableStateOf(DiffViewType.TWO_SIDE) }
66-
val scrollState = rememberScrollState()
6767
Scaffold(
6868
modifier = Modifier.fillMaxSize(),
6969
containerColor = background,
@@ -90,11 +90,10 @@ fun DiffCheckerScreen(viewModel: MainViewModel) {
9090
text = "Live",
9191
style = MaterialTheme.typography.titleMedium,
9292
color = if (realTimeDiff) primary else Color.Gray,
93-
modifier = Modifier.padding(end = 6.dp)
93+
modifier = Modifier.padding(end = 2.dp)
9494
)
9595
Switch(
9696
modifier = Modifier
97-
.padding(end = 4.dp)
9897
.scale(0.7f),
9998
checked = realTimeDiff,
10099
onCheckedChange = {
@@ -125,18 +124,54 @@ fun DiffCheckerScreen(viewModel: MainViewModel) {
125124
onDismissRequest = { expanded = false }) {
126125
DropdownMenuItem(
127126
text = { Text("Two Side View") },
127+
trailingIcon = when (selectedViewType) {
128+
DiffViewType.TWO_SIDE -> {
129+
{
130+
Icon(
131+
Icons.Default.Check,
132+
contentDescription = null
133+
)
134+
}
135+
}
136+
137+
else -> null
138+
},
128139
onClick = {
129140
selectedViewType = DiffViewType.TWO_SIDE
130141
expanded = false
131142
})
132143
DropdownMenuItem(
133-
text = { Text("Column View") },
144+
text = { Text("Separate View") },
145+
trailingIcon = when (selectedViewType) {
146+
DiffViewType.SEPARATE -> {
147+
{
148+
Icon(
149+
Icons.Default.Check,
150+
contentDescription = null
151+
)
152+
}
153+
}
154+
155+
else -> null
156+
},
134157
onClick = {
135158
selectedViewType = DiffViewType.SEPARATE
136159
expanded = false
137160
})
138161
DropdownMenuItem(
139162
text = { Text("Unified View") },
163+
trailingIcon = when (selectedViewType) {
164+
DiffViewType.UNIFIED -> {
165+
{
166+
Icon(
167+
Icons.Default.Check,
168+
contentDescription = null
169+
)
170+
}
171+
}
172+
173+
else -> null
174+
},
140175
onClick = {
141176
selectedViewType = DiffViewType.UNIFIED
142177
expanded = false
@@ -148,7 +183,7 @@ fun DiffCheckerScreen(viewModel: MainViewModel) {
148183
Column(
149184
modifier = Modifier
150185
.padding(innerPadding)
151-
.padding(16.dp)
186+
.padding(10.dp)
152187
.fillMaxSize()
153188
) {
154189
OutlinedTextField(
@@ -203,7 +238,6 @@ fun DiffCheckerScreen(viewModel: MainViewModel) {
203238
),
204239
modifier = Modifier
205240
.align(Alignment.CenterHorizontally)
206-
.padding(vertical = 8.dp)
207241
) {
208242
Icon(
209243
imageVector = Icons.Default.SwapVert,
@@ -265,11 +299,22 @@ fun DiffCheckerScreen(viewModel: MainViewModel) {
265299
) {
266300
Text("Find Difference")
267301
}
268-
when (selectedViewType) {
269-
DiffViewType.TWO_SIDE -> TwoSideCharDiffText(diffResult)
270-
DiffViewType.SEPARATE -> ColumCharDiffText(diffResult)
271-
DiffViewType.UNIFIED -> UnifiedCharDiffText(diffResult)
302+
303+
Box (
304+
modifier = Modifier
305+
.fillMaxWidth()
306+
.weight(1f)
307+
.padding(8.dp)
308+
.background(Color.White, RoundedCornerShape(8.dp))
309+
)
310+
{
311+
when (selectedViewType) {
312+
DiffViewType.TWO_SIDE -> TwoSideCharDiffText(diffResult)
313+
DiffViewType.SEPARATE -> ColumCharDiffText(diffResult)
314+
DiffViewType.UNIFIED -> UnifiedCharDiffText(diffResult)
315+
}
272316
}
317+
273318
}
274319
}
275320
}

0 commit comments

Comments
 (0)