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
| // with: | |
| // FileManageExtensions.swift | |
| // https://gist.github.com/benigumocom/6a8e4506438b5260469c12b1c12c0fb7 | |
| do { | |
| let documents = URL.documentsDirectory | |
| let text = "あいうえお" | |
| // convert to data bytes | |
| print( |
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
| extension URL { | |
| var exists: Bool { | |
| isFile || isDirectory | |
| } | |
| var isFile: Bool { | |
| (try? resourceValues(forKeys: [.isRegularFileKey]))?.isRegularFile == true | |
| } | |
| var isDirectory: Bool { |
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
| extension URL { | |
| // private var resourceIsDirectory: Bool? { | |
| // (try? resourceValues(forKeys: [.isDirectoryKey]))?.isDirectory | |
| // } | |
| var exists: Bool { | |
| // resourceIsDirectory != nil | |
| // (try? resourceValues(forKeys: [.isDirectoryKey]))?.isDirectory != nil | |
| // (try? resourceValues(forKeys: [.isRegularFileKey]))?.isRegularFile != nil | |
| isFile || isDirectory |
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 Chart: View { | |
| var function: (Double) -> Double | |
| var by: Double | |
| private let height = 20.0 | |
| private var data: [Double] { | |
| stride(from: -3.0, to: 3.0 + by , by: by) |
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 TestColorValues: View { | |
| var color: Color | |
| @Environment(\.self) private var environment | |
| private var resolved: Color.Resolved { | |
| color.resolve(in: environment) | |
| } |
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 TestDragGesture: View { | |
| @State private var location = CGPoint(x: 150, y: 150) | |
| @State private var startLocation: CGPoint? | |
| var body: some View { | |
| Circle() | |
| .fill(.orange) | |
| .frame(width: 200) |
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 TestSymbolTransition: View { | |
| @State private var value = true | |
| var body: some View { | |
| VStack { | |
| Button { | |
| value.toggle() |
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
| extension GroupBoxStyle where Self == MusicGroupBoxStyle { | |
| static var music: MusicGroupBoxStyle { .init() } | |
| //static var music: Self { Self() } | |
| } |
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 BackgroundCheckeredPattern<Content: View>: View { | |
| var size: CGFloat = 10 | |
| @ViewBuilder var content: () -> Content | |
| var body: some View { | |
| ZStack { | |
| CheckeredPattern(size: size) | |
| .edgesIgnoringSafeArea(.all) |