Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update add-account view #125

Merged
merged 1 commit into from
Jun 27, 2024
Merged
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
Update add-account view
jocmp committed Jun 27, 2024

Partially verified

This commit is signed with the committer’s verified signature.
spydon’s contribution has been verified via GPG key.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
commit 66110ee26f0f2604ec56bf0ea9b6061e5da1ffda
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Capy Reader

[![CalVer v2024.06.1000][img_version]][url_version]
[![CalVer 2024.06.1000][img_version]][url_version]

<img src="./site/capy.png" width="100px">

_A smallish RSS reader with support for Feedbin and local feeds._

[img_version]: https://img.shields.io/static/v1.svg?label=CalVer&message=v2024.06.1000&color=blue
[img_version]: https://img.shields.io/static/v1.svg?label=CalVer&message=2024.06.1000&color=blue
[url_version]: https://github.com/jocmp/capyreader
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ android {
minSdk = 30
targetSdk = 34
versionCode = 1000
versionName = "v2024.06.1000"
versionName = "2024.06.1000"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
2 changes: 1 addition & 1 deletion app/src/main/java/com/jocmp/capyreader/ui/App.kt
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ fun App(
},
onAddSuccess = {
navController.navigate(Route.Articles) {
popUpTo(Route.Login.path) {
popUpTo(Route.AddAccount.path) {
inclusive = true
}
}
73 changes: 73 additions & 0 deletions app/src/main/java/com/jocmp/capyreader/ui/accounts/AccountRow.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.jocmp.capyreader.ui.accounts

import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.width
import androidx.compose.material3.ListItem
import androidx.compose.material3.MaterialTheme.colorScheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.jocmp.capy.accounts.Source
import com.jocmp.capyreader.R
import com.jocmp.capyreader.ui.theme.CapyTheme

@Composable
fun AccountRow(
source: Source
) {
val item = buildItem(source = source)

ListItem(
headlineContent = {
Text(text = item.title)
},
leadingContent = {
Image(
painter = painterResource(id = item.iconID),
contentDescription = null,
modifier = Modifier.width(36.dp),
colorFilter = ColorFilter.tint(colorScheme.onSurface)
)
}
)
}

@Composable
private fun buildItem(source: Source): SourceModel {
return when (source) {
Source.LOCAL ->
SourceModel(
title = stringResource(R.string.account_source_local),
iconID = R.drawable.rss_logo
)

Source.FEEDBIN ->
SourceModel(
title = stringResource(R.string.account_source_feedbin),
iconID = R.drawable.feedbin_logo
)
}
}

private data class SourceModel(
val title: String,
@DrawableRes val iconID: Int,
)

@Preview
@Composable
private fun FeedbinAccountRow() {
CapyTheme {
Column {
AccountRow(source = Source.FEEDBIN)
AccountRow(source = Source.LOCAL)
}
}
}
111 changes: 84 additions & 27 deletions app/src/main/java/com/jocmp/capyreader/ui/accounts/AddAccountView.kt
Original file line number Diff line number Diff line change
@@ -1,59 +1,116 @@
package com.jocmp.capyreader.ui.accounts

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.LargeTopAppBar
import androidx.compose.material3.MaterialTheme.typography
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.Stable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.capitalize
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.jocmp.capy.accounts.Source
import com.jocmp.capyreader.R
import com.jocmp.capyreader.ui.LocalWindowWidth
import com.jocmp.capyreader.ui.components.widthMaxSingleColumn
import com.jocmp.capyreader.ui.isCompact
import com.jocmp.capyreader.ui.theme.CapyTheme

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AddAccountView(
onSelectLocal: () -> Unit,
onSelectFeedbin: () -> Unit,
) {
Column(
Modifier.verticalScroll(rememberScrollState())
) {
SourceRow(
source = Source.LOCAL,
onClick = onSelectLocal
)
SourceRow(
source = Source.FEEDBIN,
onClick = onSelectFeedbin
)
Scaffold { padding ->
Box(
contentAlignment = contentAlignment(),
modifier = Modifier
.fillMaxSize()
.padding(padding)
) {
Column(
verticalArrangement = Arrangement.spacedBy(16.dp),
modifier = Modifier
.widthMaxSingleColumn()
.verticalScroll(rememberScrollState())
) {
Text(
text = stringResource(R.string.add_account_title),
style = typography.headlineMedium,
modifier = Modifier
.padding(titlePadding())
)
Row(Modifier.clickable { onSelectFeedbin() }) {
AccountRow(source = Source.FEEDBIN)
}
Row(Modifier.clickable { onSelectLocal() }) {
AccountRow(source = Source.LOCAL)
}
}
}
}
}

@Composable
private fun SourceRow(source: Source, onClick: () -> Unit) {
Row(
Modifier
.fillMaxWidth()
.padding(16.dp)
.clickable {
onClick()
}
) {
Text(text = source.value.capitalize())
private fun contentAlignment(): Alignment {
val width = LocalWindowWidth.current

return if (width.isCompact) {
Alignment.TopCenter
} else {
Alignment.Center
}
}

@Composable
private fun titlePadding(): PaddingValues {
val width = LocalWindowWidth.current

return if (width.isCompact) {
PaddingValues(top = 56.dp, start = 16.dp, end = 16.dp)
} else {
PaddingValues(start = 16.dp, end = 16.dp)
}
}

@Preview
@Composable
private fun AddAccountViewPreview() {
AddAccountView(
onSelectLocal = {},
onSelectFeedbin = {}
)
CapyTheme {
AddAccountView(
onSelectLocal = {},
onSelectFeedbin = {}
)
}
}

@Preview(device = "id:pixel_fold")
@Composable
private fun AddAccountViewPreview_Tablet() {
CompositionLocalProvider(LocalWindowWidth provides WindowWidthSizeClass.Medium) {
CapyTheme {
AddAccountView(
onSelectLocal = {},
onSelectFeedbin = {}
)
}
}
}
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ import androidx.compose.ui.unit.dp
import com.jocmp.capyreader.R
import com.jocmp.capyreader.setupCommonModules
import com.jocmp.capyreader.ui.components.CrashReportingCheckbox
import com.jocmp.capyreader.ui.components.widthMaxSingleColumn
import org.koin.android.ext.koin.androidContext
import org.koin.compose.KoinApplication

@@ -47,8 +48,7 @@ fun LoginView(
.padding(padding)
) {
Column(
modifier = Modifier
.widthIn(max = 400.dp)
modifier = Modifier.widthMaxSingleColumn()
) {
Column(
verticalArrangement = Arrangement.spacedBy(16.dp),
9 changes: 9 additions & 0 deletions app/src/main/java/com/jocmp/capyreader/ui/components/Size.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.jocmp.capyreader.ui.components

import androidx.compose.foundation.layout.widthIn
import androidx.compose.runtime.Stable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

@Stable
fun Modifier.widthMaxSingleColumn() = then(Modifier.widthIn(max = 600.dp))
19 changes: 19 additions & 0 deletions app/src/main/res/drawable/feedbin_logo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!--
Copyright 2013 Ben Ubois
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="50dp"
android:height="47dp"
android:viewportWidth="50"
android:viewportHeight="47">
<group>
<clip-path
android:pathData="M0,0h50v46.22H0z"/>
<path
android:fillColor="#FF000000"
android:pathData="M49.697,22.475a9.704,9.704 0,0 0,-1.213 -2.605c-0.142,-0.218 -0.197,-0.416 -0.14,-0.683 0.402,-1.901 0.297,-3.786 -0.227,-5.651 -0.566,-2.015 -1.59,-3.78 -2.937,-5.367 -1.633,-1.923 -3.606,-3.425 -5.81,-4.631C35.29,1.304 30.887,0.242 26.263,0.034a32.704,32.704 0,0 0,-6.21 0.307c-2.55,0.373 -5.02,1.024 -7.396,2.03 -2.558,1.082 -4.9,2.507 -6.921,4.426C4.256,8.201 3.029,9.792 2.19,11.66c-1.268,2.825 -1.555,5.726 -0.6,8.705 0.08,0.248 0.028,0.423 -0.118,0.623 -0.446,0.61 -0.838,1.254 -1.119,1.96 -0.154,0.387 -0.278,0.781 -0.308,1.2 -0.051,0.716 -0.07,1.433 0.005,2.147 0.137,1.29 0.545,2.464 1.515,3.383 0.055,0.052 0.098,0.115 0.146,0.172v0.909c-0.003,1.264 0.05,2.522 0.24,3.777 0.412,2.728 1.674,4.976 3.748,6.78 1.09,0.949 2.313,1.688 3.623,2.29 1.705,0.782 3.49,1.312 5.323,1.696 2.593,0.544 5.22,0.807 7.863,0.878 3.36,0.092 6.717,0.044 10.066,-0.296 1.672,-0.17 3.33,-0.415 4.963,-0.817 1.617,-0.4 3.176,-0.955 4.63,-1.784 2.17,-1.237 3.771,-2.987 4.753,-5.288 0.573,-1.343 0.937,-2.745 1.149,-4.188 0.217,-1.48 0.255,-2.967 0.161,-4.459 -0.01,-0.167 0,-0.336 0,-0.503 0.082,-0.069 0.152,-0.133 0.227,-0.187 0.722,-0.524 1.155,-1.232 1.336,-2.097 0.286,-1.368 0.296,-2.731 -0.096,-4.085zM5.31,13.922c0.436,-1.202 1.096,-2.273 1.915,-3.25 1.14,-1.359 2.503,-2.453 4.008,-3.378 2.091,-1.285 4.354,-2.156 6.731,-2.74a28.642,28.642 0,0 1,8.256 -0.774c3.56,0.172 6.986,0.929 10.218,2.465a12.323,12.323 0,0 1,2.753 1.77,5.88 5.88,0 0,1 1.566,2.054c0.466,1.034 0.54,2.118 0.34,3.214 -0.43,2.377 -1.661,4.259 -3.604,5.684 -0.918,0.674 -1.917,1.201 -2.96,1.648 -0.59,0.252 -1.189,0.48 -1.78,0.728a5.614,5.614 0,0 0,-0.61 0.297,1.201 1.201,0 0,0 -0.301,0.25c-0.123,0.139 -0.103,0.35 0.06,0.442 0.176,0.1 0.373,0.177 0.57,0.222 0.671,0.153 1.354,0.124 2.031,0.074a26.11,26.11 0,0 0,5.5 -1.002c1.44,-0.427 2.793,-1.033 4.008,-1.928 0.059,-0.044 0.128,-0.076 0.194,-0.11 0.01,-0.005 0.03,0.008 0.085,0.024 -0.04,0.101 -0.071,0.203 -0.118,0.298 -0.454,0.928 -1.093,1.714 -1.866,2.395 -0.912,0.805 -1.939,1.434 -3.03,1.962 -1.69,0.819 -3.47,1.372 -5.3,1.772 -2.086,0.456 -4.2,0.709 -6.332,0.834a49.03,49.03 0,0 1,-6.337 -0.039c-2.888,-0.204 -5.734,-0.652 -8.491,-1.567 -1.256,-0.417 -2.47,-0.933 -3.614,-1.602a11.411,11.411 0,0 1,-2.216 -1.657c-1.04,-1.01 -1.781,-2.196 -2.061,-3.633 -0.296,-1.518 -0.142,-3.004 0.385,-4.453zM44.84,33.772c-0.229,1.172 -0.776,2.197 -1.544,3.107 -0.714,0.845 -1.572,1.516 -2.52,2.078 -1.407,0.833 -2.926,1.39 -4.5,1.808 -1.734,0.46 -3.5,0.748 -5.286,0.931A60.302,60.302 0,0 1,23.87 42c-2.001,-0.031 -3.997,-0.158 -5.979,-0.449 -2.076,-0.304 -4.113,-0.771 -6.06,-1.575 -1.28,-0.529 -2.486,-1.186 -3.558,-2.068 -1.402,-1.155 -2.44,-2.562 -2.957,-4.323a6.863,6.863 0,0 1,-0.302 -2.062c0.002,-0.109 0.021,-0.217 0.035,-0.343 0.176,0 0.325,-0.015 0.469,0.003 0.677,0.082 1.357,0.088 2.035,0.04 1.763,-0.129 3.359,0.33 4.813,1.323 0.875,0.598 1.678,1.283 2.445,2.011 0.602,0.571 1.19,1.158 1.78,1.742 0.69,0.68 1.453,1.258 2.325,1.688 0.98,0.483 2.011,0.755 3.108,0.736 1.015,-0.019 1.973,-0.28 2.884,-0.724a9.993,9.993 0,0 0,2.025 -1.339c0.217,-0.18 0.434,-0.363 0.662,-0.53 1.13,-0.823 2.392,-1.064 3.758,-0.851 0.766,0.12 1.501,0.36 2.244,0.574 0.706,0.203 1.413,0.412 2.131,0.559a5.07,5.07 0,0 0,2.301 -0.044c0.784,-0.201 1.358,-0.653 1.666,-1.4 0.178,-0.435 0.299,-0.892 0.439,-1.341 0.118,-0.378 0.211,-0.764 0.341,-1.137 0.343,-0.983 1.022,-1.607 2.04,-1.85 0.822,-0.197 1.643,-0.39 2.498,-0.593 0.027,0.116 0.064,0.203 0.065,0.29 0.017,1.151 -0.015,2.302 -0.236,3.436z"/>
</group>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/rss_logo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="M194.96,840Q164,840 142,817.96q-22,-22.05 -22,-53Q120,734 142.04,712q22.05,-22 53,-22Q226,690 248,712.04q22,22.05 22,53Q270,796 247.96,818q-22.05,22 -53,22ZM710,840q0,-123 -46,-229.5T537,423q-81,-81 -187.58,-127Q242.85,250 120,250v-90q142,0 265,53t216,146q93,93 146,216t53,265h-90ZM452,840q0,-70 -25.8,-131.48Q400.4,647.04 355,600q-45,-47 -105.03,-73.5Q189.95,500 120,500v-90q89,0 165.5,33.5t133.64,92.42q57.15,58.93 90,137Q542,751 542,840h-90Z"
android:fillColor="#000000"/>
</vector>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -73,4 +73,7 @@
<string name="update_auth_success_message">Successfully logged in</string>
<string name="login_title">Log in to Feedbin</string>
<string name="crash_reporting_checkbox_title">Enable crash reporting</string>
<string name="account_source_feedbin">Feedbin</string>
<string name="account_source_local">Local</string>
<string name="add_account_title">Add Account</string>
</resources>
2 changes: 1 addition & 1 deletion bumpver.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpver]
current_version = "v2024.06.1000"
current_version = "2024.06.1000"
version_pattern = "vYYYY.0M.BUILD"
commit_message = "Bump version {old_version} to {new_version}"
commit = true