This gist shows how to add a tooltip including a button to show it in a header of a table created using SwiftUI. It is used in ASO Suite.
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
// | |
// RoundedPolygon.swift | |
// | |
// Created by Nate on 2022-10-17. | |
// | |
import SwiftUI | |
struct RoundedPolygon: Shape { | |
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
// | |
// ContentView.swift | |
// SwiftUIPlayground | |
// | |
// Created by BJ Homer on 4/26/21. | |
// | |
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
import UIKit | |
import AVFoundation | |
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { | |
let tableView = UITableView(frame: .zero, style: .plain) | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
tableView.register(PlayerTableViewCell.self, forCellReuseIdentifier: "PlayerCell") |
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
import SwiftUI | |
import RevenueCat | |
struct Constants { | |
static let apiKey = "<your_api_key>" // Will look like: appl_bunchofotherstuffhere | |
static let entitlementName = "<your_entitlement_name>" // I use something like "pro" | |
} | |
@main | |
struct ATinySampleApp: App { |
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
struct ContentView: View { | |
@State var pictureExpanded = false | |
var body: some View { | |
VStack(alignment: .leading, spacing: 0) { | |
Text("Once upon a time there was a turtle named George who made friends with a giraffe at the local water park and then they went on lots of adventures together.") | |
Button { | |
withAnimation { | |
pictureExpanded.toggle() |
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
import UIKit | |
protocol StepAnimatable { | |
/// Start a sequence where you add each step in the `addSteps` closure. Use the provided `AnimationSequence` object | |
/// to add each step which should either be an actual animation or a delay. | |
/// The `completion` closure is executed when the last animation has finished. | |
/// - Parameters: | |
/// - addSteps: Closure used to add steps to the provided `AnimationSequence` object | |
/// - completion: Executed when the last animation has finished. |
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
import Foundation | |
import SwiftUI | |
extension EnvironmentValues { | |
public func value<T>(_: T.Type = T.self, forKey key: String) -> T? { | |
guard let value = first(where: { name($0, equals: key) }) else { | |
print("No EnvironmentValue with key '\(key)' found.") | |
return nil | |
} |
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 relative(width: CGFloat? = nil, height: CGFloat? = nil, alignment: Alignment = .center) -> some View { | |
Color.clear | |
.frame(maxWidth: width.map { _ in .infinity }, maxHeight: height.map { _ in .infinity }) | |
.overlay(GeometryReader { proxy in | |
ZStack { | |
self.frame( | |
width: width.map { proxy.size.width * $0 }, | |
height: height.map { proxy.size.height * $0 } | |
) |
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
// This gist demonstrates how you can implement versioning for a Codable struct to support loading | |
// old serialized data after changing the structure. Notable features of this solution: | |
// | |
// * No need to make new properties optional, or to perform post-processing on the struct after | |
// loading in ordeer to populate missing values | |
// * No need to change the call site - from the outside this struct behaves just the same | |
// as if we had implemented codable directly in the normal way. | |
// * Versioning can be applied individually to parents or leaves in a larger tree of | |
// structs without affecting the other elements | |
// * This approach will work even if the original struct was not designed with versioning in mind |
NewerOlder