changeset 313:c6d1940aa68e

Implementing SignUp
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Thu, 25 Mar 2021 17:08:13 +0100
parents d0f7e9231178
children ec6a8f637266
files LazyBear.xcodeproj/project.pbxproj LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate LazyBear/Assets.xcassets/Avatars/Random selection/random1.imageset/randomBoy1.png LazyBear/Assets.xcassets/Avatars/Random selection/random2.imageset/Contents.json LazyBear/Assets.xcassets/Avatars/Random selection/random2.imageset/randomBoy2.png LazyBear/Assets.xcassets/Avatars/Random selection/random3.imageset/Contents.json LazyBear/Assets.xcassets/Avatars/Random selection/random3.imageset/randomBoy3.png LazyBear/Assets.xcassets/Avatars/Random selection/random4.imageset/Contents.json LazyBear/Assets.xcassets/Avatars/Random selection/random4.imageset/random4.png LazyBear/Assets.xcassets/Avatars/Random selection/random5.imageset/Contents.json LazyBear/Assets.xcassets/Avatars/Random selection/random5.imageset/randomGirl1.png LazyBear/Assets.xcassets/Avatars/Random selection/random6.imageset/Contents.json LazyBear/Assets.xcassets/Avatars/Random selection/random6.imageset/randomGirl2.png LazyBear/Assets.xcassets/Avatars/Random selection/random7.imageset/Contents.json LazyBear/Assets.xcassets/Avatars/Random selection/random7.imageset/randomGirl3.png LazyBear/Assets.xcassets/Avatars/Random selection/random8.imageset/Contents.json LazyBear/Assets.xcassets/Avatars/Random selection/random8.imageset/randomGirl4.png LazyBear/Assets.xcassets/Memojis/testMemoji.imageset/testMemoji.png LazyBear/LazyBear.xcdatamodeld/LazyBear.xcdatamodel/contents LazyBear/Views/Onboarding/Helpers/EnvironmentSignUp.swift LazyBear/Views/Onboarding/Helpers/ListAvatarHelper.swift LazyBear/Views/Onboarding/SignUpView.swift UserSettings+CoreDataClass.swift UserSettings+CoreDataProperties.swift
diffstat 24 files changed, 303 insertions(+), 100 deletions(-) [+]
line wrap: on
line diff
--- a/LazyBear.xcodeproj/project.pbxproj	Thu Mar 25 17:07:59 2021 +0100
+++ b/LazyBear.xcodeproj/project.pbxproj	Thu Mar 25 17:08:13 2021 +0100
@@ -7,12 +7,15 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		95201A2F260C9CAF007D5300 /* SignUpView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95201A2E260C9CAF007D5300 /* SignUpView.swift */; };
+		95201A3E260CB20A007D5300 /* ListAvatarHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95201A3D260CB20A007D5300 /* ListAvatarHelper.swift */; };
 		954D7EA7260BBA6600A13C50 /* WatchlistCompany+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954D7EA5260BBA6600A13C50 /* WatchlistCompany+CoreDataClass.swift */; };
 		954D7EA8260BBA6600A13C50 /* WatchlistCompany+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954D7EA6260BBA6600A13C50 /* WatchlistCompany+CoreDataProperties.swift */; };
 		954D7EAC260BBB2400A13C50 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954D7EAB260BBB2400A13C50 /* HomeView.swift */; };
 		954D7EB1260BBBEA00A13C50 /* UserHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954D7EB0260BBBEA00A13C50 /* UserHelper.swift */; };
 		954D7EC2260BE70C00A13C50 /* SwiftlySearch in Frameworks */ = {isa = PBXBuildFile; productRef = 954D7EC1260BE70C00A13C50 /* SwiftlySearch */; };
 		954D7EC6260BE84100A13C50 /* WatchlistPreviewHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954D7EC5260BE84100A13C50 /* WatchlistPreviewHelper.swift */; };
