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
class ViewController: UIViewController { | |
@IBOutlet weak var imageView: UIImageView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
imageView.image = UIImage(systemName: "pencil.circle.fill")?.imageFlippedForRightToLeftLayoutDirection() | |
} | |
} |
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
final class SceneDelegate: UIResponder, UIWindowSceneDelegate { | |
func scene(_ scene: UIScene, | |
willConnectTo session: UISceneSession, | |
options connectionOptions: UIScene.ConnectionOptions) { | |
let contentView = ContentView().environment(\.layoutDirection, .rightToLeft) | |
if let windowScene = scene as? UIWindowScene { | |
let window = UIWindow(windowScene: windowScene) | |
window.rootViewController = UIHostingController(rootView: contentView) | |
self.window = window |
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
class AppDelegate: UIResponder, UIApplicationDelegate { | |
func application(_ application: UIApplication, | |
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
// Force all UIKit views to RTL | |
UIView.appearance().semanticContentAttribute = .forceRightToLeft | |
return true | |
} | |
} |
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
// | |
// TrackableScrollView.swift | |
// Lions | |
// | |
// Created by Soheil Novinfard on 22/04/2021. | |
// Copyright © 2021 David Rodriguez Luque. All rights reserved. | |
// | |
import SwiftUI |
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
{ | |
"lotteryList": [ | |
{ | |
"userId": 10, | |
"void": false | |
}, | |
{ | |
"userId": 22, | |
"void": 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
{ | |
"items": [ | |
{ | |
"userId": 10, | |
"name": "Jack Alexy", | |
"username": "JAlex", | |
"regDate": "2020-10-19" | |
}, | |
{ | |
"userId": 22, |
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
// 1. Create the key with a default value | |
private struct CaptionColorKey: EnvironmentKey { | |
static let defaultValue = Color(.secondarySystemBackground) | |
} | |
// 2. Extend the environment with our property | |
extension EnvironmentValues { | |
var captionBackgroundColor: Color { | |
get { self[CaptionColorKey.self] } | |
set { self[CaptionColorKey.self] = newValue } |
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
class Program { | |
class BST { | |
var value: Int | |
var left: BST? | |
var right: BST? | |
init(value: Int) { | |
self.value = value | |
} | |
} |
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 View { | |
func debug() -> Self { | |
print(Mirror(reecting: self).subjectType) | |
return self | |
} | |
} |
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 is available at | |
// https://github.com/dmytro-anokhin/url-image | |
import URLImage | |
struct URLOptionalImage: View { | |
var imageUrlString: String? | |
var body: some View { | |
if let urlString = imageUrlString, | |
let url = URL(string: urlString) { | |
URLImage(url: url) { image in |