-
-
Save fitomad/6a9ac00ba5fe8f028d7a948f26ed231b to your computer and use it in GitHub Desktop.
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
internal struct SessionView : View | |
{ | |
... | |
@ObservedObject private var sessionModel: SessionViewModel | |
/// Vista | |
var body: some View | |
{ | |
ScrollView([ .vertical ], showsIndicators: false) | |
{ | |
Button(action: self.handleFavoriteButtonTap) { | |
Text(self.sessionModel.isFavorite ? "Quitar de Favoritos" : "Marcar como favorita") | |
.font(.callout) | |
.fontWeight(.semibold) | |
.foregroundColor(self.sessionModel.isFavorite ? .accentColor : .white) | |
.frame(minWidth: 0, maxWidth: .infinity) | |
} | |
.frame(height: 50) | |
.background(self.sessionModel.isFavorite ? Color.white : Color.accentColor) | |
.cornerRadius(6) | |
.shadow(radius: self.sessionModel.isFavorite ? 0 : 4) | |
.padding([.top, .bottom], 24) | |
... | |
} | |
... | |
} | |
/** | |
*/ | |
internal init(for session: Session) | |
{ | |
... | |
self.sessionModel = SessionViewModel(forSession: session) | |
} | |
/** | |
*/ | |
private func handleFavoriteButtonTap() -> Void | |
{ | |
self.sessionModel.isFavorite.toggle() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment