forked from Writand/writand
feat: fontSize relatively altered
This commit is contained in:
parent
2cf09d7a93
commit
ea700e7e49
9 changed files with 61 additions and 26 deletions
|
@ -1,18 +1,19 @@
|
||||||
package be.re.writand.screens
|
package be.re.writand.screens
|
||||||
|
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
|
||||||
object WUIGlobals {
|
object WUIGlobals {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard value to be added to the font size setting.
|
* Standard value to be added to the font size setting.
|
||||||
*/
|
*/
|
||||||
val heading = 11.dp
|
const val HEADING = 11
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard title size to be added to the font size setting.
|
* Standard title size to be added to the font size setting.
|
||||||
*/
|
*/
|
||||||
val title = 16.dp
|
const val TITLE = 16
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard corner radius for borders.
|
* Standard corner radius for borders.
|
||||||
|
|
|
@ -27,7 +27,10 @@ fun WLoadingIndicator() {
|
||||||
verticalArrangement = Arrangement.Center,
|
verticalArrangement = Arrangement.Center,
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
CircularProgressIndicator(modifier = Modifier.padding(vertical = 10.dp), color = MaterialTheme.colorScheme.tertiary)
|
CircularProgressIndicator(
|
||||||
|
modifier = Modifier.padding(vertical = 10.dp),
|
||||||
|
color = MaterialTheme.colorScheme.tertiary
|
||||||
|
)
|
||||||
|
|
||||||
WText(text = "while( !( succeed = try() ) );", textAlign = TextAlign.Center)
|
WText(text = "while( !( succeed = try() ) );", textAlign = TextAlign.Center)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,10 @@ import be.re.writand.screens.SettingsViewModel
|
||||||
/**
|
/**
|
||||||
* Composable to use UserSettings in the standard compose.material3.Text,
|
* Composable to use UserSettings in the standard compose.material3.Text,
|
||||||
* all parameters are explained in there, but the [settingsViewModel].
|
* all parameters are explained in there, but the [settingsViewModel].
|
||||||
|
* @param[settingsFontSizeAlterBy] when the UserSettings-fontSize is used, it can be altered
|
||||||
|
* relatively to it, if the WText-fontSize is not set.
|
||||||
|
* E.g. UserSettings-fontSize is 14, and settingsFontSizeAlterBy is set to 6, than
|
||||||
|
* the used fontSize will be 20.sp for the [Text] fontSize parameter.
|
||||||
* @param[settingsViewModel] view model that provides the UserSettings.
|
* @param[settingsViewModel] view model that provides the UserSettings.
|
||||||
* @see[Text].
|
* @see[Text].
|
||||||
*/
|
*/
|
||||||
|
@ -46,12 +50,13 @@ fun WText(
|
||||||
minLines: Int = 1,
|
minLines: Int = 1,
|
||||||
onTextLayout: ((TextLayoutResult) -> Unit)? = null,
|
onTextLayout: ((TextLayoutResult) -> Unit)? = null,
|
||||||
style: TextStyle = LocalTextStyle.current,
|
style: TextStyle = LocalTextStyle.current,
|
||||||
|
settingsFontSizeAlterBy: Int = 0,
|
||||||
settingsViewModel: SettingsViewModel = hiltViewModel(),
|
settingsViewModel: SettingsViewModel = hiltViewModel(),
|
||||||
) {
|
) {
|
||||||
|
|
||||||
val settings by settingsViewModel.settings.collectAsState()
|
val settings by settingsViewModel.settings.collectAsState()
|
||||||
val size = if (fontSize == TextUnit.Unspecified && settings != null) {
|
val size = if (fontSize == TextUnit.Unspecified && settings != null) {
|
||||||
settings!!.fontSize.sp
|
(settings!!.fontSize + settingsFontSizeAlterBy).sp
|
||||||
} else if (fontSize != TextUnit.Unspecified) {
|
} else if (fontSize != TextUnit.Unspecified) {
|
||||||
fontSize
|
fontSize
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -250,9 +250,9 @@ fun Filename(
|
||||||
),
|
),
|
||||||
contentDescription = "Open/close the directory"
|
contentDescription = "Open/close the directory"
|
||||||
)
|
)
|
||||||
Text(text = filename)
|
WText(text = filename)
|
||||||
} else {
|
} else {
|
||||||
Text(
|
WText(
|
||||||
text = filename,
|
text = filename,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(start = 10.dp * depth + WUIGlobals.treeIconSize)
|
.padding(start = 10.dp * depth + WUIGlobals.treeIconSize)
|
||||||
|
|
|
@ -98,7 +98,10 @@ fun InfoPopup(
|
||||||
// spacer to divide the row in 3 parts and spread them over the width
|
// spacer to divide the row in 3 parts and spread them over the width
|
||||||
Spacer(modifier = Modifier.size(0.dp))
|
Spacer(modifier = Modifier.size(0.dp))
|
||||||
|
|
||||||
WText(text = "About Writand", fontSize = 25.sp)
|
WText(
|
||||||
|
text = "About Writand",
|
||||||
|
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||||
|
)
|
||||||
|
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = { openDialog.value = false },
|
onClick = { openDialog.value = false },
|
||||||
|
@ -138,11 +141,11 @@ fun InfoPopup(
|
||||||
text = "Writand",
|
text = "Writand",
|
||||||
color = MaterialTheme.colorScheme.tertiary,
|
color = MaterialTheme.colorScheme.tertiary,
|
||||||
fontWeight = FontWeight.ExtraBold,
|
fontWeight = FontWeight.ExtraBold,
|
||||||
fontSize = 30.sp
|
settingsFontSizeAlterBy = WUIGlobals.TITLE
|
||||||
)
|
)
|
||||||
WText(
|
WText(
|
||||||
text = " | version ${vM.version}",
|
text = " | version ${vM.version}",
|
||||||
fontSize = 20.sp
|
settingsFontSizeAlterBy = 6
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
WText(text =
|
WText(text =
|
||||||
|
@ -152,7 +155,7 @@ fun InfoPopup(
|
||||||
)
|
)
|
||||||
// change log / what's new: version 2 will have this
|
// change log / what's new: version 2 will have this
|
||||||
/*Column {
|
/*Column {
|
||||||
WText(text = "What's new", fontSize = 25.sp)
|
WText(text = "What's new", settingsFontSizeAlterBy = WUIGlobals.HEADING)
|
||||||
WText("upcoming...")
|
WText("upcoming...")
|
||||||
}*/
|
}*/
|
||||||
// TOS
|
// TOS
|
||||||
|
@ -160,7 +163,7 @@ fun InfoPopup(
|
||||||
WText(
|
WText(
|
||||||
modifier = Modifier.padding(vertical = 10.dp),
|
modifier = Modifier.padding(vertical = 10.dp),
|
||||||
text = "Terms Of Services",
|
text = "Terms Of Services",
|
||||||
fontSize = 25.sp
|
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||||
)
|
)
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
|
@ -193,7 +196,7 @@ fun InfoPopup(
|
||||||
WText(
|
WText(
|
||||||
modifier = Modifier.padding(vertical = 15.dp),
|
modifier = Modifier.padding(vertical = 15.dp),
|
||||||
text = "Support & Feedback",
|
text = "Support & Feedback",
|
||||||
fontSize = 25.sp
|
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||||
)
|
)
|
||||||
WText(
|
WText(
|
||||||
modifier = Modifier.padding(bottom = 5.dp),
|
modifier = Modifier.padding(bottom = 5.dp),
|
||||||
|
@ -217,7 +220,7 @@ fun InfoPopup(
|
||||||
WText(
|
WText(
|
||||||
modifier = Modifier.padding(vertical = 15.dp),
|
modifier = Modifier.padding(vertical = 15.dp),
|
||||||
text = "Support Us",
|
text = "Support Us",
|
||||||
fontSize = 25.sp
|
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||||
)
|
)
|
||||||
WText(text = "Support us via patreon and get more features: (link)")
|
WText(text = "Support us via patreon and get more features: (link)")
|
||||||
}
|
}
|
||||||
|
@ -228,7 +231,7 @@ fun InfoPopup(
|
||||||
WText(
|
WText(
|
||||||
modifier = Modifier.padding(vertical = 15.dp),
|
modifier = Modifier.padding(vertical = 15.dp),
|
||||||
text = "Rate The App",
|
text = "Rate The App",
|
||||||
fontSize = 25.sp
|
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||||
)
|
)
|
||||||
WText(
|
WText(
|
||||||
modifier = Modifier.padding(bottom = 5.dp),
|
modifier = Modifier.padding(bottom = 5.dp),
|
||||||
|
|
|
@ -104,7 +104,10 @@ fun SettingsPopup(
|
||||||
// spacer to divide the row in 3 parts and spread them over the width
|
// spacer to divide the row in 3 parts and spread them over the width
|
||||||
Spacer(modifier = Modifier.size(0.dp))
|
Spacer(modifier = Modifier.size(0.dp))
|
||||||
|
|
||||||
WText(text = "Settings", fontSize = 25.sp)
|
WText(
|
||||||
|
text = "Settings",
|
||||||
|
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||||
|
)
|
||||||
|
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = { openDialog.value = false },
|
onClick = { openDialog.value = false },
|
||||||
|
@ -197,7 +200,11 @@ fun AppearanceSettings(
|
||||||
.padding(start = 16.dp)
|
.padding(start = 16.dp)
|
||||||
) {
|
) {
|
||||||
|
|
||||||
WText(modifier = Modifier.padding(top = 25.dp), text = "Language", fontSize = 25.sp)
|
WText(
|
||||||
|
modifier = Modifier.padding(top = 25.dp),
|
||||||
|
text = "Language",
|
||||||
|
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||||
|
)
|
||||||
WRadioButtonsSelectorRowWise(
|
WRadioButtonsSelectorRowWise(
|
||||||
enable = true,
|
enable = true,
|
||||||
textTitle = "",
|
textTitle = "",
|
||||||
|
@ -207,7 +214,11 @@ fun AppearanceSettings(
|
||||||
labelSize = 0.dp
|
labelSize = 0.dp
|
||||||
)
|
)
|
||||||
|
|
||||||
WText(modifier = Modifier.padding(top = 25.dp), text = "Theme", fontSize = 25.sp)
|
WText(
|
||||||
|
modifier = Modifier.padding(top = 25.dp),
|
||||||
|
text = "Theme",
|
||||||
|
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||||
|
)
|
||||||
WRadioButtonsSelectorRowWise(
|
WRadioButtonsSelectorRowWise(
|
||||||
enable = true,
|
enable = true,
|
||||||
textTitle = "",
|
textTitle = "",
|
||||||
|
@ -217,7 +228,11 @@ fun AppearanceSettings(
|
||||||
labelSize = 0.dp
|
labelSize = 0.dp
|
||||||
)
|
)
|
||||||
|
|
||||||
WText(modifier = Modifier.padding(top = 25.dp), text = "Font", fontSize = 25.sp)
|
WText(
|
||||||
|
modifier = Modifier.padding(top = 25.dp),
|
||||||
|
text = "Font",
|
||||||
|
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||||
|
)
|
||||||
WLabelAndTextField(
|
WLabelAndTextField(
|
||||||
title = "Fontsize",
|
title = "Fontsize",
|
||||||
value = editorSettingsVM.textFieldFontSize.value,
|
value = editorSettingsVM.textFieldFontSize.value,
|
||||||
|
@ -263,7 +278,11 @@ fun AdvancedSettings(
|
||||||
.padding(it)
|
.padding(it)
|
||||||
.padding(start = 16.dp)
|
.padding(start = 16.dp)
|
||||||
) {
|
) {
|
||||||
WText(text = "History", modifier = Modifier.padding(top = 25.dp), fontSize = 25.sp)
|
WText(
|
||||||
|
text = "History",
|
||||||
|
modifier = Modifier.padding(top = 25.dp),
|
||||||
|
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||||
|
)
|
||||||
ArrowAmountChooser(
|
ArrowAmountChooser(
|
||||||
text = "Max amount of recently opened projects:",
|
text = "Max amount of recently opened projects:",
|
||||||
amountInt = editorSettingsVM.amountSavedProjects.intValue,
|
amountInt = editorSettingsVM.amountSavedProjects.intValue,
|
||||||
|
@ -272,7 +291,11 @@ fun AdvancedSettings(
|
||||||
onIncrementValue = editorSettingsVM::onIncrementProjects,
|
onIncrementValue = editorSettingsVM::onIncrementProjects,
|
||||||
onMaxValue = editorSettingsVM::onMaxValueProjects
|
onMaxValue = editorSettingsVM::onMaxValueProjects
|
||||||
)
|
)
|
||||||
WText(text = "IDE tabs", modifier = Modifier.padding(top = 25.dp), fontSize = 25.sp)
|
WText(
|
||||||
|
text = "IDE tabs",
|
||||||
|
modifier = Modifier.padding(top = 25.dp),
|
||||||
|
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||||
|
)
|
||||||
ArrowAmountChooser(
|
ArrowAmountChooser(
|
||||||
text = "Max amount of opened files:",
|
text = "Max amount of opened files:",
|
||||||
amountInt = editorSettingsVM.amountSavedFiles.intValue,
|
amountInt = editorSettingsVM.amountSavedFiles.intValue,
|
||||||
|
|
|
@ -118,13 +118,13 @@ fun WelcomeSettingsScreen(
|
||||||
text = "Welcome",
|
text = "Welcome",
|
||||||
color = MaterialTheme.colorScheme.tertiary,
|
color = MaterialTheme.colorScheme.tertiary,
|
||||||
fontWeight = FontWeight.ExtraBold,
|
fontWeight = FontWeight.ExtraBold,
|
||||||
fontSize = 25.sp
|
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||||
)
|
)
|
||||||
WText(
|
WText(
|
||||||
text = " to settings",
|
text = " to settings",
|
||||||
color = MaterialTheme.colorScheme.onPrimary,
|
color = MaterialTheme.colorScheme.onPrimary,
|
||||||
fontWeight = FontWeight.ExtraBold,
|
fontWeight = FontWeight.ExtraBold,
|
||||||
fontSize = 25.sp
|
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,13 +87,13 @@ fun WelcomeStartScreen(
|
||||||
text = "Welcome",
|
text = "Welcome",
|
||||||
color = MaterialTheme.colorScheme.tertiary,
|
color = MaterialTheme.colorScheme.tertiary,
|
||||||
fontWeight = FontWeight.ExtraBold,
|
fontWeight = FontWeight.ExtraBold,
|
||||||
fontSize = 25.sp
|
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||||
)
|
)
|
||||||
WText(
|
WText(
|
||||||
text = " to Writand",
|
text = " to Writand",
|
||||||
color = MaterialTheme.colorScheme.onPrimary,
|
color = MaterialTheme.colorScheme.onPrimary,
|
||||||
fontWeight = FontWeight.ExtraBold,
|
fontWeight = FontWeight.ExtraBold,
|
||||||
fontSize = 25.sp
|
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
WText(text = "Any fool can write code that a computer can understand.\nGood programmers can write code that humans can understand.")
|
WText(text = "Any fool can write code that a computer can understand.\nGood programmers can write code that humans can understand.")
|
||||||
|
|
|
@ -104,13 +104,13 @@ fun WelcomeTOSScreen(
|
||||||
text = "Welcome",
|
text = "Welcome",
|
||||||
color = MaterialTheme.colorScheme.tertiary,
|
color = MaterialTheme.colorScheme.tertiary,
|
||||||
fontWeight = FontWeight.ExtraBold,
|
fontWeight = FontWeight.ExtraBold,
|
||||||
fontSize = 25.sp
|
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||||
)
|
)
|
||||||
WText(
|
WText(
|
||||||
text = " to TOS",
|
text = " to TOS",
|
||||||
color = MaterialTheme.colorScheme.onPrimary,
|
color = MaterialTheme.colorScheme.onPrimary,
|
||||||
fontWeight = FontWeight.ExtraBold,
|
fontWeight = FontWeight.ExtraBold,
|
||||||
fontSize = 25.sp
|
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue