-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gears: added package with set of gears for compose
- Loading branch information
Showing
8 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// For some reason gradle.properties in this project doesn't affect its subprojects | ||
val gearsGroup = group | ||
subprojects { group = gearsGroup } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## Unreleased | ||
|
||
### Changed | ||
|
||
- Create gears.compose | ||
added: | ||
- `FixedFontScaleContainer` - A container that fixes the font scale, ignoring values, that are set in the phone's system settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# compose-ktx <GitHub path="RedMadRobot/redmadrobot-android-ktx/tree/main/compose-ktx"/> | ||
[![Version](https://img.shields.io/maven-central/v/com.redmadrobot.extensions/compose-ktx?style=flat-square)][mavenCentral] | ||
[![License](https://img.shields.io/github/license/RedMadRobot/redmadrobot-android-ktx?style=flat-square)][license] | ||
|
||
--- | ||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Contributing](#contributing) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
A set of gears for compose. | ||
|
||
## Installation | ||
|
||
Add the dependency: | ||
```groovy | ||
repositories { | ||
mavenCentral() | ||
google() | ||
} | ||
dependencies { | ||
implementation("com.redmadrobot.gears:compose:<version>") | ||
} | ||
``` | ||
|
||
## Usage | ||
|
||
| Gear | Description | | ||
|:--------------------|:-----------| | ||
| `FixedFontScaleContainer` | A container that fixes the font scale, ignoring values, that are set in the phone's system settings | | ||
|
||
## Contributing | ||
|
||
Merge requests are welcome. | ||
For major changes, please open an issue first to discuss what you would like to change. | ||
|
||
|
||
[mavenCentral]: https://search.maven.org/artifact/com.redmadrobot.extensions/compose-ktx | ||
[license]: ../LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
plugins { | ||
id("com.redmadrobot.android-library") | ||
id("com.redmadrobot.publish") | ||
convention.library.android | ||
} | ||
|
||
version = "1.6.6-0" | ||
description = "A set of gears for compose" | ||
|
||
redmadrobot { | ||
android.minSdk = 21 | ||
} | ||
|
||
android { | ||
namespace = "$group.compose" | ||
|
||
buildFeatures { | ||
compose = true | ||
} | ||
|
||
composeOptions { | ||
kotlinCompilerExtensionVersion = androidx.versions.compose.compiler.get() | ||
} | ||
} | ||
|
||
dependencies { | ||
api(androidx.compose.ui) | ||
api(androidx.compose.runtime) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.redmadrobot.extensions.compose | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.CompositionLocalProvider | ||
import androidx.compose.ui.platform.LocalDensity | ||
import androidx.compose.ui.unit.Density | ||
|
||
/** | ||
* A container that fixes the font scale, ignoring values, | ||
* that are set in the phone's system settings | ||
*/ | ||
@Composable | ||
public fun FixedFontScaleContainer( | ||
content: @Composable () -> Unit, | ||
) { | ||
val fixedFontScaleDensity = Density(LocalDensity.current.density) | ||
CompositionLocalProvider( | ||
LocalDensity provides fixedFontScaleDensity, | ||
content = content, | ||
) | ||
} | ||
|
||
/** | ||
* A container that restricts the font scale, ignoring values, | ||
* that are set in the phone's system settings | ||
* | ||
* @param limit - the upper limit of font enlargement | ||
*/ | ||
@Composable | ||
public fun LimitedFontScaleContainer( | ||
limit: Float, | ||
content: @Composable () -> Unit, | ||
) { | ||
val fontScale = LocalDensity.current.fontScale.coerceAtMost(limit) | ||
val fixedFontScaleDensity = Density( | ||
density = LocalDensity.current.density, | ||
fontScale = fontScale, | ||
) | ||
CompositionLocalProvider( | ||
LocalDensity provides fixedFontScaleDensity, | ||
content = content, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
group=com.redmadrobot.gears |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,4 +34,5 @@ include( | |
":ktx:lifecycle-livedata-ktx", | ||
":ktx:resources-ktx", | ||
":ktx:viewbinding-ktx", | ||
":gears:compose", | ||
) |