Skip to content

Commit

Permalink
Merge pull request #31 from haroldjose30/feature/18-us05-improve-design
Browse files Browse the repository at this point in the history
Feature/18 us05 improve design
  • Loading branch information
haroldjose30 authored May 10, 2024
2 parents 1f87621 + f0fa06e commit 9c4c786
Show file tree
Hide file tree
Showing 44 changed files with 185 additions and 142 deletions.
2 changes: 2 additions & 0 deletions androidApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.ktx.Firebase
import dev.haroldjose.familysharedlist.AndroidPlatform
import dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator.views.NavigatorPage
import dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator.views.Router
import org.koin.androidx.compose.KoinAndroidContext
import org.koin.core.annotation.KoinExperimentalAPI

Expand All @@ -26,17 +27,37 @@ class MainActivity : ComponentActivity() {
AndroidPlatform.androidContextForKmm = this
AndroidPlatform.isDebuggable = (0 != applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE)


var initialRoute = handleInitialRoute()
setContent {
MyApplicationTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
KoinAndroidContext() {
NavigatorPage()
NavigatorPage(
initialRoute = initialRoute
)
}
}
}
}
}

private fun handleInitialRoute(): Router {

//handle shortcuts
val shortcutValue = intent.getStringExtra("shortcut_key")
when (shortcutValue) {

Router.QUICK_INSERT.value -> {
return Router.QUICK_INSERT
}

else -> {
return Router.FAMILY_LIST
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator.viewmodels

import androidx.navigation.NavHostController
import dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator.views.Router

interface INavigatorViewModel {

var viewState: NavigatorViewState
suspend fun checkIfNeedToCreateNewAccount(navController: NavHostController)
suspend fun checkIfNeedToCreateNewAccount(navController: NavHostController, initialRoute: Router)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.navigation.NavHostController
import dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator.views.NavigatorRouter
import dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator.views.Router
import dev.haroldjose.familysharedlist.domainLayer.usecases.account.GetOrCreateAccountFromLocalUuidUseCase
import dev.haroldjose.familysharedlist.services.firebase.IFirebaseCrashlytics

Expand All @@ -15,12 +15,12 @@ class NavigatorViewModel(
): ViewModel(), INavigatorViewModel {
override var viewState: NavigatorViewState by mutableStateOf(NavigatorViewState.Initial)

override suspend fun checkIfNeedToCreateNewAccount(navController: NavHostController) {
override suspend fun checkIfNeedToCreateNewAccount(navController: NavHostController, initialRoute: Router) {
viewState = NavigatorViewState.Loading
try {
getOrCreateAccountFromLocalUuidUseCase.execute()
viewState = NavigatorViewState.Success
navController.navigate(NavigatorRouter.FAMILY_LIST.value)
navController.navigate(initialRoute.value)
} catch (e: Throwable) {
crashlytics.record(e)
viewState = NavigatorViewState.Error(e.message ?: "Ocorreu um erro inesperado. Tente novamente.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigato

import androidx.lifecycle.ViewModel
import androidx.navigation.NavHostController
import dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator.views.Router

class NavigatorViewModelMock(): ViewModel(), INavigatorViewModel {
override var viewState: NavigatorViewState = NavigatorViewState.Initial
override suspend fun checkIfNeedToCreateNewAccount(navController: NavHostController) {}
override suspend fun checkIfNeedToCreateNewAccount(navController: NavHostController,initialRoute: Router) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,33 @@ fun NavigatorPage(
navigatorViewModel: INavigatorViewModel = koinViewModel<NavigatorViewModel>(),
quickInsertListViewModel: IQuickInsertListViewModel = koinViewModel<QuickInsertListViewModel>(),
settingsViewModel: ISettingsViewModel = koinViewModel<SettingsViewModel>(),
familyListViewModel: IFamilyListViewModel = koinViewModel<FamilyListViewModel>()
familyListViewModel: IFamilyListViewModel = koinViewModel<FamilyListViewModel>(),
initialRoute: Router
) {
val coroutineScope: CoroutineScope = rememberCoroutineScope()
val navController: NavHostController = rememberNavController()

quickInsertListViewModel.goToFamilyListPage = { navController.navigate(NavigatorRouter.FAMILY_LIST.value) }
settingsViewModel.goBack = { navController.navigate(NavigatorRouter.FAMILY_LIST.value) }
familyListViewModel.goToSetting = { navController.navigate(NavigatorRouter.SETTINGS.value) }
familyListViewModel.goToQuickInsert = { navController.navigate(NavigatorRouter.QUICK_INSERT.value) }
quickInsertListViewModel.goToFamilyListPage = { navController.navigate(Router.FAMILY_LIST.value) }
settingsViewModel.goBack = { navController.navigate(Router.FAMILY_LIST.value) }
familyListViewModel.goToSetting = { navController.navigate(Router.SETTINGS.value) }
familyListViewModel.goToQuickInsert = { navController.navigate(Router.QUICK_INSERT.value) }

LaunchedEffect(key1 = "NavigatorView") {
navigatorViewModel.checkIfNeedToCreateNewAccount(navController)
navigatorViewModel.checkIfNeedToCreateNewAccount(navController, initialRoute)
}

NavHost(navController = navController, startDestination = NavigatorRouter.NAVIGATOR.value) {
composable(NavigatorRouter.FAMILY_LIST.value) {
NavHost(navController = navController, startDestination = Router.NAVIGATOR.value) {
composable(Router.FAMILY_LIST.value) {
FamilyListPage(familyListViewModel)
}
composable(NavigatorRouter.SETTINGS.value) {
composable(Router.SETTINGS.value) {
SettingsPage(settingsViewModel)
}
composable(NavigatorRouter.QUICK_INSERT.value) {
composable(Router.QUICK_INSERT.value) {
QuickInsertListPage(quickInsertListViewModel)
}
composable(NavigatorRouter.NAVIGATOR.value) {
LoadingOrErrorPage(navController, coroutineScope, navigatorViewModel)
composable(Router.NAVIGATOR.value) {
LoadingOrErrorPage(navController, coroutineScope, navigatorViewModel, initialRoute)
}
}
}
Expand All @@ -74,7 +75,8 @@ fun NavigatorPage(
private fun LoadingOrErrorPage(
navController: NavHostController,
coroutineScope: CoroutineScope,
navigatorViewModel: INavigatorViewModel
navigatorViewModel: INavigatorViewModel,
initialRoute: Router
) {
when (navigatorViewModel.viewState) {
is NavigatorViewState.Initial, NavigatorViewState.Loading, NavigatorViewState.Success -> CircularProgressIndicator(
Expand All @@ -85,7 +87,8 @@ private fun LoadingOrErrorPage(
is NavigatorViewState.Error -> ErrorPage((navigatorViewModel.viewState as NavigatorViewState.Error).message) {
coroutineScope.launch {
navigatorViewModel.checkIfNeedToCreateNewAccount(
navController
navController,
initialRoute
)
}
}
Expand All @@ -100,7 +103,8 @@ fun FamilyListPage_Preview() {
navigatorViewModel = NavigatorViewModelMock(),
quickInsertListViewModel = QuickInsertListViewModelMocked(),
settingsViewModel = SettingsViewModelMocked(),
familyListViewModel= FamilyListViewModelMocked()
familyListViewModel= FamilyListViewModelMocked(),
initialRoute = Router.NAVIGATOR
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator.views

enum class NavigatorRouter(val value: String) {
enum class Router(val value: String) {
FAMILY_LIST("family_list"),
SETTINGS("setting"),
QUICK_INSERT("quick_insert"),
Expand Down
3 changes: 3 additions & 0 deletions androidApp/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Family List</string>
<string name="quick_insert_shortcut_short_label">Inclusão rápida</string>
<string name="quick_insert_shortcut_long_label">crie vários itens de uma só vez</string>
<string name="quick_insert_disabled_message">indisponível no momento</string>
</resources>
16 changes: 16 additions & 0 deletions androidApp/src/main/res/xml/shortcuts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="quick_insert"
android:enabled="true"
android:icon="@drawable/list_alt_add"
android:shortcutShortLabel="@string/quick_insert_shortcut_short_label"
android:shortcutLongLabel="@string/quick_insert_shortcut_long_label"
android:shortcutDisabledMessage="@string/quick_insert_disabled_message">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="dev.haroldjose.familysharedlist.android"
android:targetClass="dev.haroldjose.familysharedlist.android.app.MainActivity">
<extra android:name="shortcut_key" android:value="quick_insert" />
</intent>
</shortcut>
</shortcuts>
20 changes: 20 additions & 0 deletions iosApp/iosApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
527A6A102BE5C0EE000C565D /* NavigatorViewState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 527A6A0F2BE5C0EE000C565D /* NavigatorViewState.swift */; };
527A6A122BE5C3C7000C565D /* FamilyListViewState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 527A6A112BE5C3C7000C565D /* FamilyListViewState.swift */; };
527A6A142BE6DC0F000C565D /* FirebaseCrashlytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 527A6A132BE6DC0F000C565D /* FirebaseCrashlytics.swift */; };
5296515B2BED7F9B005F5E19 /* RouterType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5296515A2BED7F9B005F5E19 /* RouterType.swift */; };
5296515D2BED8C14005F5E19 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5296515C2BED8C14005F5E19 /* SceneDelegate.swift */; };
5296515F2BED8C79005F5E19 /* RouterService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5296515E2BED8C79005F5E19 /* RouterService.swift */; };
52B326972BDD689A00D12B05 /* FirebaseAnalytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52B326962BDD689A00D12B05 /* FirebaseAnalytics.swift */; };
52B326992BDD736A00D12B05 /* nativeModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52B326982BDD736A00D12B05 /* nativeModule.swift */; };
52BD908C2BC0B6DE00C88B84 /* FamilyListPageTabEnum.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52BD908B2BC0B6DE00C88B84 /* FamilyListPageTabEnum.swift */; };
Expand Down Expand Up @@ -127,6 +130,9 @@
527A6A0F2BE5C0EE000C565D /* NavigatorViewState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigatorViewState.swift; sourceTree = "<group>"; };
527A6A112BE5C3C7000C565D /* FamilyListViewState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FamilyListViewState.swift; sourceTree = "<group>"; };
527A6A132BE6DC0F000C565D /* FirebaseCrashlytics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirebaseCrashlytics.swift; sourceTree = "<group>"; };
5296515A2BED7F9B005F5E19 /* RouterType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RouterType.swift; sourceTree = "<group>"; };
5296515C2BED8C14005F5E19 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
5296515E2BED8C79005F5E19 /* RouterService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RouterService.swift; sourceTree = "<group>"; };
52B326962BDD689A00D12B05 /* FirebaseAnalytics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirebaseAnalytics.swift; sourceTree = "<group>"; };
52B326982BDD736A00D12B05 /* nativeModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = nativeModule.swift; sourceTree = "<group>"; };
52BD908B2BC0B6DE00C88B84 /* FamilyListPageTabEnum.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FamilyListPageTabEnum.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -310,6 +316,15 @@
path = error;
sourceTree = "<group>";
};
529651602BED8D8E005F5E19 /* router */ = {
isa = PBXGroup;
children = (
5296515E2BED8C79005F5E19 /* RouterService.swift */,
5296515A2BED7F9B005F5E19 /* RouterType.swift */,
);
path = router;
sourceTree = "<group>";
};
52B326952BDD688900D12B05 /* services */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -531,13 +546,15 @@
52FD81A02BBDD72500D6FEE3 /* iOSApp+configureIsRunningUITests.swift */,
52385F362BC1C7E4009E46F4 /* AppConstants.swift */,
523509F82BD3273100BC2F51 /* AppDelegate.swift */,
5296515C2BED8C14005F5E19 /* SceneDelegate.swift */,
);
path = app;
sourceTree = "<group>";
};
52FD81B22BBDD87300D6FEE3 /* presentationLayer */ = {
isa = PBXGroup;
children = (
529651602BED8D8E005F5E19 /* router */,
52FD81B32BBDD8E500D6FEE3 /* components */,
52FD818D2BBDD72500D6FEE3 /* pages */,
);
Expand Down Expand Up @@ -771,9 +788,11 @@
523E95EE2BE9B76300ECEBBF /* year+month+day.swift in Sources */,
52FD81A52BBDD72500D6FEE3 /* LazyKoin.swift in Sources */,
52FD81B52BBDDA9E00D6FEE3 /* QuantitySelectionView.swift in Sources */,
5296515D2BED8C14005F5E19 /* SceneDelegate.swift in Sources */,
524120D22BEAF86F00C1E1D3 /* CurrencyField.swift in Sources */,
52FD81B82BBDE1B100D6FEE3 /* QuickInsertListPage.swift in Sources */,
523D9BD72BE81C010014A86F /* toCurrencyFormat.swift in Sources */,
5296515F2BED8C79005F5E19 /* RouterService.swift in Sources */,
52D7B6D12BC7433E00037A17 /* isDigitsOnly.swift in Sources */,
523D9BD02BE7D5B40014A86F /* ColumnRigthEditingName.swift in Sources */,
52385F372BC1C7E4009E46F4 /* AppConstants.swift in Sources */,
Expand Down Expand Up @@ -804,6 +823,7 @@
52385F2F2BC1B2BD009E46F4 /* ListBackgroundClearModifier.swift in Sources */,
52DE60A32BBF522000C12669 /* SettingsItemWithInputTextView.swift in Sources */,
524120D02BEAE43200C1E1D3 /* FamilyListBottomSheetOpenImage.swift in Sources */,
5296515B2BED7F9B005F5E19 /* RouterType.swift in Sources */,
52FD81BA2BBDE23F00D6FEE3 /* QuickInsertListViewModelProtocol.swift in Sources */,
52FD81AC2BBDD72600D6FEE3 /* toInt32.swift in Sources */,
);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9c4c786

Please sign in to comment.