-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added alignment prop for android (#2)
* feat: added alignment prop for android * fix: little update * fix: more fixes * fix: saving alignment in the same way as fit property * fix: added proper package header / removed unnecessary import Co-authored-by: TMaszko <tomasz.krzyzowski@callstack.com>
- Loading branch information
Showing
6 changed files
with
94 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.rivereactnative | ||
|
||
import app.rive.runtime.kotlin.core.Alignment | ||
|
||
enum class RNAlignment(private val mValue: String) { | ||
TopLeft("topLeft"), | ||
TopCenter("topCenter"), | ||
TopRight("topRight"), | ||
CenterLeft( "centerLeft"), | ||
Center("center"), | ||
CenterRight("centerRight"), | ||
BottomLeft("bottomLeft"), | ||
BottomCenter("bottomCenter"), | ||
BottomRight("bottomRight"); | ||
|
||
override fun toString(): String { | ||
return mValue | ||
} | ||
|
||
companion object { | ||
|
||
fun mapToRNAlignment(alignment: String): RNAlignment { | ||
return valueOf(values().first() {it.toString() == alignment }.name) | ||
} | ||
|
||
fun mapToRiveAlignment(v: RNAlignment): Alignment { | ||
return when (v) { | ||
TopLeft -> Alignment.TOP_LEFT | ||
TopCenter -> Alignment.TOP_CENTER | ||
TopRight -> Alignment.TOP_RIGHT | ||
CenterLeft -> Alignment.CENTER_LEFT | ||
Center -> Alignment.CENTER | ||
CenterRight -> Alignment.CENTER_RIGHT | ||
BottomLeft -> Alignment.BOTTOM_LEFT | ||
BottomCenter -> Alignment.BOTTOM_CENTER | ||
BottomRight -> Alignment.BOTTOM_RIGHT | ||
else -> throw IllegalStateException("Unsupported Alignment type") | ||
} | ||
} | ||
} | ||
} |
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