From a6507c999605592e1dc7e7c2d299182330a0322a Mon Sep 17 00:00:00 2001 From: Alex Usbergo Date: Fri, 5 Jun 2020 14:46:18 +0200 Subject: [PATCH] demo --- .../store_hacker_news/ContentView.swift | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/Demo/store_hacker_news/store_hacker_news/ContentView.swift b/Demo/store_hacker_news/store_hacker_news/ContentView.swift index 9761535..15049d5 100644 --- a/Demo/store_hacker_news/store_hacker_news/ContentView.swift +++ b/Demo/store_hacker_news/store_hacker_news/ContentView.swift @@ -60,19 +60,36 @@ struct StoryView: View { } var body: some View { + Group { + if store.isSelected { + expanded + } else { + collapsed + } + }.padding() + } + + var collapsed: some View { Button(action: store.select) { - VStack(alignment: store.isSelected ? .center : .leading) { + VStack(alignment: .leading) { Text(title).font(.headline) - Text(caption).font(.subheadline).lineLimit(store.isSelected ? nil : 4) - - if store.isSelected { - Button(action: store.deselect) { - Image(systemName: "xmark.circle") - } - } + Text(caption).font(.subheadline).lineLimit(2) + } + } + } + + var expanded: some View { + VStack(alignment: .center) { + Text(title).font(.system(.headline, design: .rounded)) + ScrollView { + Text(caption).font(.callout) + } + Spacer() + Button(action: store.deselect) { + Image(systemName: "xmark.circle") } - .padding() } } + }