Skip to content

Commit

Permalink
#18 - us05 - fix some issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Harold Jose committed Apr 2, 2024
1 parent 5570dd5 commit 7ef584b
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 51 deletions.
20 changes: 20 additions & 0 deletions androidApp/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "dev.haroldjose.familysharedlist.android",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "androidApp-release.apk"
}
],
"elementType": "File"
}
3 changes: 2 additions & 1 deletion androidApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

<application
android:name=".app.MainApplication"
android:label="@string/app_name"
android:allowBackup="true"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".app.MainActivity"
android:exported="true">
<intent-filter>
<intent-filter android:label="@string/app_name">>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.*
import androidx.compose.ui.Modifier
import dev.haroldjose.familysharedlist.AndroidPlatform
import dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator.NavigationView
import dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator.NavigatorView
import org.koin.compose.koinInject

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -22,7 +23,7 @@ class MainActivity : ComponentActivity() {
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
NavigationView()
NavigatorView(viewModel = koinInject())
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package dev.haroldjose.familysharedlist.android.dependencyInjection

import dev.haroldjose.familysharedlist.android.presentationLayer.pages.familyList.FamilyListViewModel
import dev.haroldjose.familysharedlist.android.presentationLayer.pages.familyList.IFamilyListViewModel
import dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator.INavigatorViewModel
import dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator.NavigatorViewModel
import dev.haroldjose.familysharedlist.android.presentationLayer.pages.quickInsertList.IQuickInsertListViewModel
import dev.haroldjose.familysharedlist.android.presentationLayer.pages.quickInsertList.QuickInsertListViewModel
import dev.haroldjose.familysharedlist.android.presentationLayer.pages.settings.ISettingsViewModel
Expand All @@ -15,4 +17,5 @@ val androidModule = module {
factoryOf(::SettingsViewModel) bind ISettingsViewModel::class
factoryOf(::FamilyListViewModel) bind IFamilyListViewModel::class
factoryOf(::QuickInsertListViewModel) bind IQuickInsertListViewModel::class
factoryOf(::NavigatorViewModel) bind INavigatorViewModel::class
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator

interface INavigatorViewModel {
suspend fun checkIfNeedToCreateNewAccount()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigato
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.NavHostController
import androidx.navigation.Navigator
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
Expand All @@ -17,7 +16,9 @@ import dev.haroldjose.familysharedlist.android.presentationLayer.pages.settings.
import org.koin.compose.koinInject

@Composable
fun NavigationView() {
fun NavigatorView(
viewModel: INavigatorViewModel
) {
val navController: NavHostController = rememberNavController()
NavHost(navController = navController, startDestination = ViewRouter.QUICK_INSERT.value) {
composable(ViewRouter.FAMILY_LIST.value) {
Expand Down Expand Up @@ -63,7 +64,7 @@ private enum class ViewRouter(val value: String) {
@Composable
fun FamilyListPage_Preview() {
MyApplicationTheme {
NavigationView()
NavigatorView(viewModel = NavigatorViewModelMock())
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package dev.haroldjose.familysharedlist.android.presentationLayer.pages.navigator

import dev.haroldjose.familysharedlist.domainLayer.usecases.account.GetOrCreateAccountFromLocalUuidUseCase

class NavigatorViewModel(
private val getOrCreateAccountFromLocalUuidUseCase: GetOrCreateAccountFromLocalUuidUseCase,
): INavigatorViewModel {
override suspend fun checkIfNeedToCreateNewAccount() {
getOrCreateAccountFromLocalUuidUseCase.execute()
}
}

class NavigatorViewModelMock(): INavigatorViewModel {
override suspend fun checkIfNeedToCreateNewAccount() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
Expand All @@ -16,7 +14,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardCapitalization
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -57,8 +54,7 @@ fun QuickInsertListPage(
keyboardOptions = KeyboardOptions(
capitalization = KeyboardCapitalization.None,
autoCorrect = true,
keyboardType = KeyboardType.Text,
imeAction = ImeAction.Done
keyboardType = KeyboardType.Text
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ class QuickInsertListViewModel(

if (text.isEmpty()) return

val listOfItem = text.lines().map { item ->
val listOfItem = text.lines().mapNotNull { item ->

//extrai os numeros
val quantityStr = item.filter { it.isDigit() }.toIntOrNull()
//extrai o nome
val name = item.filter { !it.isDigit() }
return@map FamilyListModel(

if (name.isEmpty())
return@mapNotNull null

return@mapNotNull FamilyListModel(
name = name.ifEmpty { item },
isPrioritized = true,
quantity = quantityStr ?: 1
Expand Down
4 changes: 4 additions & 0 deletions androidApp/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Family List</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,8 @@ class GetOrCreateAccountFromLocalUuidUseCase(
private fun getOrCreateUuid(): String {

//try to get local UUID
val accountUuid = keyValueStorageRepository.getString(
key = KeyValueStorageRepositoryEnum.ACCOUNT_UUID
)

accountUuid?.let {
if (it.isNotEmpty()) {
return it
}
keyValueStorageRepository.getString(key = KeyValueStorageRepositoryEnum.ACCOUNT_UUID)?.let {
if (it.isNotEmpty()) return it
}

//Generate new Account UUID for this device
Expand Down

0 comments on commit 7ef584b

Please sign in to comment.