Skip to content

Commit

Permalink
Add open source badge card in setting screen
Browse files Browse the repository at this point in the history
  • Loading branch information
msasikanth committed Jan 25, 2024
1 parent b5eb6f0 commit 772eadf
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright 2024 Sasikanth Miriyampalli
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.sasikanth.rss.reader.resources.icons

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathFillType.Companion.NonZero
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.StrokeCap.Companion.Butt
import androidx.compose.ui.graphics.StrokeJoin.Companion.Miter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.ImageVector.Builder
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp

val TwineIcons.EditorsChoice: ImageVector
get() {
if (_editorsChoice != null) {
return _editorsChoice!!
}
_editorsChoice =
Builder(
name = "EditorsChoice",
defaultWidth = 24.0.dp,
defaultHeight = 24.0.dp,
viewportWidth = 960.0f,
viewportHeight = 960.0f
)
.apply {
path(
fill = SolidColor(Color(0xFF000000)),
stroke = null,
strokeLineWidth = 0.0f,
strokeLineCap = Butt,
strokeLineJoin = Miter,
strokeLineMiter = 4.0f,
pathFillType = NonZero
) {
moveTo(240.0f, 920.0f)
verticalLineToRelative(-329.0f)
lineTo(110.0f, 380.0f)
lineToRelative(185.0f, -300.0f)
horizontalLineToRelative(370.0f)
lineToRelative(185.0f, 300.0f)
lineToRelative(-130.0f, 211.0f)
verticalLineToRelative(329.0f)
lineToRelative(-240.0f, -80.0f)
lineToRelative(-240.0f, 80.0f)
close()
moveTo(320.0f, 809.0f)
lineTo(480.0f, 756.0f)
lineTo(640.0f, 809.0f)
verticalLineToRelative(-129.0f)
lineTo(320.0f, 680.0f)
verticalLineToRelative(129.0f)
close()
moveTo(340.0f, 160.0f)
lineTo(204.0f, 380.0f)
lineToRelative(136.0f, 220.0f)
horizontalLineToRelative(280.0f)
lineToRelative(136.0f, -220.0f)
lineToRelative(-136.0f, -220.0f)
lineTo(340.0f, 160.0f)
close()
moveTo(438.0f, 543.0f)
lineTo(296.0f, 402.0f)
lineToRelative(57.0f, -57.0f)
lineToRelative(85.0f, 85.0f)
lineToRelative(169.0f, -170.0f)
lineToRelative(57.0f, 56.0f)
lineToRelative(-226.0f, 227.0f)
close()
moveTo(320.0f, 680.0f)
horizontalLineToRelative(320.0f)
horizontalLineToRelative(-320.0f)
close()
}
}
.build()
return _editorsChoice!!
}

private var _editorsChoice: ImageVector? = null
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,8 @@ val EnTwineStrings =
noNewPostsSubtitle = "Check back later or pull down to check for new content now",
postsAll = "All",
postsUnread = "Unread",
postsToday = "Today"
postsToday = "Today",
openSource = "Open Source",
openSourceDesc =
"Twine is built on open source technologies and is completely free to use, you can find the source code of Twine and some of my other popular projects on GitHub. Click here to head over there."
)
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ data class TwineStrings(
val postsAll: String,
val postsUnread: String,
val postsToday: String,
val openSource: String,
val openSourceDesc: String,
)

object Locales {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ import androidx.compose.foundation.layout.calculateEndPadding
import androidx.compose.foundation.layout.calculateStartPadding
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowDropDown
import androidx.compose.material.icons.rounded.ArrowBack
Expand All @@ -43,6 +46,7 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
Expand All @@ -62,6 +66,7 @@ import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.dp
Expand All @@ -80,6 +85,8 @@ import dev.sasikanth.rss.reader.repository.Period.ONE_WEEK
import dev.sasikanth.rss.reader.repository.Period.ONE_YEAR
import dev.sasikanth.rss.reader.repository.Period.SIX_MONTHS
import dev.sasikanth.rss.reader.repository.Period.THREE_MONTHS
import dev.sasikanth.rss.reader.resources.icons.EditorsChoice
import dev.sasikanth.rss.reader.resources.icons.TwineIcons
import dev.sasikanth.rss.reader.resources.strings.LocalStrings
import dev.sasikanth.rss.reader.settings.SettingsEvent
import dev.sasikanth.rss.reader.settings.SettingsPresenter
Expand Down Expand Up @@ -135,6 +142,12 @@ internal fun SettingsScreen(
bottom = padding.calculateBottomPadding() + 80.dp
),
) {
item {
OpenSource {
coroutineScope.launch { linkHandler.openLink(Constants.OPEN_SOURCE_LINK) }
}
}

item {
SubHeader(
text = LocalStrings.current.settingsHeaderBehaviour,
Expand Down Expand Up @@ -229,6 +242,38 @@ internal fun SettingsScreen(
)
}

@Composable
private fun OpenSource(openLink: () -> Unit) {
Surface(
color = AppTheme.colorScheme.tintedSurface,
shape = RoundedCornerShape(4.dp),
modifier = Modifier.fillMaxWidth().padding(16.dp).clickable { openLink() }
) {
Column(horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.padding(16.dp)) {
Icon(
TwineIcons.EditorsChoice,
contentDescription = null,
tint = AppTheme.colorScheme.onSurface,
modifier = Modifier.size(48.dp)
)
Spacer(Modifier.height(16.dp))
Text(
LocalStrings.current.openSource,
style = MaterialTheme.typography.titleMedium,
textAlign = TextAlign.Center,
color = AppTheme.colorScheme.onSurface
)
Spacer(Modifier.height(12.dp))
Text(
LocalStrings.current.openSourceDesc,
style = MaterialTheme.typography.labelMedium,
textAlign = TextAlign.Center,
color = AppTheme.colorScheme.onSurface
)
}
}
}

@Composable
private fun PostsDeletionPeriodSettingItem(
postsDeletionPeriod: Period?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ internal object Constants {
const val ABOUT_ED_THREADS = "https://www.threads.net/@edpratti"
const val ABOUT_ED_TWITTER = "https://twitter.com/edpratti"

const val OPEN_SOURCE_LINK = "https://github.com/sponsors/msasikanth"

const val MINIMUM_REQUIRED_SEARCH_CHARACTERS = 3
}

0 comments on commit 772eadf

Please sign in to comment.