Skip to content

Commit

Permalink
UI updates and refinements
Browse files Browse the repository at this point in the history
  • Loading branch information
beradeep committed Sep 26, 2023
1 parent 8f644f9 commit 2e43d81
Show file tree
Hide file tree
Showing 12 changed files with 203 additions and 166 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/bera/collegesearch/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.bera.collegesearch.navigation.Navigation
import com.bera.collegesearch.network.ConnectivityObserver
import com.bera.collegesearch.network.ConnectivityStatus
import com.bera.collegesearch.network.connectivity.ConnectivityObserver
import com.bera.collegesearch.network.connectivity.ConnectivityStatus
import com.bera.collegesearch.screens.home.NetworkErrorScreen
import com.bera.collegesearch.ui.theme.CollegeSearchTheme
import dagger.hilt.android.AndroidEntryPoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -54,7 +54,7 @@ fun CollegeColumn(
modifier = Modifier
.fillMaxWidth().padding(top = 16.dp, start = 4.dp, end = 4.dp)
) {
Button(
OutlinedButton(
modifier = Modifier
.height(80.dp)
.fillMaxWidth()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bera.collegesearch.components.cbr

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -17,10 +18,12 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.bera.collegesearch.R
import com.bera.collegesearch.models.CutoffItem
import com.bera.collegesearch.utils.Constants.FakeCutoffItem
import com.bera.collegesearch.utils.ShimmerListItem
Expand All @@ -30,10 +33,13 @@ fun CBRCutoffs(
cutoffs: ArrayList<CutoffItem>,
isLoading: Boolean
) {
Box(modifier = Modifier.fillMaxSize().padding(2.dp), contentAlignment = Alignment.Center) {
Box(
modifier = Modifier
.fillMaxSize()
.padding(2.dp), contentAlignment = Alignment.Center
) {
LazyColumn(Modifier.fillMaxWidth()) {
items(if (isLoading) List(20) { FakeCutoffItem }
else cutoffs) {
items(if (isLoading) List(20) { FakeCutoffItem } else cutoffs) {
ShimmerListItem(
isLoading = isLoading,
barCount = 3,
Expand Down Expand Up @@ -89,56 +95,16 @@ fun CBRCutoffs(
}
}
}
// if (!isLoading) {
// LazyColumn(
// modifier = Modifier.fillMaxWidth()
// ) {
// items(cutoffs) {
// Card(
// modifier = Modifier
// .height(200.dp)
// .fillMaxWidth()
// .padding(bottom = 5.dp),
// colors = CardDefaults.cardColors(containerColor = BlueShade1),
// elevation = CardDefaults.cardElevation(2.dp)
// ) {
// Column(
// modifier = Modifier
// .fillMaxSize()
// .padding(horizontal = 6.dp),
// verticalArrangement = Arrangement.SpaceEvenly
// ) {
// Text(text = it.Institute)
// Text(text = it.AcademicProgramName)
// Row(
// Modifier.fillMaxWidth(),
// horizontalArrangement = Arrangement.SpaceBetween
// ) {
// Text(text = it.Quota)
// Text(text = it.Gender.removeSuffix("(including Supernumerary)"))
// Text(text = it.SeatType)
// }
// Row(
// Modifier.fillMaxWidth(),
// horizontalArrangement = Arrangement.SpaceBetween
// ) {
// Text(
// text = "OR: ${it.OpeningRank}",
// fontFamily = FontFamily.Monospace,
// fontSize = 18.sp,
// fontWeight = FontWeight.Bold
// )
// Text(
// text = "CR: ${it.ClosingRank}",
// fontFamily = FontFamily.Monospace,
// fontSize = 18.sp,
// fontWeight = FontWeight.Bold
// )
// }
// }
// }
// }
// }
// }
if (!isLoading && cutoffs.isEmpty()) {
Column {
Image(
modifier = Modifier
.fillMaxSize()
.padding(20.dp),
painter = painterResource(id = R.drawable.no_data),
contentDescription = "No data available",
)
}
}
}
}
112 changes: 83 additions & 29 deletions app/src/main/java/com/bera/collegesearch/components/cbr/CBRFilters.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fun CBRFilters(modifier: Modifier = Modifier, state: CBRState, onAction: (CBRAct
)
val rotationState by animateFloatAsState(
targetValue = if (state.expandFilters) 270f else 0f,
animationSpec = tween(durationMillis = 300)
animationSpec = tween(durationMillis = 300), label = ""
)
Icon(
imageVector = Icons.Default.Settings,
Expand Down Expand Up @@ -175,14 +175,20 @@ fun CBRFilters(modifier: Modifier = Modifier, state: CBRState, onAction: (CBRAct
) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
RadioButton(selected = state.exam == "Adv",
enabled = state.exam != "Adv",
onClick = { onAction(CBRAction.Exam("Adv")) })
onClick = {
if (state.exam != "Adv") onAction(
CBRAction.Exam("Adv")
)
})
Text(text = "JEE-Adv", fontSize = 10.sp)
}
Column(horizontalAlignment = Alignment.CenterHorizontally) {
RadioButton(selected = state.exam == "Main",
enabled = state.exam != "Main",
onClick = { onAction(CBRAction.Exam("Main")) })
onClick = {
if (state.exam != "Main") onAction(
CBRAction.Exam("Main")
)
})
Text(text = "JEE-Main", fontSize = 10.sp)
}
}
Expand All @@ -203,14 +209,20 @@ fun CBRFilters(modifier: Modifier = Modifier, state: CBRState, onAction: (CBRAct
) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
RadioButton(selected = state.state == "HS",
enabled = state.state != "HS",
onClick = { onAction(CBRAction.State("HS")) })
onClick = {
if (state.state != "HS") onAction(
CBRAction.State("HS")
)
})
Text(text = "HS", fontSize = 10.sp)
}
Column(horizontalAlignment = Alignment.CenterHorizontally) {
RadioButton(selected = state.state == "OS",
enabled = state.state != "OS",
onClick = { onAction(CBRAction.State("OS")) })
onClick = {
if (state.state != "OS") onAction(
CBRAction.State("OS")
)
})
Text(text = "OS", fontSize = 10.sp)
}
}
Expand All @@ -231,20 +243,29 @@ fun CBRFilters(modifier: Modifier = Modifier, state: CBRState, onAction: (CBRAct
) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
RadioButton(selected = state.gender == "Gender-Neutral",
enabled = state.gender != "Gender-Neutral",
onClick = { onAction(CBRAction.Gender("Gender-Neutral")) })
onClick = {
if (state.gender != "Gender-Neutral") onAction(
CBRAction.Gender("Gender-Neutral")
)
})
Text(text = "Gender-Neutral", fontSize = 10.sp)
}
Column(horizontalAlignment = Alignment.CenterHorizontally) {
RadioButton(selected = state.gender == "Female",
enabled = state.gender != "Female",
onClick = { onAction(CBRAction.Gender("Female")) })
onClick = {
if (state.gender != "Female") onAction(
CBRAction.Gender("Female")
)
})
Text(text = "Female", fontSize = 10.sp)
}
Column(horizontalAlignment = Alignment.CenterHorizontally) {
RadioButton(selected = state.gender == "Supernumerary",
enabled = state.gender != "Supernumerary",
onClick = { onAction(CBRAction.Gender("Supernumerary")) })
onClick = {
if (state.gender != "Supernumerary") onAction(
CBRAction.Gender("Supernumerary")
)
})
Text(text = "Other", fontSize = 10.sp)
}
}
Expand All @@ -264,14 +285,24 @@ fun CBRFilters(modifier: Modifier = Modifier, state: CBRState, onAction: (CBRAct
) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
RadioButton(selected = state.pwd,
enabled = !state.pwd,
onClick = { onAction(CBRAction.PwD(true)) })
onClick = {
if (!state.pwd) onAction(
CBRAction.PwD(
true
)
)
})
Text(text = "Yes", fontSize = 10.sp)
}
Column(horizontalAlignment = Alignment.CenterHorizontally) {
RadioButton(selected = !state.pwd,
enabled = state.pwd,
onClick = { onAction(CBRAction.PwD(false)) })
onClick = {
if (state.pwd) onAction(
CBRAction.PwD(
false
)
)
})
Text(text = "No", fontSize = 10.sp)
}
}
Expand All @@ -290,32 +321,55 @@ fun CBRFilters(modifier: Modifier = Modifier, state: CBRState, onAction: (CBRAct
) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
RadioButton(selected = state.quota == "OPEN",
enabled = state.quota != "OPEN",
onClick = { onAction(CBRAction.Quota("OPEN")) })
onClick = {
if (state.quota != "OPEN") onAction(
CBRAction.Quota("OPEN")
)
})
Text(text = "OPEN", fontSize = 10.sp)
}
Column(horizontalAlignment = Alignment.CenterHorizontally) {
RadioButton(selected = state.quota == "EWS",
enabled = state.quota != "EWS",
onClick = { onAction(CBRAction.Quota("EWS")) })
onClick = {
if (state.quota != "EWS") onAction(
CBRAction.Quota(
"EWS"
)
)
})
Text(text = "EWS", fontSize = 10.sp)
}
Column(horizontalAlignment = Alignment.CenterHorizontally) {
RadioButton(selected = state.quota == "SC",
enabled = state.quota != "SC",
onClick = { onAction(CBRAction.Quota("SC")) })
onClick = {
if (state.quota != "SC") onAction(
CBRAction.Quota(
"SC"
)
)
})
Text(text = "SC", fontSize = 10.sp)
}
Column(horizontalAlignment = Alignment.CenterHorizontally) {
RadioButton(selected = state.quota == "ST",
enabled = state.quota != "ST",
onClick = { onAction(CBRAction.Quota("ST")) })
onClick = {
if (state.quota != "ST") onAction(
CBRAction.Quota(
"ST"
)
)
})
Text(text = "ST", fontSize = 10.sp)
}
Column(horizontalAlignment = Alignment.CenterHorizontally) {
RadioButton(selected = state.quota == "OBC",
enabled = state.quota != "OBC",
onClick = { onAction(CBRAction.Quota("OBC")) })
onClick = {
if (state.quota != "OBC") onAction(
CBRAction.Quota(
"OBC"
)
)
})
Text(text = "OBC", fontSize = 10.sp)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.bera.collegesearch.network
package com.bera.collegesearch.network.connectivity

import android.content.Context
import android.net.ConnectivityManager
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.bera.collegesearch.network
package com.bera.collegesearch.network.connectivity

enum class ConnectivityStatus {
Available, Unavailable
Expand Down
Loading

0 comments on commit 2e43d81

Please sign in to comment.