Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.