Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added options to style text better #33

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea/jarRepositories.xml
/.idea/
.DS_Store
/build
/captures
Expand Down
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,19 @@ android {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
namespace 'com.togitech.togii'
}

dependencies {

implementation "androidx.core:core-ktx:$core_ktx_version"
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation platform('androidx.compose:compose-bom:2022.10.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.material:material:1.4.3'
implementation 'androidx.compose.ui:ui-tooling-preview'

implementation 'androidx.core:core-ktx:1.10.0'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
implementation "androidx.activity:activity-compose:$activity_compose_version"
implementation 'androidx.activity:activity-compose:1.7.1'
implementation 'com.google.accompanist:accompanist-systemuicontroller:0.29.1-alpha'

implementation project(path: ':ccp')
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.togitech.togii">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/java/com/togitech/togii/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import com.togitech.ccp.component.*
import com.togitech.togii.ui.theme.TogiiTheme
Expand Down Expand Up @@ -65,7 +67,13 @@ fun CountryCodePick() {
onValueChange = { phoneNumber.value = it },
unfocusedBorderColor = MaterialTheme.colors.primary,
bottomStyle = false,
shape = RoundedCornerShape(24.dp)
shape = RoundedCornerShape(24.dp),
codeFontColor = Color.Black,
codeFontSize = 18.sp,
codeFontWeight = FontWeight.SemiBold,
phoneNumberFontColor = Color.Black,
phoneNumberFontSize = 18.sp,
phoneNumberFontWeight = FontWeight.SemiBold,
)
Spacer(modifier = Modifier.height(10.dp))
Button(onClick = {
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ buildscript {
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.2' apply false
id 'com.android.application' version '8.0.0' apply false
id 'com.android.library' version '8.0.0' apply false
id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
id "com.github.ben-manes.versions" version "0.46.0"
}
Expand Down
4 changes: 2 additions & 2 deletions ccp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ dependencies {

//noinspection GradleDependency
implementation "androidx.core:core-ktx:$core_ktx_version"
implementation "androidx.activity:activity-compose:$activity_compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation 'androidx.activity:activity-compose:1.7.1'
implementation 'androidx.compose.material:material:1.4.3'
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
implementation 'com.googlecode.libphonenumber:libphonenumber:8.13.7'

Expand Down
3 changes: 1 addition & 2 deletions ccp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.togitech.ccp">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
23 changes: 14 additions & 9 deletions ccp/src/main/java/com/togitech/ccp/component/TogiCodePicker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ import com.togitech.ccp.utils.searchCountry
@Composable
fun TogiCodeDialog(
modifier: Modifier = Modifier,
padding: Dp = 15.dp,
paddingStart: Dp = 12.dp,
paddingEnd: Dp = 0.dp,
defaultSelectedCountry: CountryData = getLibCountries.first(),
showCountryCode: Boolean = true,
pickedCountry: (CountryData) -> Unit,
showFlag: Boolean = true,
showCountryName: Boolean = false,
fontWeight: FontWeight = FontWeight.Bold,
fontSize: TextUnit = 18.sp,
fontColor: Color = MaterialTheme.colors.onSurface,

) {
val context = LocalContext.current
Expand All @@ -58,7 +62,7 @@ fun TogiCodeDialog(
val interactionSource = remember { MutableInteractionSource() }

Column(modifier = modifier
.padding(padding)
.padding(start = paddingStart, end = paddingEnd)
.clickable(
interactionSource = interactionSource,
indication = null,
Expand All @@ -82,20 +86,20 @@ fun TogiCodeDialog(
if (showCountryCode) {
Text(
text = isPickCountry.countryPhoneCode,
fontWeight = FontWeight.Bold,
fontWeight = fontWeight,
modifier = Modifier.padding(start = 6.dp),
fontSize = 18.sp,
color = MaterialTheme.colors.onSurface
fontSize = fontSize,
color = fontColor,
)
Icon(imageVector = Icons.Default.ArrowDropDown, contentDescription = null)
}
if (showCountryName) {
Text(
text = stringResource(id = getCountryName(isPickCountry.countryCode.lowercase())),
fontWeight = FontWeight.Bold,
fontWeight = fontWeight,
modifier = Modifier.padding(start = 6.dp),
fontSize = 18.sp,
color = MaterialTheme.colors.onSurface
fontSize = fontSize,
color = fontColor,
)
Icon(imageVector = Icons.Default.ArrowDropDown, contentDescription = null)
}
Expand Down Expand Up @@ -155,6 +159,7 @@ fun CountryDialog(
)
},
modifier = Modifier
.padding(top = 10.dp)
.clip(RoundedCornerShape(50))
.height(40.dp),
)
Expand Down Expand Up @@ -211,7 +216,7 @@ private fun SearchTextField(
textColor: Color = Color.Black,
onValueChange: (String) -> Unit,
hint: String = stringResource(id = R.string.search),
fontSize: TextUnit = MaterialTheme.typography.body2.fontSize
fontSize: TextUnit = MaterialTheme.typography.body2.fontSize,
) {
BasicTextField(modifier = modifier
.fillMaxWidth()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.togitech.ccp.component

import android.util.Log
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardActions
Expand All @@ -19,9 +20,12 @@ import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalTextInputService
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.togitech.ccp.R
import com.togitech.ccp.data.utils.getDefaultLangCode
import com.togitech.ccp.data.utils.getDefaultPhoneCode
Expand All @@ -48,7 +52,13 @@ fun TogiCountryCodePicker(
focusedBorderColor: Color = MaterialTheme.colors.primary,
unfocusedBorderColor: Color = MaterialTheme.colors.onSecondary,
cursorColor: Color = MaterialTheme.colors.primary,
bottomStyle: Boolean = false
bottomStyle: Boolean = false,
codeFontWeight: FontWeight = FontWeight.Bold,
codeFontSize: TextUnit = 18.sp,
codeFontColor: Color = MaterialTheme.colors.onSurface,
phoneNumberFontWeight: FontWeight = FontWeight.Bold,
phoneNumberFontSize: TextUnit = 18.sp,
phoneNumberFontColor: Color = MaterialTheme.colors.onSurface,
) {
val context = LocalContext.current
var textFieldValue by rememberSaveable { mutableStateOf("") }
Expand Down Expand Up @@ -82,7 +92,10 @@ fun TogiCountryCodePicker(
defaultSelectedCountry = getLibCountries.single { it.countryCode == defaultLang },
showCountryCode = showCountryCode,
showFlag = showCountryFlag,
showCountryName = true
showCountryName = true,
fontWeight = codeFontWeight,
fontSize = codeFontSize,
fontColor = codeFontColor,
)
}
Row(
Expand All @@ -92,10 +105,16 @@ fun TogiCountryCodePicker(
OutlinedTextField(modifier = modifier.fillMaxWidth(),
shape = shape,
value = textFieldValue,
textStyle = TextStyle(
fontSize = phoneNumberFontSize,
fontWeight = phoneNumberFontWeight,
color = phoneNumberFontColor,
),
onValueChange = {
textFieldValue = it
if (text != it) {
onValueChange(it)
isPhoneNumber()
}
},
singleLine = true,
Expand Down Expand Up @@ -124,7 +143,10 @@ fun TogiCountryCodePicker(
},
defaultSelectedCountry = getLibCountries.single { it.countryCode == defaultLang },
showCountryCode = showCountryCode,
showFlag = showCountryFlag
showFlag = showCountryFlag,
fontWeight = codeFontWeight,
fontSize = codeFontSize,
fontColor = codeFontColor,
)
}
}
Expand Down
7 changes: 7 additions & 0 deletions ccp/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="unkown">Inconnue</string>
<string name="search">Recherche…</string>
<string name="select_country">Choisissez le pays</string>
<string name="invalid_number">Numéro de téléphone invalide</string>
</resources>
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.disableAutomaticComponentCreation=true
android.nonTransitiveRClass=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Apr 14 12:41:17 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME