This file contains hidden or 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 PopupViewController:UIViewController{ | |
let frame:CGRect | |
let content:AnyView | |
required init?(coder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} | |
override func viewDidLoad() { |
This file contains hidden or 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
func scaleAndOrient(image: UIImage) -> UIImage { | |
// Set a default value for limiting image size. | |
let maxResolution: CGFloat = 640 | |
guard let cgImage = image.cgImage else { | |
print("UIImage has no CGImage backing it!") | |
return image | |
} |
This file contains hidden or 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 Calendar { | |
func generateDates( | |
inside interval: DateInterval, | |
matching components: DateComponents | |
) -> [Date] { | |
var dates: [Date] = [] | |
dates.append(interval.start) |
This file contains hidden or 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
/** | |
* PreviewDevice+ListOfPads.swift | |
* Copyright (c) Thiago Holanda 2020 | |
* https://twitter.com/tholanda | |
* | |
* MIT license | |
*/ | |
import SwiftUI |
This file contains hidden or 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 ContentView: View { | |
@State var gradient = [ | |
Color.red, .orange, .yellow, .green, .blue, .purple, Color.red, .orange, .yellow, .green, .blue, .purple, | |
] | |
@State var startPoint = UnitPoint(x: 0, y: -1) | |
@State var endPoint = UnitPoint(x: 0, y: 1) |
This file contains hidden or 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 AnimalView: View { | |
var model: Animal | |
var body: some View { | |
VStack { | |
Image(systemName: model.systemImageName) | |
.resizable() | |
.scaledToFit() |
This file contains hidden or 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
func makePNG(_ size: NSSize, by drawing: (CGContext) -> ()) -> Data? { | |
guard let bitmapImageRep = NSBitmapImageRep(bitmapDataPlanes: nil, | |
pixelsWide: Int(size.width), | |
pixelsHigh: Int(size.height), | |
bitsPerSample: 8, | |
samplesPerPixel: 4, | |
hasAlpha: true, | |
isPlanar: false, | |
colorSpaceName: NSColorSpaceName.deviceRGB, | |
bytesPerRow: 0, bitsPerPixel: 0) else { |
This file contains hidden or 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
// | |
// ContentView.swift | |
// TryGeometryReader | |
// | |
// Created by satoutakeshi on 2019/12/07. | |
// Copyright © 2019 satoutakeshi. Licensed under MIT. | |
// | |
import SwiftUI |
This file contains hidden or 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
/** | |
* MacEditorTextView | |
* Copyright (c) Thiago Holanda 2020-2021 | |
* https://bsky.app/profile/tholanda.com | |
* | |
* (the twitter account is now deleted, please, do not try to reach me there) | |
* https://twitter.com/tholanda | |
* | |
* MIT license | |
*/ |
This file contains hidden or 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 ViewControllerHolder { | |
weak var value: UIViewController? | |
init(_ value: UIViewController?) { | |
self.value = value | |
} | |
} | |
struct ViewControllerKey: EnvironmentKey { | |
static var defaultValue: ViewControllerHolder { return ViewControllerHolder(UIApplication.shared.windows.first?.rootViewController ) } |