Skip to content

Commit

Permalink
Add UI for OPML imports/exports
Browse files Browse the repository at this point in the history
  • Loading branch information
jocmp committed Jul 2, 2024
1 parent 544896a commit 9b4ea75
Show file tree
Hide file tree
Showing 11 changed files with 220 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fun NavGraphBuilder.accountsGraph(
}
dynamicLayout(isCompactWidth) {
SettingsScreen(
onLogout = onLogout,
onRemoveAccount = onLogout,
onNavigateBack = onNavigateBackFromSettings
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fun AddFeedView(
Text(stringResource(resource))
}
},
maxLines = 1,
singleLine = true,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.jocmp.capyreader.ui.components

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.Checkbox
import androidx.compose.material3.RadioButton
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -35,10 +40,12 @@ fun CrashReportingCheckbox(
}

Row(
verticalAlignment = Alignment.CenterVertically
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.fillMaxWidth()
) {
Checkbox(checked = enableCrashReporting, onCheckedChange = updateCrashReporting)
Text(text = stringResource(R.string.crash_reporting_checkbox_title))
Switch(checked = enableCrashReporting, onCheckedChange = updateCrashReporting)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.jocmp.capyreader.ui.settings

import androidx.annotation.StringRes
import com.jocmp.capy.accounts.Source
import com.jocmp.capyreader.R

data class AccountSettingsStrings(
@StringRes val dialogTitle: Int,
@StringRes val dialogMessage: Int,
@StringRes val dialogConfirmText: Int,
@StringRes val requestRemoveText: Int
) {
companion object {
fun find(source: Source): AccountSettingsStrings {
return when (source) {
Source.LOCAL -> AccountSettingsStrings(
dialogTitle = R.string.settings_remove_account_title_local,
dialogMessage = R.string.settings_remove_account_message_local,
dialogConfirmText = R.string.settings_remove_account_confirm_local,
requestRemoveText = R.string.settings_remove_account_button_local,
)

Source.FEEDBIN -> AccountSettingsStrings(
dialogTitle = R.string.settings_remove_account_title_feedbin,
dialogMessage = R.string.settings_remove_account_message_feedbin,
dialogConfirmText = R.string.settings_remove_account_confirm_feedbin,
requestRemoveText = R.string.settings_remove_account_button_feedbin,
)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.jocmp.capyreader.ui.settings

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme.colorScheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier

@Composable
fun OPMLExportButton() {
Column {
Button(
onClick = {},
colors = ButtonDefaults.buttonColors(
containerColor = colorScheme.secondary,
contentColor = colorScheme.onSecondary
),
modifier = Modifier.fillMaxWidth()
) {
Text("Export to OPML")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.jocmp.capyreader.ui.settings

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme.colorScheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier

@Composable
fun OPMLImportButton() {
Button(
onClick = {},
colors = ButtonDefaults.buttonColors(
containerColor = colorScheme.secondary,
contentColor = colorScheme.onSecondary
),
modifier = Modifier.fillMaxWidth()
) {
Text("Import from File")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ import org.koin.androidx.compose.koinViewModel
@Composable
fun SettingsScreen(
viewModel: SettingsViewModel = koinViewModel(),
onLogout: () -> Unit,
onRemoveAccount: () -> Unit,
onNavigateBack: () -> Unit,
) {
SettingsView(
refreshInterval = viewModel.refreshInterval,
updateRefreshInterval = viewModel::updateRefreshInterval,
accountName = viewModel.accountName,
onNavigateBack = { onNavigateBack() },
onRequestLogout = {
viewModel.logOut()
onLogout()
accountSource = viewModel.accountSource,
onRequestRemoveAccount = {
viewModel.removeAccount()
onRemoveAccount()
},
)
}
Loading

0 comments on commit 9b4ea75

Please sign in to comment.