+		95531C79260CBECC00F0916A /* EnvironmentSignUp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95531C78260CBECC00F0916A /* EnvironmentSignUp.swift */; };
 		95672B8F25DDA54700DCBE4A /* LazyBearApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95672B8E25DDA54700DCBE4A /* LazyBearApp.swift */; };
 		95672B9325DDA54700DCBE4A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 95672B9225DDA54700DCBE4A /* Assets.xcassets */; };
 		95672B9625DDA54700DCBE4A /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 95672B9525DDA54700DCBE4A /* Preview Assets.xcassets */; };
@@ -22,16 +25,21 @@
 		95AD4A2D26078C1400498079 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95AD4A2C26078C1400498079 /* ContentView.swift */; };
 		95AD4A38260794A800498079 /* WhatsNewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95AD4A37260794A800498079 /* WhatsNewView.swift */; };
 		95E512D32607B42200C283E0 /* WelcomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95E512D22607B42200C283E0 /* WelcomeView.swift */; };
+		95F1E091260CBD0B0076AE63 /* UserSettings+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95F1E08F260CBD0B0076AE63 /* UserSettings+CoreDataClass.swift */; };
+		95F1E092260CBD0B0076AE63 /* UserSettings+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95F1E090260CBD0B0076AE63 /* UserSettings+CoreDataProperties.swift */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
 		950BA46B25E944F500D065EF /* Production.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Production.xcconfig; sourceTree = "<group>"; };
 		950BA46C25E944FC00D065EF /* Sandbox.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Sandbox.xcconfig; sourceTree = "<group>"; };
+		95201A2E260C9CAF007D5300 /* SignUpView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignUpView.swift; sourceTree = "<group>"; };
+		95201A3D260CB20A007D5300 /* ListAvatarHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListAvatarHelper.swift; sourceTree = "<group>"; };
 		954D7EA5260BBA6600A13C50 /* WatchlistCompany+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WatchlistCompany+CoreDataClass.swift"; sourceTree = "<group>"; };
 		954D7EA6260BBA6600A13C50 /* WatchlistCompany+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WatchlistCompany+CoreDataProperties.swift"; sourceTree = "<group>"; };
 		954D7EAB260BBB2400A13C50 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
 		954D7EB0260BBBEA00A13C50 /* UserHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserHelper.swift; sourceTree = "<group>"; };
 		954D7EC5260BE84100A13C50 /* WatchlistPreviewHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WatchlistPreviewHelper.swift; sourceTree = "<group>"; };
+		95531C78260CBECC00F0916A /* EnvironmentSignUp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnvironmentSignUp.swift; sourceTree = "<group>"; };
 		95672B8B25DDA54700DCBE4A /* LazyBear.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LazyBear.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		95672B8E25DDA54700DCBE4A /* LazyBearApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LazyBearApp.swift; sourceTree = "<group>"; };
 		95672B9225DDA54700DCBE4A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -44,6 +52,8 @@
 		95AD4A2C26078C1400498079 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
 		95AD4A37260794A800498079 /* WhatsNewView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhatsNewView.swift; sourceTree = "<group>"; };
 		95E512D22607B42200C283E0 /* WelcomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeView.swift; sourceTree = "<group>"; };
+		95F1E08F260CBD0B0076AE63 /* UserSettings+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserSettings+CoreDataClass.swift"; sourceTree = "<group>"; };
+		95F1E090260CBD0B0076AE63 /* UserSettings+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserSettings+CoreDataProperties.swift"; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -59,9 +69,27 @@
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
+		95201A36260CAD36007D5300 /* Tests */ = {
+			isa = PBXGroup;
+			children = (
+			);
+			path = Tests;
+			sourceTree = "<group>";
+		};
+		95201A40260CB50A007D5300 /* Helpers */ = {
+			isa = PBXGroup;
+			children = (
+				95201A3D260CB20A007D5300 /* ListAvatarHelper.swift */,
+				95531C78260CBECC00F0916A /* EnvironmentSignUp.swift */,
+			);
+			path = Helpers;
+			sourceTree = "<group>";
+		};
 		954D7E9D260BBA5200A13C50 /* Models */ = {
 			isa = PBXGroup;
 			children = (
+				95F1E08F260CBD0B0076AE63 /* UserSettings+CoreDataClass.swift */,
+				95F1E090260CBD0B0076AE63 /* UserSettings+CoreDataProperties.swift */,
 				954D7EA5260BBA6600A13C50 /* WatchlistCompany+CoreDataClass.swift */,
 				954D7EA6260BBA6600A13C50 /* WatchlistCompany+CoreDataProperties.swift */,
 			);
@@ -117,6 +145,7 @@
 				95672B9725DDA54700DCBE4A /* Persistence.swift */,
 				95B1874925DDAC4D0068A364 /* Views */,
 				954D7E9D260BBA5200A13C50 /* Models */,
+				95201A36260CAD36007D5300 /* Tests */,
 				95672B9425DDA54700DCBE4A /* Preview Content */,
 			);
 			path = LazyBear;
