Skip to content

Commit

Permalink
Merge branch 'chore/add-fonts' into test/designsystem_screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
azrael8576 committed Nov 16, 2023
2 parents 4834d3e + e015ab6 commit d8c42aa
Show file tree
Hide file tree
Showing 37 changed files with 312 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.compose.NavHost
import androidx.window.layout.DisplayFeature
import com.wei.amazingtalker.core.designsystem.ui.AtNavigationType
import com.wei.amazingtalker.core.designsystem.ui.DeviceOrientation
import com.wei.amazingtalker.feature.contactme.contactme.navigation.contactMeScreen
import com.wei.amazingtalker.feature.login.login.navigation.loginScreen
import com.wei.amazingtalker.feature.login.welcome.navigation.welcomeGraph
Expand All @@ -31,7 +31,7 @@ fun AtNavHost(
) {
val navController = appState.navController
val navigationType = appState.navigationType
val isCompact = navigationType == AtNavigationType.BOTTOM_NAVIGATION
val isPortrait = appState.currentDeviceOrientation == DeviceOrientation.PORTRAIT
val contentType = appState.contentType

NavHost(
Expand All @@ -47,11 +47,10 @@ fun AtNavHost(
},
)
welcomeGraph(
isCompact = isCompact,
isPortrait = isPortrait,
navController = navController,
nestedGraphs = {
loginScreen(
isCompact = isCompact,
onLoginNav = { appState.loginNavigate() },
)
},
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/com/wei/amazingtalker/ui/AtAppState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import androidx.window.layout.FoldingFeature
import com.wei.amazingtalker.core.data.utils.NetworkMonitor
import com.wei.amazingtalker.core.designsystem.ui.AtContentType
import com.wei.amazingtalker.core.designsystem.ui.AtNavigationType
import com.wei.amazingtalker.core.designsystem.ui.DeviceOrientation
import com.wei.amazingtalker.core.designsystem.ui.DevicePosture
import com.wei.amazingtalker.core.designsystem.ui.currentDeviceOrientation
import com.wei.amazingtalker.core.designsystem.ui.isBookPosture
import com.wei.amazingtalker.core.designsystem.ui.isSeparating
import com.wei.amazingtalker.feature.contactme.contactme.navigation.contactMeRoute
Expand Down Expand Up @@ -71,6 +73,9 @@ class AtAppState(
networkMonitor: NetworkMonitor,
displayFeatures: List<DisplayFeature>,
) {
val currentDeviceOrientation: DeviceOrientation
@Composable get() = currentDeviceOrientation()

/**
* We are using display's folding features to map the device postures a fold is in.
* In the state of folding device If it's half fold in BookPosture we want to avoid content
Expand Down Expand Up @@ -200,9 +205,11 @@ class AtAppState(
TopLevelDestination.SCHEDULE -> navController.navigateToSchedule(
topLevelNavOptions,
)

TopLevelDestination.CONTACT_ME -> navController.navigateToContactMe(
topLevelNavOptions,
)

else -> showFunctionalityNotAvailablePopup.value = true
}
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<resources>
<string name="app_name">Amazing Talker</string>
<string name="not_connected">⚠️ 您沒有網路連線</string>
<string name="schedule">Schedule</string>
<string name="home">Home</string>
<string name="contact_me">Contact Me</string>
<string name="schedule">行事曆</string>
<string name="home">首頁</string>
<string name="contact_me">聯絡我</string>

</resources>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ fun AtTheme(
androidTheme: Boolean = true,
content: @Composable () -> Unit,
) {
val typography = getAppTypography()

// Color scheme
val colorScheme = when {
androidTheme -> if (darkTheme) DarkColors else LightColors
Expand All @@ -110,6 +112,7 @@ fun AtTheme(
) {
MaterialTheme(
colorScheme = colorScheme,
typography = typography,
content = content,
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
package com.wei.amazingtalker.core.designsystem.theme

import androidx.compose.material3.Typography
import androidx.compose.runtime.Composable
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
import com.wei.amazingtalker.core.designsystem.R

val atFontFamily = FontFamily(
Font(R.font.gilroy_black, FontWeight.Black),
Font(R.font.gilroy_black_italic, FontWeight.Black, FontStyle.Italic),
Font(R.font.gilroy_bold, FontWeight.Bold),
Font(R.font.gilroy_bold_italic, FontWeight.Bold, FontStyle.Italic),
Font(R.font.gilroy_extra_bold, FontWeight.ExtraBold),
Font(R.font.gilroy_extra_bold_italic, FontWeight.ExtraBold, FontStyle.Italic),
Font(R.font.gilroy_light, FontWeight.Light),
Font(R.font.gilroy_light_italic, FontWeight.Light, FontStyle.Italic),
Font(R.font.gilroy_medium, FontWeight.SemiBold),
Font(R.font.gilroy_medium_italic, FontWeight.SemiBold, FontStyle.Italic),
Font(R.font.gilroy_regular, FontWeight.Medium),
Font(R.font.gilroy_regular_italic, FontWeight.Normal, FontStyle.Italic),
Font(R.font.gilroy_semi_bold, FontWeight.SemiBold),
Font(R.font.gilroy_semi_bold_italic, FontWeight.SemiBold, FontStyle.Italic),
Font(R.font.gilroy_thin, FontWeight.Thin),
Font(R.font.gilroy_thin_italic, FontWeight.Thin, FontStyle.Italic),
Font(R.font.gilroy_ultra_light, FontWeight.ExtraLight),
Font(R.font.gilroy_ultra_light_italic, FontWeight.ExtraLight, FontStyle.Italic),
)

val notoSansTCFontFamily = FontFamily(
Font(R.font.noto_sans_tc_variablefont_wght),
)

val abrilFatfaceFontFamily = FontFamily(
Font(R.font.abril_fatface),
)

@Composable
fun getAppTypography(): Typography {
return Typography(
displayLarge = TextStyle(
fontFamily = atFontFamily,
fontWeight = FontWeight.Normal,
fontSize = 57.sp,
lineHeight = 64.sp,
letterSpacing = (-0.25).sp,
),
displayMedium = TextStyle(
fontFamily = atFontFamily,
fontWeight = FontWeight.Normal,
fontSize = 45.sp,
lineHeight = 52.sp,
letterSpacing = 0.sp,
),
displaySmall = TextStyle(
fontFamily = atFontFamily,
fontWeight = FontWeight.Normal,
fontSize = 36.sp,
lineHeight = 44.sp,
letterSpacing = 0.sp,
),
headlineLarge = TextStyle(
fontFamily = atFontFamily,
fontWeight = FontWeight.Normal,
fontSize = 32.sp,
lineHeight = 40.sp,
letterSpacing = 0.sp,
),
headlineMedium = TextStyle(
fontFamily = atFontFamily,
fontWeight = FontWeight.Normal,
fontSize = 28.sp,
lineHeight = 36.sp,
letterSpacing = 0.sp,
),
headlineSmall = TextStyle(
fontFamily = atFontFamily,
fontWeight = FontWeight.Normal,
fontSize = 24.sp,
lineHeight = 32.sp,
letterSpacing = 0.sp,
),
titleLarge = TextStyle(
fontFamily = atFontFamily,
fontWeight = FontWeight.Bold,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp,
),
titleMedium = TextStyle(
fontFamily = atFontFamily,
fontWeight = FontWeight.Bold,
fontSize = 18.sp,
lineHeight = 24.sp,
letterSpacing = 0.15.sp,
),
titleSmall = TextStyle(
fontFamily = atFontFamily,
fontWeight = FontWeight.SemiBold,
fontSize = 14.sp,
lineHeight = 20.sp,
letterSpacing = 0.1.sp,
),
bodyLarge = TextStyle(
fontFamily = atFontFamily,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.15.sp,
),
bodyMedium = TextStyle(
fontFamily = atFontFamily,
fontWeight = FontWeight.Normal,
fontSize = 14.sp,
lineHeight = 20.sp,
letterSpacing = 0.25.sp,
),
bodySmall = TextStyle(
fontFamily = atFontFamily,
fontWeight = FontWeight.Normal,
fontSize = 12.sp,
lineHeight = 16.sp,
letterSpacing = 0.4.sp,
),
labelLarge = TextStyle(
fontFamily = atFontFamily,
fontWeight = FontWeight.SemiBold,
fontSize = 14.sp,
lineHeight = 20.sp,
letterSpacing = 0.1.sp,
),
labelMedium = TextStyle(
fontFamily = atFontFamily,
fontWeight = FontWeight.SemiBold,
fontSize = 12.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp,
),
labelSmall = TextStyle(
fontFamily = atFontFamily,
fontWeight = FontWeight.SemiBold,
fontSize = 10.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp,
),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.wei.amazingtalker.core.designsystem.ui

import android.content.res.Configuration
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalConfiguration

enum class DeviceOrientation {
PORTRAIT,
LANDSCAPE,
}

@Composable
fun currentDeviceOrientation(): DeviceOrientation {
val configuration = LocalConfiguration.current
return if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
DeviceOrientation.PORTRAIT
} else {
DeviceOrientation.LANDSCAPE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,26 @@ import androidx.compose.ui.tooling.preview.Preview
device = "spec:shape=Normal,width=673,height=841,unit=dp,dpi=480",
uiMode = Configuration.ORIENTATION_PORTRAIT,
)
@Preview(
name = "tablet",
device = "spec:shape=Normal,width=840,height=1280,unit=dp,dpi=480",
uiMode = Configuration.ORIENTATION_PORTRAIT,
)
annotation class DevicePortraitPreviews

@Preview(
name = "landscape",
name = "phone",
device = "spec:shape=Normal,width=640,height=360,unit=dp,dpi=480",
uiMode = Configuration.ORIENTATION_LANDSCAPE,
)
@Preview(
name = "foldable",
device = "spec:shape=Normal,width=841,height=673,unit=dp,dpi=480",
uiMode = Configuration.ORIENTATION_LANDSCAPE,
)
@Preview(
name = "tablet",
device = "spec:shape=Normal,width=1280,height=800,unit=dp,dpi=480",
device = "spec:shape=Normal,width=1280,height=840,unit=dp,dpi=480",
uiMode = Configuration.ORIENTATION_LANDSCAPE,
)
annotation class DeviceLandscapePreviews
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified docs/demo/screenshots_phone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/demo/screenshots_tablet_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,18 @@ internal fun ContactMeTwoPaneSecondContent(
if (withTopSpacer) {
item {
Spacer(Modifier.windowInsetsTopHeight(WindowInsets.safeDrawing))
Spacer(modifier = Modifier.height(16.dp))
}
}
item {
Spacer(modifier = Modifier.height(8.dp))
ContactMeCard(
uiStates = uiStates,
onPhoneClick = onPhoneClick,
)
Spacer(modifier = Modifier.height(8.dp))
}
if (withBottomSpacer) {
item {
Spacer(modifier = Modifier.height(16.dp))
Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))
}
}
Expand All @@ -259,6 +259,7 @@ internal fun ContactMeSinglePaneContent(
if (withTopSpacer) {
item {
Spacer(Modifier.windowInsetsTopHeight(WindowInsets.safeDrawing))
Spacer(modifier = Modifier.height(16.dp))
}
}
item {
Expand All @@ -279,10 +280,10 @@ internal fun ContactMeSinglePaneContent(
uiStates = uiStates,
onPhoneClick = onPhoneClick,
)
Spacer(modifier = Modifier.height(8.dp))
}
if (withBottomSpacer) {
item {
Spacer(modifier = Modifier.height(16.dp))
Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal open class WelcomeScreenRobot(
composeTestRule.setContent {
AtTheme {
WelcomeScreen(
isCompact = true,
isPortrait = true,
onGetStartedButtonClicked = { },
)
}
Expand Down
Loading

0 comments on commit d8c42aa

Please sign in to comment.