private struct ScreamAtMeKey: EnvironmentKey { static let defaultValue = false } // Set via .environent(\.screamAtMe, true) extension EnvironmentValues { var screamAtMe: Bool { get { self[ScreamAtMeKey.self] } set { self[ScreamAtMeKey.self] = newValue } } } // Set via .screamAtMe(true) extension View { func screamAtMe(_ aaaaaah: Bool) -> some View { environment(.screamAtMe, aaaaaah) } }
struct ContentView: View { var body: some View { TabView { SimplePlan() .badge(23) .tabItem { Label("Simple Plan", systemImage: "house") } MultiPlan() .tabItem { Label("Simple Plan", systemImage: "house.lodge") } } } }
enum Tab: Hashable { case simplePlan case complicatedPlan case multiPlan var id: Self { self } } struct ContentView: View { @State private var tab = Tab.complicatedPlan var body: some View { TabView(selection: $tab) { SimplePlan(captureModel: SimpleCaptureModel.shared) .tabItem { Label("Simple Plan", systemImage: "house") } .tag(Tab.simplePlan) CompliPlan(captureModel: CompliCaptureModel.shared) .tabItem { Label("Complicated Plan", systemImage: "house.circle.fill") } .tag(Tab.complicatedPlan) MultiPlan() .tabItem { Label("Multi Plan", systemImage: "house.lodge") } .tag(Tab.multiPlan) } } }
.buttonStyle(.bordered) // gray filled oval .buttonStyle(.borderedProminent) // blue filled oval .buttonStyle(.borderless) // default (I think) - free floating random blue text .buttonStyle(.plain) // free floating random plain text. that's also a button
struct CustomButtonStyle: ButtonStyle { func makeBody(configuration: Configuration) -> some View { configuration.label .padding() .background(.purple) .foregroundStyle(.green) .clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous)) .scaleEffect(configuration.isPressed ? 2.0 : 1) .animation(.easeOut(duration: 0.05), value: configuration.isPressed) } }(please don't actually make buttons with this style...) And then attach it to something (say an individual button, or a top-level view) like
.buttonStyle(CustomButtonStyle())
Button("Button Text") { print("Snorgle") }
struct PlaceholderContainerView: UIViewRepresentable { func makeUIView(context: Context) -> PlaceholderUIView { return PlaceholderUIView() } func updateUIView(_ uIView: PlaceholderUIView, context: Context) { print("update ui view (context)") } }