Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import com.arygm.quickfix.model.offline.small.PreferencesViewModel
import com.arygm.quickfix.model.offline.small.PreferencesViewModelUserProfile
import com.arygm.quickfix.model.switchModes.ModeViewModel
import com.arygm.quickfix.ressources.C
import com.arygm.quickfix.ui.navigation.NavigationActions
import com.arygm.quickfix.ui.profile.FakePreferencesRepository
import com.arygm.quickfix.ui.theme.QuickFixTheme
import com.arygm.quickfix.ui.uiMode.appContentUI.navigation.AppContentRoute
import com.arygm.quickfix.ui.uiMode.appContentUI.userModeUI.navigation.UserScreen
import com.arygm.quickfix.ui.uiMode.appContentUI.userModeUI.profile.becomeWorker.views.welcome.WelcomeOnBoardScreen
import com.arygm.quickfix.utils.IS_WORKER_KEY
Expand All @@ -36,9 +38,11 @@ class WelcomeOnBoardUserNoModeScreenTest {
// Initialize ViewModels
private lateinit var preferencesViewModel: PreferencesViewModel
private lateinit var userPreferencesViewModel: PreferencesViewModelUserProfile
private lateinit var modeViewModel: ModeViewModel

@Before
fun setup() {
modeViewModel = ModeViewModel()
// Initialize Mockito mocks for NavigationActions
navigationActions = mock(NavigationActions::class.java)
rootMainNavigationActions = mock(NavigationActions::class.java)
Expand All @@ -61,7 +65,11 @@ class WelcomeOnBoardUserNoModeScreenTest {
composeTestRule.setContent {
QuickFixTheme {
WelcomeOnBoardScreen(
navigationActions = navigationActions, preferencesViewModel = preferencesViewModel)
navigationActions = navigationActions,
preferencesViewModel = preferencesViewModel,
modeViewModel = modeViewModel,
testingFlag = true,
appContentNavigationActions = appContentNavigationActions)
}
}

Expand All @@ -79,7 +87,9 @@ class WelcomeOnBoardUserNoModeScreenTest {
WelcomeOnBoardScreen(
navigationActions = navigationActions,
preferencesViewModel = preferencesViewModel,
testingFlag = true)
modeViewModel = modeViewModel,
testingFlag = true,
appContentNavigationActions = appContentNavigationActions)
}
}
runBlocking { preferencesRepository.setPreference(IS_WORKER_KEY, true) }
Expand All @@ -97,14 +107,16 @@ class WelcomeOnBoardUserNoModeScreenTest {
WelcomeOnBoardScreen(
navigationActions = navigationActions,
preferencesViewModel = preferencesViewModel,
testingFlag = true)
modeViewModel = modeViewModel,
testingFlag = true,
appContentNavigationActions = appContentNavigationActions)
}
}
runBlocking { preferencesRepository.setPreference(IS_WORKER_KEY, true) }
// Perform click on "Stay User Mode" button
composeTestRule.onNodeWithTag(C.Tag.welcomeOnBoardScreenSwitchWorkerButton).performClick()

