Skip to content

Instantly share code, notes, and snippets.

@fvilarino
fvilarino / draggable_content_final.kt
Created June 22, 2023 18:56
Draggable Contente - Final
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
PlaygroundTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
) {
Box {
@har5hit
har5hit / SuspendFunctionsFromSwift.md
Created August 3, 2022 20:25
Calling kotlin suspend functions from Swift

Works

Suspend function can be called from swift on Main thread. Examples:

// Sample.kt
suspend fun add(a: Int, b: Int): Int {
    return a + b;
}

// Sample.swift
struct DependencyInjector {
private static var dependencyList: [String:Any] = [:]
static func resolve<T>() -> T {
guard let t = dependencyList[String(describing: T.self)] as? T else {
fatalError("No povider registered for type \(T.self)")
}
return t
}
@jbnunn
jbnunn / SignInView.swift
Last active June 6, 2024 08:52
SwiftUI + PhoneNumberKit implementation
import SwiftUI
import UIKit
import PhoneNumberKit
struct PhoneNumberTextFieldView: UIViewRepresentable {
@Binding var phoneNumber: String
private let textField = PhoneNumberTextField()
func makeUIView(context: Context) -> PhoneNumberTextField {
textField.withExamplePlaceholder = true
// The SwiftUI Lab
// Website: https://swiftui-lab.com
// Article: https://swiftui-lab.com/alignment-guides
import SwiftUI
class Model: ObservableObject {
@Published var minimumContainer = true
@Published var extendedTouchBar = false
@Published var twoPhases = true
@saurabhdhillon
saurabhdhillon / SpanningLinearLayoutManager.java
Created February 14, 2019 11:22
Distribute items inside recycle-view evenly.
package com.ed.lib.base.utils;
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.ViewGroup;
public class SpanningLinearLayoutManager extends LinearLayoutManager {
@TheFinestArtist
TheFinestArtist / ZoomLayout.java
Last active February 22, 2024 10:46 — forked from anorth/ZoomLayout.java
Pinch-zoomable Android frame layout
package au.id.alexn;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import android.widget.FrameLayout;
@janheinrichmerker
janheinrichmerker / LICENSE
Last active August 29, 2023 14:28
LinearLayoutManager implementation that stretches to fit all list items on screen and disables scrolling. Useful for dashboards etc.
MIT License
Copyright (c) 2020 Jan Heinrich Reimer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: