forked from Writand/writand
Merge branch 'frontend/relative-fontsize' into 'main'
feat: fontSize relatively altered Closes #35 See merge request EmmaVandewalle/writand!48
This commit is contained in:
commit
9f6d8570e6
9 changed files with 61 additions and 26 deletions
|
@ -1,18 +1,19 @@
|
|||
package be.re.writand.screens
|
||||
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
object WUIGlobals {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
val title = 16.dp
|
||||
const val TITLE = 16
|
||||
|
||||
/**
|
||||
* Standard corner radius for borders.
|
||||
|
|
|
@ -27,7 +27,10 @@ fun WLoadingIndicator() {
|
|||
verticalArrangement = Arrangement.Center,
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -24,6 +24,10 @@ import be.re.writand.screens.SettingsViewModel
|
|||
/**
|
||||
* Composable to use UserSettings in the standard compose.material3.Text,
|
||||
* 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.
|
||||
* @see[Text].
|
||||
*/
|
||||
|
@ -46,12 +50,13 @@ fun WText(
|
|||
minLines: Int = 1,
|
||||
onTextLayout: ((TextLayoutResult) -> Unit)? = null,
|
||||
style: TextStyle = LocalTextStyle.current,
|
||||
settingsFontSizeAlterBy: Int = 0,
|
||||
settingsViewModel: SettingsViewModel = hiltViewModel(),
|
||||
) {
|
||||
|
||||
val settings by settingsViewModel.settings.collectAsState()
|
||||
val size = if (fontSize == TextUnit.Unspecified && settings != null) {
|
||||
settings!!.fontSize.sp
|
||||
(settings!!.fontSize + settingsFontSizeAlterBy).sp
|
||||
} else if (fontSize != TextUnit.Unspecified) {
|
||||
fontSize
|
||||
} else {
|
||||
|
|
|
@ -250,9 +250,9 @@ fun Filename(
|
|||
),
|
||||
contentDescription = "Open/close the directory"
|
||||
)
|
||||
Text(text = filename)
|
||||
WText(text = filename)
|
||||
} else {
|
||||
Text(
|
||||
WText(
|
||||
text = filename,
|
||||
modifier = Modifier
|
||||
.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(modifier = Modifier.size(0.dp))
|
||||
|
||||
WText(text = "About Writand", fontSize = 25.sp)
|
||||
WText(
|
||||
text = "About Writand",
|
||||
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||
)
|
||||
|
||||
IconButton(
|
||||
onClick = { openDialog.value = false },
|
||||
|
@ -138,11 +141,11 @@ fun InfoPopup(
|
|||
text = "Writand",
|
||||
color = MaterialTheme.colorScheme.tertiary,
|
||||
fontWeight = FontWeight.ExtraBold,
|
||||
fontSize = 30.sp
|
||||
settingsFontSizeAlterBy = WUIGlobals.TITLE
|
||||
)
|
||||
WText(
|
||||
text = " | version ${vM.version}",
|
||||
fontSize = 20.sp
|
||||
settingsFontSizeAlterBy = 6
|
||||
)
|
||||
}
|
||||
WText(text =
|
||||
|
@ -152,7 +155,7 @@ fun InfoPopup(
|
|||
)
|
||||
// change log / what's new: version 2 will have this
|
||||
/*Column {
|
||||
WText(text = "What's new", fontSize = 25.sp)
|
||||
WText(text = "What's new", settingsFontSizeAlterBy = WUIGlobals.HEADING)
|
||||
WText("upcoming...")
|
||||
}*/
|
||||
// TOS
|
||||
|
@ -160,7 +163,7 @@ fun InfoPopup(
|
|||
WText(
|
||||
modifier = Modifier.padding(vertical = 10.dp),
|
||||
text = "Terms Of Services",
|
||||
fontSize = 25.sp
|
||||
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||
)
|
||||
|
||||
Box(
|
||||
|
@ -193,7 +196,7 @@ fun InfoPopup(
|
|||
WText(
|
||||
modifier = Modifier.padding(vertical = 15.dp),
|
||||
text = "Support & Feedback",
|
||||
fontSize = 25.sp
|
||||
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||
)
|
||||
WText(
|
||||
modifier = Modifier.padding(bottom = 5.dp),
|
||||
|
@ -217,7 +220,7 @@ fun InfoPopup(
|
|||
WText(
|
||||
modifier = Modifier.padding(vertical = 15.dp),
|
||||
text = "Support Us",
|
||||
fontSize = 25.sp
|
||||
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||
)
|
||||
WText(text = "Support us via patreon and get more features: (link)")
|
||||
}
|
||||
|
@ -228,7 +231,7 @@ fun InfoPopup(
|
|||
WText(
|
||||
modifier = Modifier.padding(vertical = 15.dp),
|
||||
text = "Rate The App",
|
||||
fontSize = 25.sp
|
||||
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||
)
|
||||
WText(
|
||||
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(modifier = Modifier.size(0.dp))
|
||||
|
||||
WText(text = "Settings", fontSize = 25.sp)
|
||||
WText(
|
||||
text = "Settings",
|
||||
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||
)
|
||||
|
||||
IconButton(
|
||||
onClick = { openDialog.value = false },
|
||||
|
@ -197,7 +200,11 @@ fun AppearanceSettings(
|
|||
.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(
|
||||
enable = true,
|
||||
textTitle = "",
|
||||
|
@ -207,7 +214,11 @@ fun AppearanceSettings(
|
|||
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(
|
||||
enable = true,
|
||||
textTitle = "",
|
||||
|
@ -217,7 +228,11 @@ fun AppearanceSettings(
|
|||
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(
|
||||
title = "Fontsize",
|
||||
value = editorSettingsVM.textFieldFontSize.value,
|
||||
|
@ -263,7 +278,11 @@ fun AdvancedSettings(
|
|||
.padding(it)
|
||||
.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(
|
||||
text = "Max amount of recently opened projects:",
|
||||
amountInt = editorSettingsVM.amountSavedProjects.intValue,
|
||||
|
@ -272,7 +291,11 @@ fun AdvancedSettings(
|
|||
onIncrementValue = editorSettingsVM::onIncrementProjects,
|
||||
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(
|
||||
text = "Max amount of opened files:",
|
||||
amountInt = editorSettingsVM.amountSavedFiles.intValue,
|
||||
|
|
|
@ -118,13 +118,13 @@ fun WelcomeSettingsScreen(
|
|||
text = "Welcome",
|
||||
color = MaterialTheme.colorScheme.tertiary,
|
||||
fontWeight = FontWeight.ExtraBold,
|
||||
fontSize = 25.sp
|
||||
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||
)
|
||||
WText(
|
||||
text = " to settings",
|
||||
color = MaterialTheme.colorScheme.onPrimary,
|
||||
fontWeight = FontWeight.ExtraBold,
|
||||
fontSize = 25.sp
|
||||
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -87,13 +87,13 @@ fun WelcomeStartScreen(
|
|||
text = "Welcome",
|
||||
color = MaterialTheme.colorScheme.tertiary,
|
||||
fontWeight = FontWeight.ExtraBold,
|
||||
fontSize = 25.sp
|
||||
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||
)
|
||||
WText(
|
||||
text = " to Writand",
|
||||
color = MaterialTheme.colorScheme.onPrimary,
|
||||
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.")
|
||||
|
|
|
@ -104,13 +104,13 @@ fun WelcomeTOSScreen(
|
|||
text = "Welcome",
|
||||
color = MaterialTheme.colorScheme.tertiary,
|
||||
fontWeight = FontWeight.ExtraBold,
|
||||
fontSize = 25.sp
|
||||
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||
)
|
||||
WText(
|
||||
text = " to TOS",
|
||||
color = MaterialTheme.colorScheme.onPrimary,
|
||||
fontWeight = FontWeight.ExtraBold,
|
||||
fontSize = 25.sp
|
||||
settingsFontSizeAlterBy = WUIGlobals.HEADING
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue