Skip to content

Commit

Permalink
added sponsor section
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed May 12, 2024
1 parent b8c3f1e commit 39d46f3
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ data object Constants {
const val CLIENT = "AniListAuthClient"
}
}

data object Sponsor {
const val GITHUB = "https://github.com/sponsors/DatL4g"
const val POLAR = "https://polar.sh/DatL4g"
const val PATREON = "https://patreon.com/datlag"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,84 +136,19 @@ fun SettingsScreen(component: SettingsComponent) {
}
}
item {
val uriHandler = LocalUriHandler.current

Row(
modifier = Modifier
.fillParentMaxWidth()
.defaultMinSize(minHeight = ButtonDefaults.MinHeight)
.clip(MaterialTheme.shapes.small)
.onClick {
uriHandler.openUri(Constants.GITHUB_REPO)
},
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Image(
modifier = Modifier.size(24.dp),
painter = painterResource(SharedRes.images.github),
contentDescription = null,
colorFilter = ColorFilter.tint(LocalContentColor.current)
)
Text(text = stringResource(SharedRes.strings.github_repository))
}
GitHubRepoSection(modifier = Modifier.fillParentMaxWidth())
}
item {
val uriHandler = LocalUriHandler.current

Row(
modifier = Modifier
.fillParentMaxWidth()
.defaultMinSize(minHeight = ButtonDefaults.MinHeight)
.clip(MaterialTheme.shapes.medium)
.onClick {
uriHandler.openUri(Constants.GITHUB_OWNER)
},
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Icon(
imageVector = Icons.Rounded.Code,
contentDescription = null,
)
Text(text = stringResource(SharedRes.strings.developed_by_datlag))
}
GitHubOwnerSection(modifier = Modifier.fillParentMaxWidth())
}
item {
var clicked by remember { mutableStateOf(0) }

Row(
modifier = Modifier
.fillParentMaxWidth()
.defaultMinSize(minHeight = ButtonDefaults.MinHeight)
.clip(MaterialTheme.shapes.medium)
.onClick {
if (clicked >= 99) {
component.nekos()
} else {
clicked++
}
},
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Image(
modifier = Modifier.size(24.dp),
painter = painterResource(SharedRes.images.cat_filled),
contentDescription = null,
colorFilter = ColorFilter.tint(LocalContentColor.current)
)
Text(text = stringResource(SharedRes.strings.nekos_api))
AnimatedVisibility(
visible = clicked >= 1,
) {
Badge(
containerColor = MaterialTheme.colorScheme.tertiaryContainer
) {
Text(text = "$clicked")
}
}
}
NekosSection(
modifier = Modifier.fillParentMaxWidth(),
onClick = component::nekos
)
}
item {
SponsorSection(modifier = Modifier.fillParentMaxWidth())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings.component

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Code
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.unit.dp
import dev.datlag.aniflow.SharedRes
import dev.datlag.aniflow.other.Constants
import dev.datlag.tooling.compose.onClick
import dev.icerock.moko.resources.compose.stringResource

@Composable
fun GitHubOwnerSection(
modifier: Modifier = Modifier,
) {
val uriHandler = LocalUriHandler.current

Row(
modifier = modifier
.defaultMinSize(minHeight = ButtonDefaults.MinHeight)
.clip(MaterialTheme.shapes.medium)
.onClick {
uriHandler.openUri(Constants.GITHUB_OWNER)
},
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Icon(
imageVector = Icons.Rounded.Code,
contentDescription = null,
)
Text(text = stringResource(SharedRes.strings.developed_by_datlag))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings.component

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.size
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.unit.dp
import dev.datlag.aniflow.SharedRes
import dev.datlag.aniflow.other.Constants
import dev.datlag.tooling.compose.onClick
import dev.icerock.moko.resources.compose.painterResource
import dev.icerock.moko.resources.compose.stringResource

@Composable
fun GitHubRepoSection(
modifier: Modifier = Modifier,
) {
val uriHandler = LocalUriHandler.current

Row(
modifier = modifier
.defaultMinSize(minHeight = ButtonDefaults.MinHeight)
.clip(MaterialTheme.shapes.small)
.onClick {
uriHandler.openUri(Constants.GITHUB_REPO)
},
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Image(
modifier = Modifier.size(24.dp),
painter = painterResource(SharedRes.images.github),
contentDescription = null,
colorFilter = ColorFilter.tint(LocalContentColor.current)
)
Text(text = stringResource(SharedRes.strings.github_repository))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings.component

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.size
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.unit.dp
import dev.datlag.aniflow.SharedRes
import dev.datlag.tooling.compose.onClick
import dev.icerock.moko.resources.compose.painterResource
import dev.icerock.moko.resources.compose.stringResource

@Composable
fun NekosSection(
modifier: Modifier = Modifier,
onClick: () -> Unit
) {
var clicked by remember { mutableStateOf(0) }

Row(
modifier = modifier
.defaultMinSize(minHeight = ButtonDefaults.MinHeight)
.clip(MaterialTheme.shapes.medium)
.onClick {
if (clicked >= 99) {
onClick()
} else {
clicked++
}
},
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Image(
modifier = Modifier.size(24.dp),
painter = painterResource(SharedRes.images.cat_filled),
contentDescription = null,
colorFilter = ColorFilter.tint(LocalContentColor.current)
)
Text(text = stringResource(SharedRes.strings.nekos_api))
AnimatedVisibility(
visible = clicked >= 1,
) {
Badge(
containerColor = MaterialTheme.colorScheme.tertiaryContainer
) {
Text(text = "$clicked")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package dev.datlag.aniflow.ui.navigation.screen.home.dialog.settings.component

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Savings
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.unit.dp
import com.maxkeppeker.sheets.core.models.base.Header
import com.maxkeppeker.sheets.core.models.base.IconSource
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.option.OptionDialog
import com.maxkeppeler.sheets.option.models.DisplayMode
import com.maxkeppeler.sheets.option.models.Option
import com.maxkeppeler.sheets.option.models.OptionConfig
import com.maxkeppeler.sheets.option.models.OptionSelection
import dev.datlag.aniflow.SharedRes
import dev.datlag.aniflow.other.Constants
import dev.datlag.tooling.compose.onClick
import dev.icerock.moko.resources.compose.painterResource
import dev.icerock.moko.resources.compose.stringResource

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SponsorSection(
modifier: Modifier = Modifier,
) {
val sponsorDialog = rememberUseCaseState()
val uriHandler = LocalUriHandler.current

OptionDialog(
state = sponsorDialog,
config = OptionConfig(
mode = DisplayMode.LIST
),
selection = OptionSelection.Single(
options = listOf(
Option(
icon = IconSource(painter = painterResource(SharedRes.images.github)),
titleText = stringResource(SharedRes.strings.github)
),
Option(
icon = IconSource(painter = painterResource(SharedRes.images.polar)),
titleText = stringResource(SharedRes.strings.polar)
),
Option(
icon = IconSource(painter = painterResource(SharedRes.images.patreon)),
titleText = stringResource(SharedRes.strings.patreon)
)
),
onSelectOption = { option, _ ->
when (option) {
0 -> uriHandler.openUri(Constants.Sponsor.GITHUB)
1 -> uriHandler.openUri(Constants.Sponsor.POLAR)
2 -> uriHandler.openUri(Constants.Sponsor.PATREON)
}
}
),
header = Header.Default(
title = stringResource(SharedRes.strings.sponsor),
icon = IconSource(imageVector = Icons.Rounded.Savings)
)
)

Row(
modifier = modifier
.defaultMinSize(minHeight = ButtonDefaults.MinHeight)
.clip(MaterialTheme.shapes.medium)
.onClick {
sponsorDialog.show()
},
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Icon(
imageVector = Icons.Rounded.Savings,
contentDescription = null,
)
Text(text = stringResource(SharedRes.strings.sponsor))
}
}
4 changes: 4 additions & 0 deletions composeApp/src/commonMain/moko-resources/base/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,8 @@
<string name="developed_by_datlag">Developed by DatLag</string>
<string name="profile_color">Profile Color</string>
<string name="login_markdown">Login with [AniList](%s)</string>
<string name="github">GitHub</string>
<string name="polar">Polar</string>
<string name="patreon">Patreon</string>
<string name="sponsor">Sponsor</string>
</resources>
8 changes: 8 additions & 0 deletions composeApp/src/commonMain/moko-resources/images/patreon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions composeApp/src/commonMain/moko-resources/images/polar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 39d46f3

Please sign in to comment.