// Verify navigation to UserScreen.PROFILE
verify(navigationActions).navigateTo(UserScreen.PROFILE)
verify(appContentNavigationActions).navigateTo(AppContentRoute.WORKER_MODE)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,6 @@ class SearchWorkerResultScreenTest {
.filter(!hasTestTag("filter_button_Clear"))[0]
.performClick()
composeTestRule.waitForIdle()

// With availability cleared and no other filters applied, we should still see 2 workers
composeTestRule.onNodeWithTag("worker_profiles_list").onChildren().assertCountEquals(2)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ fun QuickFixProfileScreenElement(
.clip(RoundedCornerShape(buttonCornerRadius))
.testTag("AddFundsButton")
.background(
color = colorScheme.onPrimary,
color = colorScheme.surface,
shape = RoundedCornerShape(buttonCornerRadius))
.weight(0.35f),
) {
Expand Down Expand Up @@ -364,7 +364,7 @@ fun QuickFixProfileScreenElement(
},
shape = RoundedCornerShape(screenWidth * 0.04f),
border = BorderStroke(borderStrokeWidth, colorScheme.onBackground),
colors = ButtonDefaults.buttonColors(containerColor = colorScheme.onPrimary),
colors = ButtonDefaults.buttonColors(containerColor = colorScheme.surface),
modifier = Modifier.testTag("LogoutButton")) {
Text(
text = "Log out",
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/arygm/quickfix/ui/theme/Color.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@ val DarkTitlePrimary = Color(0xFF66001A)

/* Time selector */
val TimeSelectorUnselectedContainerColor = Color(0xFFE9E0E0)

val DarkRegisterColor = Color(0xFFB78080)
val LightRegisterColor = ButtonPrimary
10 changes: 8 additions & 2 deletions app/src/main/java/com/arygm/quickfix/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ private val LightColorScheme =
surfaceVariant = ButtonQuaternary, // Fourth button color
onSurfaceVariant = TextButtonQuaternary, // Text color for the quaternary button,
onSecondaryContainer = TextDisabled,
tertiaryContainer = ButtonDisabled)
tertiaryContainer = ButtonDisabled,
scrim = LightRegisterColor,
surfaceDim = DarkTextPrimary,
surfaceContainerLowest = TextButtonPrimary)

private val DarkColorScheme =
darkColorScheme(
Expand All @@ -58,7 +61,10 @@ private val DarkColorScheme =
surfaceVariant = DarkButtonQuaternary, // Fourth button color
onSurfaceVariant = DarkTextButtonQuaternary, // Text color for the quaternary button
onSecondaryContainer = DarkTextDisabled,
tertiaryContainer = DarkButtonDisabled)
tertiaryContainer = DarkButtonDisabled,
scrim = DarkRegisterColor,
surfaceDim = TextPrimary,
surfaceContainerLowest = TextSecondary)
val poppinsFontFamily =
FontFamily(
Font(R.font.poppins_black, FontWeight.Black, FontStyle.Normal),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ fun AppContentNavGraph(
workerViewModel,
quickFixViewModel,
chatViewModel,
categoryViewModel)
categoryViewModel,
userPreferencesViewModel)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,9 @@ fun ProfileNavHost(
locationViewModel,
testBitmapPP,
testLocation,
workerPreferencesViewModel)
workerPreferencesViewModel,
appContentNavigationActions,
modeViewModel)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import com.arygm.quickfix.ui.elements.QuickFixTextFieldCustom
import com.arygm.quickfix.ui.elements.QuickFixesWidget
import com.arygm.quickfix.ui.elements.Service
import com.arygm.quickfix.ui.navigation.NavigationActions
import com.arygm.quickfix.ui.theme.BackgroundSecondary
import com.arygm.quickfix.ui.theme.poppinsTypography
import com.arygm.quickfix.ui.uiMode.appContentUI.userModeUI.navigation.USER_TOP_LEVEL_DESTINATIONS
import com.arygm.quickfix.ui.uiMode.appContentUI.userModeUI.navigation.UserScreen
Expand Down Expand Up @@ -285,11 +286,19 @@ fun HomeScreen(
.background(colorScheme.surface),
verticalArrangement = Arrangement.spacedBy((-64).dp),
horizontalAlignment = Alignment.CenterHorizontally) {
Image(
painter = painterResource(id = R.drawable.noquickfix),
contentDescription = "No QuickFixes Background",
contentScale = ContentScale.Crop,
modifier = Modifier.size(180.dp).alpha(1f))
if (colorScheme.surface == BackgroundSecondary) {
Image(
painter = painterResource(id = R.drawable.noquickfix),
contentDescription = "No QuickFixes Background",
contentScale = ContentScale.Crop,
modifier = Modifier.size(180.dp).alpha(1f))
} else {
Image(
painter = painterResource(id = R.drawable.noquickfixdark),
contentDescription = "No QuickFixes Background",
contentScale = ContentScale.Crop,
modifier = Modifier.size(180.dp).alpha(1f))
}

Column(
horizontalAlignment = Alignment.CenterHorizontally,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,6 @@ fun MapScreen(
mapStyleOptions = MapStyleOptions.loadRawResourceStyle(context, currentStyle)),
onMapLoaded = { isMapLoaded = true }) {
filteredWorkers.forEach { profile ->
profile.location?.let {
val cityName = getCityNameFromCoordinates(it.latitude, profile.location.longitude)
if (cityName != null) {
workerAddress = cityName
} else {
workerAddress = profile.location.name
}
}
profile.location
?.let { LatLng(it.latitude, it.longitude) }
?.let { rememberMarkerState(position = it) }
Expand Down Expand Up @@ -249,6 +241,17 @@ fun MapScreen(
if (isWindowVisible) {
Popup(onDismissRequest = { isWindowVisible = false }, alignment = Alignment.Center) {
selectedWorker?.let {
selectedWorker!!.location?.let {
val cityName =
selectedWorker!!.location?.let { it1 ->
getCityNameFromCoordinates(it.latitude, it1.longitude)
}
if (cityName != null) {
workerAddress = cityName
} else {
workerAddress = selectedWorker!!.location!!.name
}
}
QuickFixSlidingWindowWorker(
isVisible = isWindowVisible,
onDismiss = { isWindowVisible = false },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import com.arygm.quickfix.model.profile.ProfileViewModel
import com.arygm.quickfix.model.profile.WorkerProfile
import com.arygm.quickfix.model.profile.dataFields.AddOnService
import com.arygm.quickfix.model.profile.dataFields.IncludedService
import com.arygm.quickfix.model.switchModes.ModeViewModel
import com.arygm.quickfix.ressources.C
import com.arygm.quickfix.ui.navigation.NavigationActions
import com.arygm.quickfix.ui.theme.poppinsTypography
Expand Down Expand Up @@ -76,7 +77,9 @@ fun BusinessScreen(
locationViewModel: LocationViewModel,
testBitmapPP: Bitmap? = null,
testLocation: Location = Location(),
workerPreferencesViewModel: PreferencesViewModelWorkerProfile
workerPreferencesViewModel: PreferencesViewModelWorkerProfile,
appContentNavigationActions: NavigationActions,
modeViewModel: ModeViewModel
) {
val locationWorker = remember { mutableStateOf(testLocation) }
val categories = categoryViewModel.categories.collectAsState().value
Expand Down Expand Up @@ -252,7 +255,11 @@ fun BusinessScreen(
workingHours = workingHours)
}
2 -> {
WelcomeOnBoardScreen(navigationActions, preferencesViewModel)
WelcomeOnBoardScreen(
appContentNavigationActions,
navigationActions,
preferencesViewModel,
modeViewModel = modeViewModel)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,22 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.arygm.quickfix.R
import com.arygm.quickfix.model.offline.small.PreferencesViewModel
import com.arygm.quickfix.model.switchModes.AppMode
import com.arygm.quickfix.model.switchModes.ModeViewModel
import com.arygm.quickfix.ressources.C
import com.arygm.quickfix.ui.elements.QuickFixButton
import com.arygm.quickfix.ui.navigation.NavigationActions
import com.arygm.quickfix.ui.theme.poppinsTypography
import com.arygm.quickfix.ui.uiMode.appContentUI.navigation.AppContentRoute
import com.arygm.quickfix.ui.uiMode.appContentUI.userModeUI.navigation.UserScreen
import com.arygm.quickfix.ui.uiMode.workerMode.navigation.WorkerScreen

@Composable
fun WelcomeOnBoardScreen(
appContentNavigationActions: NavigationActions,
navigationActions: NavigationActions,
preferencesViewModel: PreferencesViewModel,
testingFlag: Boolean = false
testingFlag: Boolean = false,
modeViewModel: ModeViewModel
) {
BoxWithConstraints {
val widthRatio = maxWidth / 411
Expand All @@ -52,11 +56,18 @@ fun WelcomeOnBoardScreen(
// If the user chooses "Switch Worker Mode," we set this to true and show a loader until
// isWorker == true
var isWaitingForWorkerMode by remember { mutableStateOf(false) }
var switchToWorkerProfile by remember { mutableStateOf(false) }
var switchToUserProfile by remember { mutableStateOf(false) }

// When isWorker changes, if we're waiting for worker mode and it's now true, navigate
LaunchedEffect(isWorker) {
if (isWaitingForWorkerMode && isWorker) {
navigationActions.navigateTo(WorkerScreen.PROFILE)
if (switchToWorkerProfile) {
modeViewModel.switchMode(AppMode.WORKER)
appContentNavigationActions.navigateTo(AppContentRoute.WORKER_MODE)
} else if (switchToUserProfile) {
navigationActions.navigateTo(UserScreen.PROFILE)
}
}
}
if (isWaitingForWorkerMode) {
Expand Down Expand Up @@ -99,6 +110,7 @@ fun WelcomeOnBoardScreen(
onClickAction = {
if (!testingFlag) {
isWaitingForWorkerMode = true
switchToUserProfile = true
} else {
navigationActions.navigateTo(UserScreen.PROFILE)
}
Expand All @@ -119,8 +131,9 @@ fun WelcomeOnBoardScreen(
onClickAction = {
if (!testingFlag) {
isWaitingForWorkerMode = true
switchToWorkerProfile = true
} else {
navigationActions.navigateTo(UserScreen.PROFILE)
appContentNavigationActions.navigateTo(AppContentRoute.WORKER_MODE)
}
},
buttonColor = colorScheme.onPrimary,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import com.arygm.quickfix.model.locations.LocationViewModel
import com.arygm.quickfix.model.messaging.ChatViewModel
import com.arygm.quickfix.model.offline.small.PreferencesRepositoryDataStore
import com.arygm.quickfix.model.offline.small.PreferencesViewModel
import com.arygm.quickfix.model.offline.small.PreferencesViewModelUserProfile
import com.arygm.quickfix.model.offline.small.PreferencesViewModelWorkerProfile
import com.arygm.quickfix.model.profile.ProfileViewModel
import com.arygm.quickfix.model.profile.WorkerProfileRepositoryFirestore
Expand Down Expand Up @@ -75,7 +76,8 @@ fun WorkerModeNavGraph(
workerViewModel: ProfileViewModel,
quickFixViewModel: QuickFixViewModel,
chatViewModel: ChatViewModel,
categoryViewModel: CategoryViewModel
categoryViewModel: CategoryViewModel,
userPreferencesViewModel: PreferencesViewModelUserProfile
) {
val context = LocalContext.current
val workerNavController = rememberNavController()
Expand Down Expand Up @@ -167,7 +169,8 @@ fun WorkerModeNavGraph(
accountViewModel,
workerNavigationActions,
rootMainNavigationActions,
workerPreferenceViewModel)
workerPreferenceViewModel,
userPreferencesViewModel)
}
}

Expand Down Expand Up @@ -325,7 +328,8 @@ fun ProfileNavHost(
accountViewModel: AccountViewModel,
workerNavigationActions: NavigationActions,
rootMainNavigationActions: NavigationActions,
workerPreferenceViewModel: PreferencesViewModelWorkerProfile
workerPreferenceViewModel: PreferencesViewModelWorkerProfile,
userPreferencesViewModel: PreferencesViewModelUserProfile
) {
val profileNavController = rememberNavController()
val profileNavigationActions = remember { NavigationActions(profileNavController) }
Expand All @@ -343,7 +347,8 @@ fun ProfileNavHost(
preferencesViewModel,
workerPreferenceViewModel,
appContentNavigationActions,
modeViewModel)
modeViewModel,
userPreferencesViewModel)
}
composable(WorkerScreen.ACCOUNT_CONFIGURATION) {
AccountConfigurationScreen(profileNavigationActions, accountViewModel, preferencesViewModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.unit.dp
import com.arygm.quickfix.model.offline.small.PreferencesViewModel
import com.arygm.quickfix.model.offline.small.PreferencesViewModelUserProfile
import com.arygm.quickfix.model.offline.small.PreferencesViewModelWorkerProfile
import com.arygm.quickfix.model.switchModes.AppMode
import com.arygm.quickfix.model.switchModes.ModeViewModel
Expand All @@ -29,7 +30,8 @@ fun WorkerProfileScreen(
preferencesViewModel: PreferencesViewModel,
workerPreferencesViewModel: PreferencesViewModelWorkerProfile,
appContentNavigationActions: NavigationActions,
modeViewModel: ModeViewModel
modeViewModel: ModeViewModel,
userPreferencesViewModel: PreferencesViewModelUserProfile
) {
val isWorker by preferencesViewModel.isWorkerFlow.collectAsState(initial = false)

Expand Down Expand Up @@ -71,6 +73,7 @@ fun WorkerProfileScreen(
val screenWidth = maxWidth
val screenHeight = maxHeight
QuickFixProfileScreenElement(
userPreferencesViewModel = userPreferencesViewModel,
modeNavigationActions = workerNavigationActions,
navigationActions = navigationActions,
rootMainNavigationActions = rootMainNavigationActions,
Expand Down
Loading
Loading