From ff599b5a6828936caabbb37d0c54f2196e0c84ce Mon Sep 17 00:00:00 2001 From: Gonzalo Perisset Date: Tue, 24 Oct 2023 18:20:49 -0300 Subject: [PATCH] BAL-183-GP-BPM-CONFIGURATION --- Balance/Balance.swift | 3 + Balance/Chill/ChillCellView.swift | 3 +- Balance/Distraction/DistractionCellView.swift | 3 +- Balance/Distraction/Drawing/DrawView.swift | 15 ++- .../Drawing/Sketch/Classes/Main.storyboard | 8 +- .../Sketch/Classes/SketchViewController.swift | 10 +- Balance/Distraction/Games/GamesCellView.swift | 3 +- Balance/Home/CellView.swift | 3 +- Balance/Home/Home.swift | 2 +- Balance/Home/NavigationView.swift | 3 +- Balance/Profile/ProfileCellView.swift | 2 +- Balance/Profile/ProfileView.swift | 94 ++++++++++++++++++- Balance/Utils/BalanceExtensions.swift | 6 ++ Balance/Utils/Constant.swift | 3 + 14 files changed, 139 insertions(+), 19 deletions(-) diff --git a/Balance/Balance.swift b/Balance/Balance.swift index 658307b..1578774 100644 --- a/Balance/Balance.swift +++ b/Balance/Balance.swift @@ -56,6 +56,9 @@ struct Balance: App { if !userModel.existLocalUser(uid: demoID) { userModel.createDemoUser() } + if (UserDefaults.standard.value(forKey: bpmKEY) == nil) { + UserDefaults.standard.setValue(defaultBPM, forKey: bpmKEY) + } }) .onChange(of: scenePhase) { phase in switch phase { diff --git a/Balance/Chill/ChillCellView.swift b/Balance/Chill/ChillCellView.swift index ba14b46..fd92ff0 100644 --- a/Balance/Chill/ChillCellView.swift +++ b/Balance/Chill/ChillCellView.swift @@ -36,7 +36,8 @@ struct ChillCellView: View { } } .padding(EdgeInsets(top: 24, leading: 24, bottom: 24, trailing: 0)) - .frame(maxWidth: 311, maxHeight: 114) + .frame(maxWidth: UIScreen.screenWidth - 20) + .frame(height: 120) .foregroundColor(darkBlueColor) .background(RoundedRectangle(cornerRadius: 20).fill(.white)) .clipped() diff --git a/Balance/Distraction/DistractionCellView.swift b/Balance/Distraction/DistractionCellView.swift index 518f109..4494297 100644 --- a/Balance/Distraction/DistractionCellView.swift +++ b/Balance/Distraction/DistractionCellView.swift @@ -25,7 +25,8 @@ struct DistractionCellView: View { Spacer() } } - .frame(maxWidth: 311, maxHeight: 120) + .frame(maxWidth: UIScreen.screenWidth - 20) + .frame(height: 120) .foregroundColor(darkBlueColor) .background(RoundedRectangle(cornerRadius: 20).fill(.white)) .clipped() diff --git a/Balance/Distraction/Drawing/DrawView.swift b/Balance/Distraction/Drawing/DrawView.swift index 74451a1..ef55006 100644 --- a/Balance/Distraction/Drawing/DrawView.swift +++ b/Balance/Distraction/Drawing/DrawView.swift @@ -29,6 +29,7 @@ struct DrawingView: UIViewRepresentable { canvas.maximumZoomScale = 10 canvas.contentSize = CGSize(width: 1000, height: 1000) canvas.contentInset = UIEdgeInsets(top: 500, left: 500, bottom: 500, right: 500) + canvas.isScrollEnabled = false return canvas } @@ -64,7 +65,7 @@ struct DrawView: View { @State var eraserWidth: Double = 99.0 @State var lineWidth: CGFloat = 1.0 @State var showLineWith = false - + var body: some View { ZStack { Color.white.edgesIgnoringSafeArea(.all) @@ -125,7 +126,9 @@ struct DrawView: View { if self.title.isEmpty { self.emptyDrawAlert = true } else { - saveImage() + Task { + await saveImage() + } } } label: { Text("Save") @@ -143,7 +146,11 @@ struct DrawView: View { .buttonStyle(ActivityLogButtonStyle(activityDescription: isColoring == true ? "Coloring Draw SAVED" : "Draw SAVED")) .alert("Enter the title of the drawing", isPresented: $emptyDrawAlert) { TextField("Title", text: $title) - Button("OK", action: saveImage) + Button("OK") { + Task { + await saveImage() + } + } } } @@ -377,7 +384,7 @@ struct DrawView: View { } } - func saveImage() { + func saveImage() async { let newDraw = Draw( id: currentDraw.id, title: title, diff --git a/Balance/Distraction/Drawing/Sketch/Classes/Main.storyboard b/Balance/Distraction/Drawing/Sketch/Classes/Main.storyboard index b6ca1c9..0572a9c 100644 --- a/Balance/Distraction/Drawing/Sketch/Classes/Main.storyboard +++ b/Balance/Distraction/Drawing/Sketch/Classes/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -45,7 +45,7 @@ -