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 UIKit | |
struct NoClipText: UIViewRepresentable { | |
typealias UIViewType = NoClipLabel | |
let text: String | |
let font: UIFont | |
let clipExtension: EdgeSizes |
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
extension UIHostingController { | |
convenience public init(rootView: Content, ignoreSafeArea: Bool) { | |
self.init(rootView: rootView) | |
if ignoreSafeArea { | |
disableSafeArea() | |
} | |
} | |
func disableSafeArea() { |
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 UIKit | |
extension Color { | |
var uiColor: UIColor { | |
if #available(iOS 14, *) { | |
// iOS 14 introduces an API to convert SwiftUI.Color to UIKit.UIColor | |
// but it does not produce a color which reacts to changes in color scheme | |
// (light mode/dark mode). To make that work we need to extract the color |
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 android.icu.text.MeasureFormat | |
import android.icu.text.NumberFormat | |
import android.icu.util.MeasureUnit | |
import android.os.Build | |
import java.util.Locale | |
import kotlin.time.Duration | |
import kotlin.time.ExperimentalTime | |
import kotlin.time.days | |
import kotlin.time.hours | |
import kotlin.time.milliseconds |
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 AppKit | |
import SwiftUI | |
// Delete this line if not using a playground | |
import PlaygroundSupport | |
struct ContentView: View { | |
var body: some View { | |
// if spacing is not set to zero, there will be a gap after the first row |
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
[ | |
{ | |
"code": "aa", | |
"name": "Afar", | |
"native": "Afar" | |
}, | |
{ | |
"code": "ab", | |
"name": "Abkhazian", | |
"native": "Аҧсуа" |
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 Combine | |
import SwiftUI | |
class RemoteImageLoader: ObservableObject { | |
@Published var data: Data = Data() | |
init(imageURL: URL) { | |
URLSession.shared.dataTask(with: imageURL) { data, response, error in | |
guard let data = data else { return } |
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 | |
struct ExampleTabbedView : View { | |
@State private var selection = 1 | |
var body: some View { | |
TabbedView(selection: $selection) { | |
Text("Tab 1") | |
.tabItem({ |
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 Kingfisher | |
import UIKit | |
public struct NetworkImage: SwiftUI.View { | |
// swiftlint:disable:next redundant_optional_initialization | |
@State private var image: UIImage? = nil | |
public let imageURL: URL? |
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 'package:flutter/gestures.dart' show DragStartBehavior; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/widgets.dart'; | |
void main() { | |
runApp( | |
MaterialApp( | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primaryColor: Colors.indigo, |
NewerOlder