-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
9,270 additions
and
69 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/jocmp/capyreader/ui/accounts/AddAccountScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.jocmp.capyreader.ui.accounts | ||
|
||
import androidx.compose.runtime.Composable | ||
import org.koin.compose.koinInject | ||
|
||
@Composable | ||
fun AddAccountScreen( | ||
onAddSuccess: () -> Unit, | ||
onNavigateToLogin: () -> Unit, | ||
viewModel: AddAccountViewModel = koinInject() | ||
) { | ||
AddAccountView( | ||
onSelectLocal = { | ||
viewModel.addLocalAccount() | ||
onAddSuccess() | ||
}, | ||
onSelectFeedbin = onNavigateToLogin | ||
) | ||
} |
59 changes: 59 additions & 0 deletions
59
app/src/main/java/com/jocmp/capyreader/ui/accounts/AddAccountView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.jocmp.capyreader.ui.accounts | ||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.rememberScrollState | ||
import androidx.compose.foundation.verticalScroll | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.capitalize | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.jocmp.capy.accounts.Source | ||
|
||
@Composable | ||
fun AddAccountView( | ||
onSelectLocal: () -> Unit, | ||
onSelectFeedbin: () -> Unit, | ||
) { | ||
Column( | ||
Modifier.verticalScroll(rememberScrollState()) | ||
) { | ||
SourceRow( | ||
source = Source.LOCAL, | ||
onClick = onSelectLocal | ||
) | ||
SourceRow( | ||
source = Source.FEEDBIN, | ||
onClick = onSelectFeedbin | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
private fun SourceRow(source: Source, onClick: () -> Unit) { | ||
Row( | ||
Modifier | ||
.fillMaxWidth() | ||
.padding(16.dp) | ||
.clickable { | ||
onClick() | ||
} | ||
) { | ||
Text(text = source.value.capitalize()) | ||
} | ||
} | ||
|
||
|
||
@Preview | ||
@Composable | ||
private fun AddAccountViewPreview() { | ||
AddAccountView( | ||
onSelectLocal = {}, | ||
onSelectFeedbin = {} | ||
) | ||
} |
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/jocmp/capyreader/ui/accounts/AddAccountViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.jocmp.capyreader.ui.accounts | ||
|
||
import androidx.lifecycle.ViewModel | ||
import com.jocmp.capy.AccountManager | ||
import com.jocmp.capy.accounts.Source | ||
import com.jocmp.capyreader.common.AppPreferences | ||
import com.jocmp.capyreader.loadAccountModules | ||
|
||
class AddAccountViewModel( | ||
private val accountManager: AccountManager, | ||
private val appPreferences: AppPreferences, | ||
) : ViewModel() { | ||
fun addLocalAccount() { | ||
val accountID = accountManager.createAccount(source = Source.LOCAL) | ||
|
||
selectAccount(accountID) | ||
|
||
loadAccountModules() | ||
} | ||
|
||
private fun selectAccount(id: String) { | ||
appPreferences.accountID.set(id) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletion
8
.../jocmp/capyreader/ui/login/LoginModule.kt → ...cmp/capyreader/ui/accounts/LoginModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
.../jocmp/capyreader/ui/login/LoginScreen.kt → ...cmp/capyreader/ui/accounts/LoginScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
app/src/main/java/com/jocmp/capyreader/ui/components/NavGraphBuilderExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.jocmp.capyreader.ui.components | ||
|
||
import androidx.compose.animation.AnimatedContentScope | ||
import androidx.compose.animation.AnimatedContentTransitionScope | ||
import androidx.compose.animation.EnterTransition | ||
import androidx.compose.animation.ExitTransition | ||
import androidx.compose.runtime.Composable | ||
import androidx.navigation.NamedNavArgument | ||
import androidx.navigation.NavBackStackEntry | ||
import androidx.navigation.NavDeepLink | ||
import androidx.navigation.NavGraphBuilder | ||
import androidx.navigation.compose.composable | ||
import com.jocmp.capyreader.ui.Route | ||
|
||
fun NavGraphBuilder.composable( | ||
route: Route, | ||
arguments: List<NamedNavArgument> = emptyList(), | ||
deepLinks: List<NavDeepLink> = emptyList(), | ||
enterTransition: (@JvmSuppressWildcards | ||
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null, | ||
exitTransition: (@JvmSuppressWildcards | ||
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null, | ||
popEnterTransition: (@JvmSuppressWildcards | ||
AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = | ||
enterTransition, | ||
popExitTransition: (@JvmSuppressWildcards | ||
AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = | ||
exitTransition, | ||
content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit | ||
) = composable( | ||
route.path, | ||
arguments, | ||
deepLinks, | ||
enterTransition, | ||
exitTransition, | ||
popEnterTransition, | ||
popExitTransition, | ||
content | ||
) |
Oops, something went wrong.