Last active
August 6, 2020 21:12
-
-
Save kutan74/57912d9c43867aa80a856998d14e4601 to your computer and use it in GitHub Desktop.
SwiftUI Expandable Rows
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
// | |
// 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