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
@OptIn(ExperimentalFoundationApi::class) | |
fun Modifier.bounceClickable( | |
dampingRatio: Float = 0.85f, | |
enabled: Boolean = true, | |
onClick: () -> Unit = {}, | |
onDoubleClick: (() -> Unit)? = null, | |
onLongClick: (() -> Unit)? = null, | |
shape: Shape = RectangleShape, | |
useHapticFeedback: Boolean = true, | |
) = composed { |
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 SwiftUI | |
extension View { | |
@MainActor | |
func pdf(size: ProposedViewSize) -> Data { | |
let renderer = ImageRenderer(content: self) | |
renderer.proposedSize = size | |
var pdfData = NSMutableData() | |
renderer.render { size, render in | |
var mediaBox = CGRect(origin: .zero, size: size) |
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 UIKit | |
import AVFoundation | |
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { | |
let tableView = UITableView(frame: .zero, style: .plain) | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
tableView.register(PlayerTableViewCell.self, forCellReuseIdentifier: "PlayerCell") |
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
package des.c5inco.material3 | |
import android.graphics.Matrix | |
import android.graphics.Path | |
import androidx.compose.animation.core.* | |
import androidx.compose.foundation.Canvas | |
import androidx.compose.foundation.layout.Box | |
import androidx.compose.foundation.layout.Column | |
import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.foundation.layout.size |
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
/** | |
* Use this [ActivityResultContract] to seamlessly switch between | |
* the new [MediaStore.ACTION_PICK_IMAGES] and [Intent.ACTION_GET_CONTENT] | |
* based on the availability of the Photo Picker. | |
* | |
* Use [PickMultipleImages] if you'd like the user to be able to select multiple | |
* photos/videos. | |
* | |
* Input: the mimeType you'd like to receive. This should generally be | |
* either `image/\*` or `video/\*` for requesting only images or only videos |
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 SwiftUI | |
import Combine | |
import Common // Code shared through Kotlin Multiplaform. | |
import CombineExt // https://github.com/CombineCommunity/CombineExt | |
/// A convenience pass-through View to hide away the verbosity | |
/// of subscribing to a presenter's stream. Usage: | |
/// | |
/// struct FooView: View { | |
/// let presenter: FooPresenter |
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.shape(width: Dp, strokeBrush: Brush, fillColor: Color, shape: Shape): Modifier = composed( | |
factory = { | |
this.then( | |
when { | |
shape === RectangleShape -> rectangleModifier(width, strokeBrush, fillColor) | |
else -> shapeModifier(width, strokeBrush, fillColor, shape) | |
} | |
) | |
}, | |
inspectorInfo = debugInspectorInfo { |
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
inline fun <reified T> T.forceParcel(): T? where T : Parcelable { | |
val bytes = Parcel.obtain().use { | |
writeParcelable(this@forceParcel, 0) | |
marshall() | |
} | |
return Parcel.obtain().use { | |
unmarshall(bytes, 0, bytes.size) | |
setDataPosition(0) | |
readParcelable(T::class.java.classLoader) | |
} |
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
//region XcFramework tasks | |
val xcFrameworkPath = "xcframework/${project.name}.xcframework" | |
tasks.create<Delete>("deleteXcFramework") { delete = setOf(xcFrameworkPath) } | |
val buildXcFramework by tasks.registering { | |
dependsOn("deleteXcFramework") | |
group = "build" | |
val mode = "Release" | |
val frameworks = arrayOf("iosArm64", "iosX64") |
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 SwiftUI | |
// Note: There are some issues with using these modifiers inside of ButtonStyles on macOS. Please see https://twitter.com/noahsark769/status/1288256379640139776?s=20 for more info. | |
struct ConditionalContent<TrueContent: View, FalseContent: View>: View { | |
let value: Bool | |
let trueContent: () -> TrueContent | |
let falseContent: () -> FalseContent | |
@ViewBuilder var body: some View { |
NewerOlder