-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
95 additions
and
84 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
39 changes: 39 additions & 0 deletions
39
app/src/main/java/io/legado/app/data/entities/rule/FlexChildStyle.kt
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,39 @@ | ||
package io.legado.app.data.entities.rule | ||
|
||
import android.view.View | ||
import com.google.android.flexbox.FlexboxLayout | ||
|
||
data class FlexChildStyle( | ||
val layout_flexGrow: Float = 0F, | ||
val layout_flexShrink: Float = 1F, | ||
val layout_alignSelf: String = "auto", | ||
val layout_flexBasisPercent: Float = -1F, | ||
val layout_wrapBefore: Boolean = false, | ||
) { | ||
|
||
fun alignSelf(): Int { | ||
return when (layout_alignSelf) { | ||
"auto" -> -1 | ||
"flex_start" -> 0 | ||
"flex_end" -> 1 | ||
"center" -> 2 | ||
"baseline" -> 3 | ||
"stretch" -> 4 | ||
else -> -1 | ||
} | ||
} | ||
|
||
fun apply(view: View) { | ||
val lp = view.layoutParams as FlexboxLayout.LayoutParams | ||
lp.flexGrow = layout_flexGrow | ||
lp.flexShrink = layout_flexShrink | ||
lp.alignSelf = alignSelf() | ||
lp.flexBasisPercent = layout_flexBasisPercent | ||
lp.isWrapBefore = layout_wrapBefore | ||
} | ||
|
||
companion object { | ||
val defaultStyle = FlexChildStyle() | ||
} | ||
|
||
} |
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
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
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