Last active
September 9, 2019 09:39
-
-
Save creaaa/d0e68ff18ce0a20a5692989a1424e17e to your computer and use it in GitHub Desktop.
SwiftUI × Presentation
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 | |
// NaviGomi | |
// | |
// Created by crea on 2019/09/09. | |
// Copyright © 2019 crea. All rights reserved. | |
// | |
import SwiftUI | |
struct ContentView: View { | |
@State var openSheet: Bool { | |
didSet { | |
print("opensheet!\(openSheet)") | |
} | |
} | |
@State var openAlert: Bool | |
@State var openActionSheet: Bool | |
var body: some View { | |
VStack(spacing: 8) { | |
Button("Sheet") { self.openSheet.toggle() } | |
.sheet(isPresented: $openSheet) { | |
Text("Sheet!!!") | |
} | |
Button("Alert") { self.openAlert.toggle() } | |
.alert(isPresented: $openAlert) { | |
Alert(title: .init("このアカウント消したい?"), | |
message: .init("それは取り消せないけど..."), | |
primaryButton: Alert.Button.cancel(.init("やっぱやめた...")), | |
secondaryButton: Alert.Button.destructive(.init("けす!"))) | |
} | |
Button("ActionSheet") { self.openActionSheet.toggle() } | |
.actionSheet(isPresented: $openActionSheet) { | |
ActionSheet( | |
title: .init("beef or chicken?"), | |
buttons: [ | |
.default(.init("Beef")) { print("beef!") }, | |
.default(.init("Chicken")) { print("chicken!") }, | |
.cancel() | |
] | |
) | |
} | |
} | |
} | |
} | |
struct DestinationView: View { | |
var body: some View { | |
Text("goal!") | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView(openSheet: false, | |
openAlert: false, | |
openActionSheet: false | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment