Skip to content

Commit

Permalink
Add AboutScreen to display Privacy Policy, Github, Website & Credits
Browse files Browse the repository at this point in the history
  • Loading branch information
opatry committed Oct 2, 2024
1 parent edf1bb3 commit 48c38a1
Show file tree
Hide file tree
Showing 6 changed files with 370 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ import net.opatry.tasks.app.ui.TasksApp
import net.opatry.tasks.app.ui.UserState
import net.opatry.tasks.app.ui.UserViewModel
import net.opatry.tasks.app.ui.component.LoadingPane
import net.opatry.tasks.app.ui.screen.AboutApp
import net.opatry.tasks.app.ui.screen.AuthorizationScreen
import net.opatry.tasks.app.ui.theme.TasksfolioTheme
import net.opatry.tasks.app.util.readText
import org.koin.compose.viewmodel.koinViewModel


Expand All @@ -60,8 +62,14 @@ class MainActivity : AppCompatActivity() {

is UserState.Unsigned,
is UserState.SignedIn -> {
val aboutApp = AboutApp(
name = getString(R.string.app_name),
version = "${BuildConfig.VERSION_NAME}.${BuildConfig.VERSION_CODE}"
) {
assets.readText("licenses_android.json")
}
val tasksViewModel = koinViewModel<TaskListsViewModel>()
TasksApp(userViewModel, tasksViewModel)
TasksApp(aboutApp, userViewModel, tasksViewModel)
}

is UserState.Newcomer -> AuthorizationScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package net.opatry.tasks.app.ui.screen
package net.opatry.tasks.app.util

import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import net.opatry.tasks.resources.Res
import net.opatry.tasks.resources.settings_screen_tbd
import org.jetbrains.compose.resources.stringResource
import android.content.res.AssetManager
import java.io.BufferedReader


@Composable
fun SettingsScreen() {
Text(stringResource(Res.string.settings_screen_tbd))
fun AssetManager.readText(assetPath: String): String {
return open(assetPath)
.bufferedReader()
.use(BufferedReader::readText)
}
16 changes: 14 additions & 2 deletions tasks-app-desktop/src/main/kotlin/mainApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import net.opatry.tasks.app.ui.TasksApp
import net.opatry.tasks.app.ui.UserState
import net.opatry.tasks.app.ui.UserViewModel
import net.opatry.tasks.app.ui.component.LoadingPane
import net.opatry.tasks.app.ui.screen.AboutApp
import net.opatry.tasks.app.ui.screen.AuthorizationScreen
import net.opatry.tasks.app.ui.theme.TasksfolioTheme
import org.koin.compose.KoinApplication
Expand All @@ -55,9 +56,14 @@ import javax.swing.UIManager

private const val GCP_CLIENT_ID = "191682949161-esokhlfh7uugqptqnu3su9vgqmvltv95.apps.googleusercontent.com"

object MainApp

fun main() {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())

val appName = "Taskfolio"
val fullVersion = System.getProperty("app.version.full") ?: "0.0.0.0"
val versionLabel = System.getProperty("app.version")?.let { " v$it" } ?: ""
application {
val screenSize by remember {
mutableStateOf(Toolkit.getDefaultToolkit().screenSize)
Expand All @@ -73,7 +79,7 @@ fun main() {
Window(
onCloseRequest = ::exitApplication,
state = windowState,
title = "Taskfolio",
title = "$appName$versionLabel",
) {
if (window.minimumSize != minSize) window.minimumSize = minSize

Expand Down Expand Up @@ -120,8 +126,14 @@ fun main() {

is UserState.Unsigned,
is UserState.SignedIn -> {
val aboutApp = AboutApp(
name = appName,
version = fullVersion
) {
MainApp::class.java.getResource("/licenses_desktop.json")?.readText() ?: ""
}
val tasksViewModel = koinViewModel<TaskListsViewModel>()
TasksApp(userViewModel, tasksViewModel)
TasksApp(aboutApp, userViewModel, tasksViewModel)
}

is UserState.Newcomer -> AuthorizationScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<string name="navigation_calendar">Calendar</string>
<string name="navigation_search">Search</string>
<string name="navigation_settings">Settings</string>
<string name="navigation_about">About</string>

<string name="onboarding_screen_authorize_explanation">You need to give the authorization to access your Google Tasks.</string>
<string name="onboarding_screen_skip">Skip</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@

package net.opatry.tasks.app.ui

import AlignJustify
import Calendar
import Info
import ListTodo
import LucideIcons
import Search
import Settings
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
Expand All @@ -53,12 +52,14 @@ import androidx.compose.ui.unit.dp
import net.opatry.tasks.app.ui.component.EditTextDialog
import net.opatry.tasks.app.ui.component.MissingScreen
import net.opatry.tasks.app.ui.component.ProfileIcon
import net.opatry.tasks.app.ui.screen.AboutApp
import net.opatry.tasks.app.ui.screen.AboutScreen
import net.opatry.tasks.app.ui.screen.TaskListsMasterDetail
import net.opatry.tasks.resources.Res
import net.opatry.tasks.resources.app_name
import net.opatry.tasks.resources.navigation_about
import net.opatry.tasks.resources.navigation_calendar
import net.opatry.tasks.resources.navigation_search
import net.opatry.tasks.resources.navigation_settings
import net.opatry.tasks.resources.navigation_tasks
import org.jetbrains.compose.resources.StringResource
import org.jetbrains.compose.resources.stringResource
Expand All @@ -69,13 +70,14 @@ enum class AppTasksScreen(
val contentDescription: StringResource? = null,
) {
Tasks(Res.string.navigation_tasks, LucideIcons.ListTodo),

Calendar(Res.string.navigation_calendar, LucideIcons.Calendar),
Search(Res.string.navigation_search, LucideIcons.Search),
Settings(Res.string.navigation_settings, LucideIcons.Settings),
About(Res.string.navigation_about, LucideIcons.Info),
}

@Composable
fun TasksApp(userViewModel: UserViewModel, tasksViewModel: TaskListsViewModel) {
fun TasksApp(aboutApp: AboutApp, userViewModel: UserViewModel, tasksViewModel: TaskListsViewModel) {
var selectedScreen by remember { mutableStateOf(AppTasksScreen.Tasks) }
val userState by userViewModel.state.collectAsState(null)
val isSigned by remember(userState) {
Expand All @@ -92,21 +94,11 @@ fun TasksApp(userViewModel: UserViewModel, tasksViewModel: TaskListsViewModel) {
var newTaskListDefaultTitle by remember { mutableStateOf("") }
var showNewTaskListDialog by remember { mutableStateOf(false) }

NavigationSuiteScaffold(navigationSuiteItems = {
// Only if expanded state
if (false) {
item(
selected = false,
onClick = { },
enabled = false,
icon = {
Icon(LucideIcons.AlignJustify, null)
},
alwaysShowLabel = false,
modifier = Modifier.padding(vertical = 12.dp),
)
}
NavigationSuiteScaffold(modifier = Modifier.padding(top = 16.dp), navigationSuiteItems = {
AppTasksScreen.entries.forEach { screen ->
// hide unsupported screens for now
if (screen == AppTasksScreen.Calendar) return@forEach
if (screen == AppTasksScreen.Search) return@forEach
item(
selected = selectedScreen == screen,
onClick = { selectedScreen = screen },
Expand Down Expand Up @@ -160,7 +152,9 @@ fun TasksApp(userViewModel: UserViewModel, tasksViewModel: TaskListsViewModel) {

AppTasksScreen.Calendar -> MissingScreen(stringResource(AppTasksScreen.Calendar.labelRes), LucideIcons.Calendar)
AppTasksScreen.Search -> MissingScreen(stringResource(AppTasksScreen.Search.labelRes), LucideIcons.Search)
AppTasksScreen.Settings -> MissingScreen(stringResource(AppTasksScreen.Settings.labelRes), LucideIcons.Settings)
AppTasksScreen.About -> {
AboutScreen(aboutApp)
}
}
}
}
Expand Down
Loading

0 comments on commit 48c38a1

Please sign in to comment.