Skip to content

Commit

Permalink
Improve theme domain models
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandarIlic committed Nov 13, 2023
1 parent d8cad5b commit 6deeeb4
Show file tree
Hide file tree
Showing 44 changed files with 155 additions and 28 deletions.
1 change: 1 addition & 0 deletions app/src/main/kotlin/net/primal/android/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import net.primal.android.theme.PrimalRippleTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.active.ActiveThemeStore
import net.primal.android.theme.defaultPrimalTheme
import net.primal.android.theme.domain.PrimalTheme
import javax.inject.Inject

@AndroidEntryPoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import net.primal.android.core.compose.icons.primaliconpack.ArrowBack
import net.primal.android.nostr.model.content.ContentMetadata
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun CreateAccountScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import net.primal.android.core.utils.usernameUiFriendly
import net.primal.android.nostr.model.content.ContentMetadata
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@OptIn(ExperimentalFoundationApi::class)
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import net.primal.android.core.compose.icons.primaliconpack.ArrowBack
import net.primal.android.core.utils.isValidNostrPrivateKey
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun LoginScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import net.primal.android.core.compose.fadingBottomEdge
import net.primal.android.core.ext.openUriSafely
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun WelcomeScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import net.primal.android.core.compose.icons.PrimalIcons
import net.primal.android.core.compose.icons.primaliconpack.Settings
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun AppBarIcon(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import androidx.compose.ui.graphics.luminance
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun AdjustTemporarilySystemBarColors(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import net.primal.android.core.compose.icons.primaliconpack.Verified
import net.primal.android.core.utils.isPrimalIdentifier
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun NostrUserText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun PrimalCallToActionButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import androidx.compose.ui.unit.dp
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun PrimalFilledButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.ui.unit.dp
import net.primal.android.core.compose.IconText
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun PrimalLoadingButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import net.primal.android.core.compose.feed.model.FeedPostStatsUi
import net.primal.android.core.compose.feed.model.FeedPostUi
import net.primal.android.core.ext.openUriSafely
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme
import java.time.Instant
import java.time.temporal.ChronoUnit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import net.primal.android.feed.db.ReferencedPost
import net.primal.android.feed.db.ReferencedUser
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme
import java.time.Instant

private const val PROFILE_ID_ANNOTATION_TAG = "profileId"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import net.primal.android.core.compose.media.model.MediaResourceUi
import net.primal.android.core.utils.formatNip05Identifier
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme
import java.time.Instant
import kotlin.time.Duration.Companion.seconds

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun NoteSurfaceCard(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import net.primal.android.core.compose.feed.model.FeedPostStatsUi
import net.primal.android.core.compose.feed.model.FeedPostUi
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme
import java.time.Instant
import java.time.temporal.ChronoUnit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import net.primal.android.drawer.PrimalBottomBarHeightDp
import net.primal.android.drawer.PrimalDrawerScaffold
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun FeedScreen(
Expand Down Expand Up @@ -261,7 +262,7 @@ private fun ErrorHandler(
@Preview
@Composable
fun FeedScreenPreview() {
PrimalTheme(primalTheme = PrimalTheme.Sunset) {
PrimalTheme(primalTheme = PrimalTheme.Sunset) {
FeedScreen(
state = FeedContract.UiState(posts = flow { }),
eventPublisher = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import net.primal.android.core.compose.icons.primaliconpack.QrCode
import net.primal.android.core.utils.formatNip05Identifier
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme
import net.primal.android.user.domain.UserAccount
import java.text.NumberFormat

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.flow.getAndUpdate
import kotlinx.coroutines.launch
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme
import net.primal.android.theme.active.ActiveThemeStore
import net.primal.android.user.accounts.active.ActiveAccountStore
import javax.inject.Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import net.primal.android.drawer.DrawerScreenDestination
import net.primal.android.drawer.PrimalDrawerScaffold
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun ExploreHomeScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import net.primal.android.profile.edit.EditProfileScreen
import net.primal.android.profile.edit.EditProfileViewModel
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme
import net.primal.android.thread.ThreadScreen
import net.primal.android.thread.ThreadViewModel
import java.net.URLEncoder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ import net.primal.android.crypto.hexToNpubHrp
import net.primal.android.profile.details.ProfileContract.UiState.ProfileError
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme
import java.text.NumberFormat

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import net.primal.android.core.compose.profile.PrimalOutlinedTextField
import net.primal.android.core.compose.profile.ProfileHero
import net.primal.android.core.utils.isValidUsername
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun EditProfileScreen(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.primal.android.settings.appearance

import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

interface AppearanceSettingsContract {
data class UiState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import net.primal.android.core.compose.icons.PrimalIcons
import net.primal.android.core.compose.icons.primaliconpack.ArrowBack
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun AppearanceSettingsScreen(
Expand Down Expand Up @@ -181,7 +182,7 @@ private fun ThemeBox(
) {
Image(
modifier = Modifier.align(alignment = Alignment.Center),
painter = painterResource(id = primalTheme.logoId),
painter = painterResource(id = primalTheme.accent.logoId),
contentDescription = null
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.getAndUpdate
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.launch
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme
import net.primal.android.theme.active.ActiveThemeStore
import javax.inject.Inject

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import net.primal.android.settings.feeds.model.Feed
import net.primal.android.settings.feeds.model.FeedAction
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun FeedsSettingsScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import net.primal.android.core.compose.icons.PrimalIcons
import net.primal.android.core.compose.icons.primaliconpack.ArrowBack
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun SettingsHomeScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ import androidx.compose.ui.unit.sp
import net.primal.android.R
import net.primal.android.core.compose.AvatarThumbnailListItemImage
import net.primal.android.core.compose.IconText
import net.primal.android.core.compose.button.PrimalLoadingButton
import net.primal.android.core.compose.PrimalTopAppBar
import net.primal.android.core.compose.button.PrimalLoadingButton
import net.primal.android.core.compose.icons.PrimalIcons
import net.primal.android.core.compose.icons.primaliconpack.ArrowBack
import net.primal.android.core.compose.icons.primaliconpack.Key
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun AccountSettingsScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import net.primal.android.core.ext.findByUrl
import net.primal.android.settings.muted.list.model.MutedUserUi
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun MutedSettingsScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import net.primal.android.notifications.domain.NotificationType
import net.primal.android.settings.notifications.NotificationsSettingsContract.UiState.ApiError
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme

@Composable
fun NotificationsSettingsScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import net.primal.android.core.compose.icons.PrimalIcons
import net.primal.android.core.compose.icons.primaliconpack.ArrowBack
import net.primal.android.theme.AppTheme
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme
import net.primal.android.user.domain.NostrWallet
import net.primal.android.user.domain.NostrWalletKeypair

Expand Down
1 change: 1 addition & 0 deletions app/src/main/kotlin/net/primal/android/theme/AppTheme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import net.primal.android.core.compose.AdjustSystemColors
import net.primal.android.theme.colors.ExtraColorScheme
import net.primal.android.theme.colors.ExtraColorSchemeProvider
import net.primal.android.theme.colors.LocalExtraColors
import net.primal.android.theme.domain.PrimalTheme


@ReadOnlyComposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.runBlocking
import net.primal.android.theme.PrimalTheme
import net.primal.android.theme.domain.PrimalTheme
import net.primal.android.theme.active.di.ActiveThemeDataStore
import javax.inject.Inject
import javax.inject.Singleton
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package net.primal.android.theme.domain

import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

enum class PostAppearance(
val bodyFontSize: TextUnit,
val lineHeight: TextUnit,
val usernameFontSize: TextUnit,
val avatarSize: Dp,
) {
StandardSmall(
bodyFontSize = 14.sp,
lineHeight = 17.sp,
usernameFontSize = 14.sp,
avatarSize = 40.dp,
),
StandardDefault(
bodyFontSize = 15.sp,
lineHeight = 17.sp,
usernameFontSize = 15.sp,
avatarSize = 42.dp,
),
StandardLarge(
bodyFontSize = 17.sp,
lineHeight = 19.sp,
usernameFontSize = 17.sp,
avatarSize = 48.dp,
),
StandardExtraLarge(
bodyFontSize = 19.sp,
lineHeight = 21.sp,
usernameFontSize = 19.sp,
avatarSize = 50.dp,
),
FullWidthSmall(
bodyFontSize = 14.sp,
lineHeight = 17.sp,
usernameFontSize = 14.sp,
avatarSize = 28.dp,
),
FullWidthDefault(
bodyFontSize = 15.sp,
lineHeight = 18.sp,
usernameFontSize = 14.sp,
avatarSize = 30.dp,
),
FullWidthLarge(
bodyFontSize = 17.sp,
lineHeight = 20.sp,
usernameFontSize = 16.sp,
avatarSize = 32.dp,
),
FullWidthExtraLarge(
bodyFontSize = 18.sp,
lineHeight = 22.sp,
usernameFontSize = 16.sp,
avatarSize = 34.dp,
),
}
22 changes: 22 additions & 0 deletions app/src/main/kotlin/net/primal/android/theme/domain/PostLayout.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package net.primal.android.theme.domain

enum class PostLayout(
private val appearanceOptions: List<PostAppearance>,
) {
Standard(
appearanceOptions = listOf(
PostAppearance.StandardSmall,
PostAppearance.StandardDefault,
PostAppearance.StandardLarge,
PostAppearance.StandardExtraLarge,
),
),
FullWidth(
appearanceOptions = listOf(
PostAppearance.FullWidthSmall,
PostAppearance.FullWidthDefault,
PostAppearance.FullWidthLarge,
PostAppearance.FullWidthExtraLarge,
),
)
}
Loading

0 comments on commit 6deeeb4

Please sign in to comment.