Skip to content

Instantly share code, notes, and snippets.

@kutan74
Last active August 6, 2020 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kutan74/57912d9c43867aa80a856998d14e4601 to your computer and use it in GitHub Desktop.
Save kutan74/57912d9c43867aa80a856998d14e4601 to your computer and use it in GitHub Desktop.
SwiftUI Expandable Rows
//
// RowView.swift
// Pop
//
// Created by KUTAN ÇINGISIZ on 7.06.2019.
// Copyright © 2019 KUTAN ÇINGISIZ. All rights reserved.
//
import SwiftUI
struct RowView : View {
let subItem = Text("Lorem ipsum dolor sit amet")
@State var showSubItem = false
var body: some View {
VStack(alignment: .leading) {
Text("Item").font(.headline)
// Show sub item when the whole view being tapped
if showSubItem {
subItem.transition(.opacity)
}
}.tapAction {
withAnimation {
self.showSubItem.toggle()
}
}
}
}
#if DEBUG
struct RowView_Previews : PreviewProvider {
static var previews: some View {
RowView()
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment