Mercurial > public > lazybear
changeset 301:cbe579dcd7b3
Reorganize file structure
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Wed, 24 Mar 2021 14:48:41 +0100 |
parents | 2f04d8b1e0ad |
children | 4f9b0ba0e52c |
files | LazyBear/Views/OnboardView.swift LazyBear/Views/WelcomeView.swift |
diffstat | 2 files changed, 0 insertions(+), 195 deletions(-) [+] |
line wrap: on
line diff
--- a/LazyBear/Views/OnboardView.swift Wed Mar 24 14:47:35 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,127 +0,0 @@ -// -// OnboardView.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 21/3/21. -// - -import SwiftUI - -extension Animation { - static func ripple(index: Int) -> Animation { - Animation.spring(dampingFraction: 0.5) - .speed(2) - .delay(0.03 * Double(index)) - } -} - -class OnboardRowItems { - var icons = ["heart.fill", "chart.bar.fill", "paintbrush.fill"] - var iconColors: [Color] = [.red, .blue, .green] - var headlines = ["Your stocks at a glance", "Interactive charts", "New design"] - var bodyTexts = ["Easily create watchlists with your favourite companies.", "Long press, drag, tap and have fun with the charts.", "Modern, clean and neat without losing simplicty."] -} -struct OnboardView: View { - let onboardRowItems = OnboardRowItems() - @State private var showingButton = false - @State private var showOnboardRows = false - @State var showContentView = false - - var body: some View { - if !showContentView { - GeometryReader { geo in - VStack(alignment: .leading) { - Text("What's new") - .font(.system(size: 50, weight: .black)) - .padding(.bottom) - .opacity(showOnboardRows ? 1: 0) - .animation(.easeInOut) - - ForEach((0..<3), id: \.self) { index in - if showOnboardRows { - OnboardRow(icon: onboardRowItems.icons[index], iconColor: onboardRowItems.iconColors[index], headline: onboardRowItems.headlines[index], bodyText: onboardRowItems.bodyTexts[index], position: index+1) - .transition(.slide) - .animation(.ripple(index: index)) - } - } - Spacer() - OnboardButton(showContentView: $showContentView) - .offset(y: showingButton ? 0 : 200) - .animation(.easeInOut) - - } - .onAppear { - DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) { - self.showingButton = true - } - DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { - self.showOnboardRows = true - } - } - .padding(geo.size.width * 0.15) - } - } else { - ContentView() - } - } -} - -struct OnboardRow: View { - var icon: String - var iconColor: Color - var headline: String - var bodyText: String - var position: Int - - let columns = [GridItem(.flexible())] - - var body: some View { - HStack(alignment: .center) { - Image(systemName: icon) - .foregroundColor(iconColor) - .frame(width: 40) - .font(.system(size: 35)) - .padding(.trailing) - - VStack(alignment: .leading) { - Text(headline) - .font(.headline) - - Text(bodyText) - } - } - .padding(.bottom) - } -} - -struct OnboardButton: View { - @Binding var showContentView: Bool - - var body: some View { - HStack { - Spacer() - Button(action: { self.showContentView = true }) { - RoundedRectangle(cornerRadius: 10) - .foregroundColor(.blue) - .frame(height: 50) - .overlay( - Text("Continue") - .foregroundColor(.white) - ) - } - - Spacer() - } - } - -// func writeUserDefaults() { -// let defaults = UserDefaults.standard -// defaults.setValue(true, forKey: "IsAppAlreadyLaunchedOnce") -// } -} - -struct OnboardView_Previews: PreviewProvider { - static var previews: some View { - OnboardView() - } -}
--- a/LazyBear/Views/WelcomeView.swift Wed Mar 24 14:47:35 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -// -// WelcomeView.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 21/3/21. -// - -import SwiftUI - -struct WelcomeView: View { - @State private var showingOnboardView = false - @State private var showProgressView = false - - var body: some View { - if showingOnboardView { - OnboardView() - } else { - GeometryReader { geo in - VStack(alignment: .leading) { - Spacer() - Image("default") - .resizable() - .frame(width: geo.size.width * 0.2, height: geo.size.width * 0.2) - .cornerRadius(25) - .shadow(color: Color.black.opacity(0.2), radius: 10) - - Group { - Text("Welcome to") - Text("Lazybear") - .foregroundColor(.blue) - .offset(y: -15) - .padding(.bottom, -15) - } - .font((.system(size: 50, weight: .black))) - - Text("Easily follow your stocks and the markets in real-time.") - - HStack { - if self.showProgressView { - Spacer() - ProgressView() - Spacer() - } - } - .padding() - .frame(height: 30) - - Spacer() - } - .padding(geo.size.width * 0.15) - .onAppear { - DispatchQueue.main.asyncAfter(deadline: .now() + 5) { - self.showingOnboardView = true - } - DispatchQueue.main.asyncAfter(deadline: .now() + 1) { - self.showProgressView = true - } - } - } - } - } -} - -struct WelcomeView_Previews: PreviewProvider { - static var previews: some View { - WelcomeView() - } -}