Replace with a description of your changes.
Replace with the reason for the changes you are making.
- Help reviewers by providing before/after screenshots or a quick video.
- Remove this section if there are no screenshots or videos.
| //___FILEHEADER___ | |
| import SwiftUI | |
| struct ___VARIABLE_ViewName___: View { | |
| @StateObject private var viewModel: ViewModel | |
| init(dependencies: ViewModel.Dependencies) { | |
| _viewModel = StateObject( | |
| wrappedValue: ViewModel( |
| import SwiftUI | |
| // swiftlint:disable identifier_name | |
| public extension Font { | |
| /// The different options for Public Sans font. | |
| enum PublicSans { | |
| /// H1 Font. | |
| /// Font: Public Sans. | |
| /// Weight: Bold. | |
| /// Size: 24. |
| import CoreGraphics | |
| import CoreText | |
| import UIKit | |
| enum FontError: Swift.Error { | |
| case failedToRegisterFont | |
| } | |
| func registerFont(named name: String) throws { | |
| guard let asset = NSDataAsset(name: "Fonts/\(name)", bundle: Bundle.module), |
| import Foundation | |
| extension JSONEncoder { | |
| /// Returns a JSONEncoder object using: | |
| /// * `.convertToSnakeCase` as `keyEncodingStrategy`. | |
| /// * `.iso8601` as `.dateEncodingStrategy`. | |
| static var `default`: JSONEncoder { | |
| let encoder = JSONEncoder() | |
| encoder.keyEncodingStrategy = .convertToSnakeCase | |
| encoder.dateEncodingStrategy = .iso8601 |
| import Foundation | |
| extension DateFormatter { | |
| /// A DateFormatter to display dates with all of your components day of the week ,day, month and year. | |
| /// The `dateFormat` property will always be set to `EEEE, MMMM dd, yyyy`. | |
| /// Example: `Friday, November 11, 2022`. | |
| /// - Parameters: | |
| /// - timeZone: The timezone for the formatter. Default: `.current`. | |
| /// - locale: The locale for the formatter. Default: `.current`. | |
| /// - Returns: The DateFormatter with the applied properties. |
| import Foundation | |
| /// Enum that represents the state of a view that loads information from the backend. | |
| enum ViewState<Info: Any> { | |
| /// Represents non state. Useful when used in combination with other ViewState. | |
| case initial | |
| /// Represents the loading state. | |
| case loading | |
| /// Represents an error. | |
| case error(_: Error) |
| import SwiftUI | |
| /// In this example: | |
| /// * The view model holds and publishes the view state wrapper value. | |
| /// * The view reacts to changes by holding an @StateObject reference to the view model. | |
| /// * The initial loading is an empty screen with a ProgressView in the middle. | |
| /// * Once we have some data, the subsequent loadings will not override the loaded data, | |
| /// and instead, will just display a ProgressView in the toolbar. | |
| struct ViewStateExampleView: View { | |
| @StateObject private var viewModel: ViewModel = .init() |