From 966dbd15cf68a23602b8e0be96b71cc23212e44a Mon Sep 17 00:00:00 2001 From: Stefan Kofler Date: Wed, 30 Oct 2019 11:46:08 +0100 Subject: [PATCH] update exercise descriptions --- SwiftUITalk/Views/BlogListView.swift | 14 ++++++++------ SwiftUITalk/Views/DragRectangleView.swift | 15 ++++++++++----- SwiftUITalk/Views/LoginView.swift | 2 ++ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/SwiftUITalk/Views/BlogListView.swift b/SwiftUITalk/Views/BlogListView.swift index 771119d..7f95c7e 100644 --- a/SwiftUITalk/Views/BlogListView.swift +++ b/SwiftUITalk/Views/BlogListView.swift @@ -25,13 +25,14 @@ struct PostCell: View { let post: Post var body: some View { - VStack(spacing: 8) { - Image(uiImage: post.header) - .resizable() - .scaledToFit() - .frame(minWidth: 0, maxWidth: .infinity) + Image(uiImage: post.header) + .resizable() + .scaledToFit() - }.padding(.vertical, 16) + // Exercise 2: Create a nice looking UI for the cells like shown on the slides + + // Hint 1: Stacks are really helpful to create a UI like this + // Hint 2: Use predefined Colors like .primary and .secondary } } @@ -39,5 +40,6 @@ struct PostCell: View { struct BlogListView_Previews: PreviewProvider { static var previews: some View { BlogListView(posts: DataService().getPosts()) + } } diff --git a/SwiftUITalk/Views/DragRectangleView.swift b/SwiftUITalk/Views/DragRectangleView.swift index 4630a72..14541be 100644 --- a/SwiftUITalk/Views/DragRectangleView.swift +++ b/SwiftUITalk/Views/DragRectangleView.swift @@ -10,16 +10,21 @@ import SwiftUI struct DragRectangleView: View { - @State private var translation: CGSize = .zero - @State private var isDragging = false - var body: some View { - BockView() + BlockView() + // Exercise 3.1: Make BlockView draggable and follow your finger + // Exercise 3.2: Animate only the movement back to the original position when lifting up your finger + // Exercise 3.3: Add scaleEffect when Block is being moved + // Exercise 3.4: Change the rectangles color based on its position + + // Hint 1: DragGesture and .offset are your friend + // Hint 2: Use minimumDistance: 0 to react to touch events without movements as well + // Hint 3: An animation duration of 0 can help you deactivate animations for specic usecases } } -struct BockView: View { +struct BlockView: View { var body: some View { Rectangle() diff --git a/SwiftUITalk/Views/LoginView.swift b/SwiftUITalk/Views/LoginView.swift index 5d6e0af..3cbe838 100644 --- a/SwiftUITalk/Views/LoginView.swift +++ b/SwiftUITalk/Views/LoginView.swift @@ -27,6 +27,8 @@ struct LoginView: View { SecureField("Password", text: $password) } + // Exercise 1: Add new Toggl element for accepting terms and conditions + NavigationLink("Submit", destination: BlogListView(posts: DataService().getPosts())) .disabled(username.isEmpty || password.isEmpty) }.navigationBarTitle("Login", displayMode: .inline)