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 ContentView: View { | |
| @State var isOuterLoading1 = false | |
| @State var isOuterLoading2 = false | |
| var body: some View { | |
| VStack { | |
| HStack { | |
| Spacer() | |
| Circle() // Sun |
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 UIImage { | |
| class func gifImage(data: Data) -> UIImage? { | |
| guard let source = CGImageSourceCreateWithData(data as CFData, nil) else { return nil } | |
| let count = CGImageSourceGetCount(source) | |
| let delays = (0..<count).map { | |
| Int(delayForImage(at: $0, source: source) * 1000) | |
| } | |
| let duration = delays.reduce(0, +) | |
| let gcd = delays.reduce(0, gcd) | |
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 BackgroundColorChange: View { | |
| let gridItems = [GridItem(.flexible()), GridItem(.flexible(minimum: 20, maximum: 50)), GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible(minimum: 10, maximum: 20))] | |
| var body: some View { | |
| ScrollView { | |
| LazyVGrid(columns: gridItems, spacing: 0) { | |
| ForEach(0...100, id: \.self) { | |
| Text("\($0)") | |
| .padding() |
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 View { | |
| func debugOnlyModifier<T: View>(_ modifier: (Self) -> T) -> some View { | |
| #if DEBUG | |
| return modifier(self) | |
| #else | |
| return self | |
| #endif | |
| } | |
| private var colors: [Color] { |
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 PrintingChanges: View { | |
| @State var counter = 0 | |
| var body: some View { | |
| Self._printChanges() | |
| return Button { | |
| counter += 1 | |
| } label: { | |
| Text("Current Value \(counter)") | |
| } |
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 Foundation | |
| import XCTest | |
| struct ContentViewHelper { | |
| static let app = XCUIApplication() | |
| enum StaticText { | |
| static let titleText = app.staticTexts["Normal Text"] | |
| static let overriddenTitleText = app.staticTexts["Text Overridden for UI Tests"] | |
| static let view1Text = app.staticTexts["View - 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 XCTest | |
| import SwiftUI | |
| class SwiftUI_UITesting_MediumUITests: XCTestCase { | |
| let app = XCUIApplication() | |
| override func setUp() { | |
| super.setUp() | |
| continueAfterFailure = false |
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
| @main | |
| struct SwiftUI_UITesting_MediumApp: App { | |
| init() { | |
| loadEnvironmentRelatedServices() | |
| } | |
| var body: some Scene { | |
| WindowGroup { | |
| ContentView() | |
| } |
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 AppDelegate: NSObject, UIApplicationDelegate { | |
| func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { | |
| //put custom code here | |
| return true | |
| } | |
| } |
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 TestDetector { | |
| private enum Keys: String { | |
| case shouldOverrideTitleText = "Override-Label-titleText" | |
| case showView2 = "Override-showView2" | |
| } | |
| static func isRunningUITests() -> Bool { | |
| return ProcessInfo.processInfo.arguments.contains("isRunningUITests") | |
| } | |
NewerOlder