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
import QuartzCore | |
extension CALayer { | |
struct Animation<Value> { | |
let keyPath: ReferenceWritableKeyPath<CALayer, Value> | |
let value: Value | |
let duration: TimeInterval | |
let timingFunction: CAMediaTimingFunction? = nil | |
let beginFromCurrentState = false | |
} |
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
import Foundation | |
extension NSError { | |
convenience init(description: String, code: Int = 0) { | |
self.init( | |
domain: "plist script", | |
code: code, | |
userInfo: [NSLocalizedDescriptionKey: description] | |
) | |
} |
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
struct GradientTestView: View { | |
@State private var startPoint = UnitPoint(x: 0.762648, y: -0.376472566) | |
@State private var endPoint = UnitPoint(x: 0.812653333, y: 0.803190265) | |
let scale: CGFloat = 1.5 | |
var body: some View { | |
ZStack { | |
GeometryReader { proxy in | |
let size = CGSize( | |
width: proxy.size.width / scale, |
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
struct ForEachIndexed<Data: RandomAccessCollection, Content: View, ID: Hashable>: View, DynamicViewContent where Data.Index: Hashable { | |
var data: [(Data.Index, Data.Element)] { | |
forEach.data | |
} | |
let forEach: ForEach<[(Data.Index, Data.Element)], ID, Content> | |
init( | |
_ data: Data, | |
id: KeyPath<Data.Element, ID>, |
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
@Composable | |
fun MiddleEllipsisText( | |
text: String, | |
modifier: Modifier = Modifier, | |
color: Color = Color.Unspecified, | |
fontSize: TextUnit = TextUnit.Unspecified, | |
fontStyle: FontStyle? = null, | |
fontWeight: FontWeight? = null, | |
fontFamily: FontFamily? = null, | |
letterSpacing: TextUnit = TextUnit.Unspecified, |
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
@Composable | |
fun <I, O> rememberLambda(lambda: (I) -> O) = remember { lambda } | |
@Composable | |
fun <I, O> rememberLambda( | |
key1: Any?, | |
lambda: (I) -> O | |
) = remember(key1) { lambda } | |
@Composable |
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
fun Modifier.swipeableLeftRight(onLeft: () -> Unit, onRight: () -> Unit): Modifier = composed { | |
var width by rememberSaveable { mutableStateOf(0f) } | |
val swipeableState = rememberSwipeableState( | |
SwipeDirection.Initial, | |
animationSpec = snap() | |
) | |
val anchorWidth = remember(width) { | |
if (width == 0f) { | |
1f | |
} else { |
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
fun Modifier.swipeableTopBottom(onTop: () -> Unit, onBottom: () -> Unit): Modifier = composed { | |
var width by rememberSaveable { mutableStateOf(0f) } | |
val swipeableState = rememberSwipeableState( | |
SwipeDirection.Initial, | |
animationSpec = snap() | |
) | |
val anchorWidth = remember(width) { | |
if (width == 0f) { | |
1f | |
} else { |
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
@Composable | |
inline fun LtrRow( | |
modifier: Modifier = Modifier, | |
horizontalArrangement: Arrangement.Horizontal = Arrangement.Start, | |
verticalAlignment: Alignment.Vertical = Alignment.Top, | |
crossinline content: @Composable RowScope.() -> Unit | |
) { | |
val direction = LocalLayoutDirection.current | |
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) { | |
Row( |
OlderNewer