@@ -151,7 +180,9 @@
 			isa = PBXGroup;
 			children = (
 				95E512D22607B42200C283E0 /* WelcomeView.swift */,
+				95201A2E260C9CAF007D5300 /* SignUpView.swift */,
 				95AD4A37260794A800498079 /* WhatsNewView.swift */,
+				95201A40260CB50A007D5300 /* Helpers */,
 			);
 			path = Onboarding;
 			sourceTree = "<group>";
@@ -232,8 +263,11 @@
 			buildActionMask = 2147483647;
 			files = (
 				954D7EAC260BBB2400A13C50 /* HomeView.swift in Sources */,
+				95201A2F260C9CAF007D5300 /* SignUpView.swift in Sources */,
 				95672B9825DDA54700DCBE4A /* Persistence.swift in Sources */,
 				954D7EA8260BBA6600A13C50 /* WatchlistCompany+CoreDataProperties.swift in Sources */,
+				95F1E091260CBD0B0076AE63 /* UserSettings+CoreDataClass.swift in Sources */,
+				95F1E092260CBD0B0076AE63 /* UserSettings+CoreDataProperties.swift in Sources */,
 				95E512D32607B42200C283E0 /* WelcomeView.swift in Sources */,
 				954D7EB1260BBBEA00A13C50 /* UserHelper.swift in Sources */,
 				954D7EC6260BE84100A13C50 /* WatchlistPreviewHelper.swift in Sources */,
@@ -241,6 +275,8 @@
 				95672B8F25DDA54700DCBE4A /* LazyBearApp.swift in Sources */,
 				954D7EA7260BBA6600A13C50 /* WatchlistCompany+CoreDataClass.swift in Sources */,
 				95672B9B25DDA54800DCBE4A /* LazyBear.xcdatamodeld in Sources */,
+				95531C79260CBECC00F0916A /* EnvironmentSignUp.swift in Sources */,
+				95201A3E260CB20A007D5300 /* ListAvatarHelper.swift in Sources */,
 				95AD4A2D26078C1400498079 /* ContentView.swift in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
Binary file LazyBear/Assets.xcassets/Avatars/Random selection/random1.imageset/randomBoy1.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LazyBear/Assets.xcassets/Avatars/Random selection/random2.imageset/Contents.json	Thu Mar 25 17:08:13 2021 +0100
@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "filename" : "randomBoy2.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}
Binary file LazyBear/Assets.xcassets/Avatars/Random selection/random2.imageset/randomBoy2.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LazyBear/Assets.xcassets/Avatars/Random selection/random3.imageset/Contents.json	Thu Mar 25 17:08:13 2021 +0100
@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "filename" : "randomBoy3.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}
Binary file LazyBear/Assets.xcassets/Avatars/Random selection/random3.imageset/randomBoy3.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LazyBear/Assets.xcassets/Avatars/Random selection/random4.imageset/Contents.json	Thu Mar 25 17:08:13 2021 +0100
@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "filename" : "random4.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}
Binary file LazyBear/Assets.xcassets/Avatars/Random selection/random4.imageset/random4.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LazyBear/Assets.xcassets/Avatars/Random selection/random5.imageset/Contents.json	Thu Mar 25 17:08:13 2021 +0100
@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "filename" : "randomGirl1.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}
Binary file LazyBear/Assets.xcassets/Avatars/Random selection/random5.imageset/randomGirl1.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LazyBear/Assets.xcassets/Avatars/Random selection/random6.imageset/Contents.json	Thu Mar 25 17:08:13 2021 +0100
@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "filename" : "randomGirl2.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}
Binary file LazyBear/Assets.xcassets/Avatars/Random selection/random6.imageset/randomGirl2.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LazyBear/Assets.xcassets/Avatars/Random selection/random7.imageset/Contents.json	Thu Mar 25 17:08:13 2021 +0100
@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "filename" : "randomGirl3.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}
Binary file LazyBear/Assets.xcassets/Avatars/Random selection/random7.imageset/randomGirl3.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LazyBear/Assets.xcassets/Avatars/Random selection/random8.imageset/Contents.json	Thu Mar 25 17:08:13 2021 +0100
@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "filename" : "randomGirl4.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}
Binary file LazyBear/Assets.xcassets/Avatars/Random selection/random8.imageset/randomGirl4.png has changed
Binary file LazyBear/Assets.xcassets/Memojis/testMemoji.imageset/testMemoji.png has changed
--- a/LazyBear/LazyBear.xcdatamodeld/LazyBear.xcdatamodel/contents	Thu Mar 25 17:07:59 2021 +0100
+++ b/LazyBear/LazyBear.xcdatamodeld/LazyBear.xcdatamodel/contents	Thu Mar 25 17:08:13 2021 +0100
@@ -3,6 +3,10 @@
     <entity name="Entity" representedClassName="Entity" syncable="YES" codeGenerationType="class">
         <attribute name="attribute" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
     </entity>
+    <entity name="UserSettings" representedClassName="UserSettings" syncable="YES">
+        <attribute name="avatar" optional="YES" attributeType="String"/>
+        <attribute name="username" optional="YES" attributeType="String"/>
+    </entity>
     <entity name="WatchlistCompany" representedClassName="WatchlistCompany" syncable="YES">
         <attribute name="name" optional="YES" attributeType="String"/>
         <attribute name="symbol" optional="YES" attributeType="String"/>
@@ -10,6 +14,7 @@
     </entity>
     <elements>
         <element name="Entity" positionX="-63" positionY="-18" width="128" height="44"/>
+        <element name="UserSettings" positionX="-63" positionY="9" width="128" height="59"/>
         <element name="WatchlistCompany" positionX="-63" positionY="-9" width="128" height="74"/>
     </elements>
 </model>
\ No newline at end of file
--- a/LazyBear/Views/Onboarding/Helpers/EnvironmentSignUp.swift	Thu Mar 25 17:07:59 2021 +0100
+++ b/LazyBear/Views/Onboarding/Helpers/EnvironmentSignUp.swift	Thu Mar 25 17:08:13 2021 +0100
@@ -7,14 +7,8 @@
 
 import SwiftUI
 
-struct EnvironmentSignUp: View {
-    var body: some View {
-        Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
-    }
+class EnvironmentSignUp: ObservableObject {
+    @Published var username = ""
+    @Published var avatar = "random4"
+    @Published var hideAvatarSelector = false
 }
-
-struct EnvironmentSignUp_Previews: PreviewProvider {
-    static var previews: some View {
-        EnvironmentSignUp()
-    }
-}
--- a/LazyBear/Views/Onboarding/Helpers/ListAvatarHelper.swift	Thu Mar 25 17:07:59 2021 +0100
+++ b/LazyBear/Views/Onboarding/Helpers/ListAvatarHelper.swift	Thu Mar 25 17:08:13 2021 +0100
@@ -8,18 +8,34 @@
 import SwiftUI
 
 struct ListAvatarHelper: View {
+    @EnvironmentObject var environmentSignUp: EnvironmentSignUp
+    @Environment(\.presentationMode) var listAvatarPresentation
     let columns = [
             GridItem(.flexible()),
             GridItem(.flexible())
         ]
     
     var body: some View {
-        ScrollView {
-            LazyVGrid(columns: columns, spacing: 20) {
-                ForEach((1..<8), id: \.self) { index in
-                    Image("randomGirl\(index)")
+        NavigationView {
+            ScrollView(showsIndicators: false) {
+                LazyVGrid(columns: columns, spacing: 10) {
+                    ForEach((1..<9), id: \.self) { index in
+                        let avatar = "random\(index)"
+                        Button(action: {
+                            environmentSignUp.avatar = avatar
+                            listAvatarPresentation.wrappedValue.dismiss()
+                        }) {
+                            Image(avatar)
+                                .imageAvatarModifier()
+                        }
+                    }
                 }
+                Text("You can customise it later in Settings")
+                    .opacity(0.6)
+                    .font(.footnote)
             }
+            .navigationTitle("Select Your Avatar")
+            .navigationBarTitleDisplayMode(.inline)
         }
     }
 }
@@ -29,3 +45,14 @@
         ListAvatarHelper()
     }
 }
+
+extension Image {
+    func imageAvatarModifier() -> some View {
+        self
+            .resizable()
+            .scaledToFit()
+            .clipShape(Circle())
+            .padding()
+            .shadow(color: Color.gray.opacity(0.3), radius: 10, x: 0.0, y: 0.0)
+    }
+}
--- a/LazyBear/Views/Onboarding/SignUpView.swift	Thu Mar 25 17:07:59 2021 +0100
+++ b/LazyBear/Views/Onboarding/SignUpView.swift	Thu Mar 25 17:08:13 2021 +0100
@@ -1,5 +1,5 @@
 //
-//  SignUp.swift
+//  SignUpView.swift
 //  LazyBear
 //
 //  Created by Dennis Concepción Martín on 25/3/21.
@@ -7,65 +7,99 @@
 
 import SwiftUI
 
-struct SignUp: View {
-    @State var username: String = ""
-    @State var textFieldIsEditing = false
+struct SignUpView: View {
+    @Environment(\.managedObjectContext) private var moc
+    @EnvironmentObject var environmentSignUp: EnvironmentSignUp
+    @State private var showingAvatars = false
+    @State private var usernameIsEmptyAlert = false
+    @State private var showContentView = false
     
     var body: some View {
-        GeometryReader { geo in
-            VStack(alignment: .leading) {
-                Text("Sign Up")
-                    .font((.system(size: 50, weight: .black)))
-                    .padding(.vertical)
-                
-                Text("Let us customise your experience")
-                    .opacity(0.5)
-                    .padding(.bottom)
-            
-                ProfileAvatar(size: geo.size.height * 0.3, textFieldIsEditing: $textFieldIsEditing)
-                    .padding(.bottom)
-                    
-                UserNameTextfield(username: $username, isEditing: $textFieldIsEditing)
-                Spacer()
-                NextButton(text: "Continue")
-                    .padding(.bottom, 50)
-                
-                
+        if showContentView {
+            ContentView()
+        } else {
+            GeometryReader { geo in
+                NavigationView {
+                    VStack(alignment: .leading) {
+                        ProfileAvatar(size: geo.size.height * 0.3, showingAvatars: $showingAvatars)
+                            .padding(.bottom)
+                            
+                        UserNameTextfield(username: $environmentSignUp.username)
+                            .padding(.bottom)
+                        
+                        Button(action: {checkAndSave()}) {
+                            NextButton(text: "Continue")
+                                .padding(.bottom, 50)
+                        }
+                    }
+                    .padding()
+                    .navigationTitle("Sign Up")
+                    .navigationBarTitleDisplayMode(.inline)
+                }
             }
-            .padding(.horizontal)
+            .alert(isPresented: $usernameIsEmptyAlert) {
+                Alert(title: Text("Select a username"), message: Text("Need ideas? Try Stockmaster, or Financial lover"), dismissButton: .default(Text("Got it!")))
+            }
+            .sheet(isPresented: $showingAvatars) {
+                ListAvatarHelper()
+            }
+        }
+    }
+    
+    private func checkAndSave() {
+        if environmentSignUp.username.isEmpty {
+            self.usernameIsEmptyAlert = true
+        } else {
+            // Save settings to CLOUDKIT and show ContentView
+            let userSettings = UserSettings(context: moc)
+            userSettings.avatar = environmentSignUp.avatar
+            userSettings.username = environmentSignUp.username
+            do {
+                try moc.save()
+                print("User saved")
+                self.showContentView = true
+            } catch {
+                print(error.localizedDescription)
+            }
         }
     }
 }
 
-struct SignUp_Previews: PreviewProvider {
+struct SignUpView_Previews: PreviewProvider {
     static var previews: some View {
-        SignUp()
+        SignUpView()
+            .environmentObject(EnvironmentSignUp())
     }
 }
 
 struct ProfileAvatar: View {
+    @EnvironmentObject var environmentSignUp: EnvironmentSignUp
     @State var size: CGFloat
-    @Binding var textFieldIsEditing: Bool
+    @Binding var showingAvatars: Bool
     
     var body: some View {
         HStack {
             Spacer()
             ZStack(alignment: .topTrailing) {
-                Image("boyAvatar")
+                Image(environmentSignUp.avatar)
                     .resizable()
                     .frame(maxWidth: size, maxHeight: size)
                     .scaledToFit()
                     .clipShape(Circle())
+                    .shadow(color: Color.gray.opacity(0.3), radius: 10, x: 0.0, y: 0.0)
                 
-                if !textFieldIsEditing {
-                    Image(systemName: "photo")
-                        .foregroundColor(.white)
-                        .padding()
-                        .background(
-                            Circle()
-                                .foregroundColor(Color("default"))
-                        )
-                        .padding()
+                if !environmentSignUp.hideAvatarSelector {
+                    Button(action: { self.showingAvatars = true }) {
+                        Image(systemName: "photo")
+                            .foregroundColor(.white)
+                            .padding()
+                            .background(
+                                Circle()
+                                    .foregroundColor(Color("default"))
+                                    .shadow(color: Color.gray.opacity(0.3), radius: 10, x: 0.0, y: 0.0)
+                            )
+                            .padding()
+                    }
                 }
             }
             
@@ -75,20 +109,21 @@
 }
 
 struct UserNameTextfield: View {
+    @EnvironmentObject var environmentSignUp: EnvironmentSignUp
     @Binding var username: String
-    @Binding var isEditing: Bool
     
     var body: some View {
         VStack {
-        Text("Your username")
-            .font(.headline)
-        
             TextField("Username", text: $username) { isEditing in
-                self.isEditing = isEditing
-            } onCommit: {
-                print(username)
+                if isEditing {  // If it's true
+                    environmentSignUp.hideAvatarSelector = isEditing
+                } else {
+                    DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
+                        environmentSignUp.hideAvatarSelector = isEditing
+                    }
+                }
             }
-            .padding(8)
+            .padding(10)
             .background(
                 RoundedRectangle(cornerRadius: 10)
                     .foregroundColor(Color(.systemGray6))
--- a/UserSettings+CoreDataClass.swift	Thu Mar 25 17:07:59 2021 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-//
-//  UserSettings+CoreDataClass.swift
-//  LazyBear
-//
-//  Created by Dennis Concepción Martín on 25/3/21.
-//
-//
-
-import Foundation
-import CoreData
-
-@objc(UserSettings)
-public class UserSettings: NSManagedObject {
-
-}
--- a/UserSettings+CoreDataProperties.swift	Thu Mar 25 17:07:59 2021 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-//
-//  UserSettings+CoreDataProperties.swift
-//  LazyBear
-//
-//  Created by Dennis Concepción Martín on 25/3/21.
-//
-//
-
-import Foundation
-import CoreData
-
-
-extension UserSettings {
-
-    @nonobjc public class func fetchRequest() -> NSFetchRequest<UserSettings> {
-        return NSFetchRequest<UserSettings>(entityName: "UserSettings")
-    }
-
-    @NSManaged public var username: String?
-    @NSManaged public var avatar: String?
-
-}
-
-extension UserSettings : Identifiable {
-
-}