From 38e41df16440b293e1640a2d4b175a1fd3a3b001 Mon Sep 17 00:00:00 2001 From: talksik Date: Sun, 12 Dec 2021 02:15:38 -0800 Subject: [PATCH] addition of microphone --- nirvana-ios.xcodeproj/project.pbxproj | 24 ++++++++++-- nirvana-ios/Globals/colors.swift | 2 +- .../FooterControlsView.swift | 38 +++++++++++++++++++ .../FooterControlsViewModel.swift | 14 +++++++ .../ChatsCarouselView/ChatsCarouselView.swift | 18 +++------ nirvana-ios/Views/HomeView/HomeView.swift | 7 ++-- .../{Footer.swift => FooterView.swift} | 0 nirvana-ios/Views/Templates/HeaderView.swift | 6 +-- .../Views/WelcomeView/WelcomeView.swift | 14 +++---- 9 files changed, 91 insertions(+), 32 deletions(-) create mode 100644 nirvana-ios/Views/FooterControlsView/FooterControlsView.swift create mode 100644 nirvana-ios/Views/FooterControlsView/FooterControlsViewModel.swift rename nirvana-ios/Views/Templates/{Footer.swift => FooterView.swift} (100%) diff --git a/nirvana-ios.xcodeproj/project.pbxproj b/nirvana-ios.xcodeproj/project.pbxproj index f7b8284..f53c6a6 100644 --- a/nirvana-ios.xcodeproj/project.pbxproj +++ b/nirvana-ios.xcodeproj/project.pbxproj @@ -16,13 +16,15 @@ 891A15F9276563CA00B26659 /* WelcomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891A15F8276563CA00B26659 /* WelcomeView.swift */; }; 891A15FD276566B800B26659 /* constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891A15FC276566B800B26659 /* constants.swift */; }; 891A15FF27656F9200B26659 /* HeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891A15FE27656F9200B26659 /* HeaderView.swift */; }; - 891A160127656FB200B26659 /* Footer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891A160027656FB200B26659 /* Footer.swift */; }; + 891A160127656FB200B26659 /* FooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891A160027656FB200B26659 /* FooterView.swift */; }; 891A160327656FC700B26659 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891A160227656FC700B26659 /* HomeView.swift */; }; 891A1607276572A800B26659 /* Onboarding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891A1606276572A800B26659 /* Onboarding.swift */; }; 891A160B2765732700B26659 /* HomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891A160A2765732700B26659 /* HomeViewModel.swift */; }; 891A160E27657CEA00B26659 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891A160D27657CEA00B26659 /* User.swift */; }; 891A1611276590B000B26659 /* ChatsCarouselView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891A1610276590B000B26659 /* ChatsCarouselView.swift */; }; 891A16132765A44300B26659 /* ChatsCarouselViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891A16122765A44300B26659 /* ChatsCarouselViewModel.swift */; }; + 892179E42765FEB8001E6C60 /* FooterControlsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 892179E32765FEB8001E6C60 /* FooterControlsView.swift */; }; + 892179E62765FECD001E6C60 /* FooterControlsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 892179E52765FECD001E6C60 /* FooterControlsViewModel.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -37,13 +39,15 @@ 891A15F8276563CA00B26659 /* WelcomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeView.swift; sourceTree = ""; }; 891A15FC276566B800B26659 /* constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = constants.swift; sourceTree = ""; }; 891A15FE27656F9200B26659 /* HeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderView.swift; sourceTree = ""; }; - 891A160027656FB200B26659 /* Footer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Footer.swift; sourceTree = ""; }; + 891A160027656FB200B26659 /* FooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterView.swift; sourceTree = ""; }; 891A160227656FC700B26659 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = ""; }; 891A1606276572A800B26659 /* Onboarding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Onboarding.swift; sourceTree = ""; }; 891A160A2765732700B26659 /* HomeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewModel.swift; sourceTree = ""; }; 891A160D27657CEA00B26659 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = ""; }; 891A1610276590B000B26659 /* ChatsCarouselView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatsCarouselView.swift; sourceTree = ""; }; 891A16122765A44300B26659 /* ChatsCarouselViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatsCarouselViewModel.swift; sourceTree = ""; }; + 892179E32765FEB8001E6C60 /* FooterControlsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterControlsView.swift; sourceTree = ""; }; + 892179E52765FECD001E6C60 /* FooterControlsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooterControlsViewModel.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -108,6 +112,7 @@ 891A15F62765639B00B26659 /* Views */ = { isa = PBXGroup; children = ( + 892179E22765FE93001E6C60 /* FooterControlsView */, 891A16052765726800B26659 /* Templates */, 891A16042765725D00B26659 /* WelcomeView */, 891A1608276572BB00B26659 /* HomeView */, @@ -126,7 +131,7 @@ 891A16052765726800B26659 /* Templates */ = { isa = PBXGroup; children = ( - 891A160027656FB200B26659 /* Footer.swift */, + 891A160027656FB200B26659 /* FooterView.swift */, 891A15FE27656F9200B26659 /* HeaderView.swift */, 891A1606276572A800B26659 /* Onboarding.swift */, ); @@ -169,6 +174,15 @@ path = ChatsCarouselView; sourceTree = ""; }; + 892179E22765FE93001E6C60 /* FooterControlsView */ = { + isa = PBXGroup; + children = ( + 892179E32765FEB8001E6C60 /* FooterControlsView.swift */, + 892179E52765FECD001E6C60 /* FooterControlsViewModel.swift */, + ); + path = FooterControlsView; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -244,13 +258,15 @@ 891A15E327653A7000B26659 /* ContentView.swift in Sources */, 891A160327656FC700B26659 /* HomeView.swift in Sources */, 891A160B2765732700B26659 /* HomeViewModel.swift in Sources */, + 892179E62765FECD001E6C60 /* FooterControlsViewModel.swift in Sources */, 891A15F5276557AB00B26659 /* colors.swift in Sources */, 891A15F9276563CA00B26659 /* WelcomeView.swift in Sources */, 891A1611276590B000B26659 /* ChatsCarouselView.swift in Sources */, 891A16132765A44300B26659 /* ChatsCarouselViewModel.swift in Sources */, 891A15E127653A7000B26659 /* nirvana_iosApp.swift in Sources */, - 891A160127656FB200B26659 /* Footer.swift in Sources */, + 891A160127656FB200B26659 /* FooterView.swift in Sources */, 891A15FF27656F9200B26659 /* HeaderView.swift in Sources */, + 892179E42765FEB8001E6C60 /* FooterControlsView.swift in Sources */, 891A15FD276566B800B26659 /* constants.swift in Sources */, 891A160E27657CEA00B26659 /* User.swift in Sources */, ); diff --git a/nirvana-ios/Globals/colors.swift b/nirvana-ios/Globals/colors.swift index 2a3cdc9..db70e37 100644 --- a/nirvana-ios/Globals/colors.swift +++ b/nirvana-ios/Globals/colors.swift @@ -36,7 +36,7 @@ extension UIColor { } } -final class NirvanaColors { +final class NirvanaColor { static let teal:Color = Color(red: 0.0, green: 0.314, blue: 0.314) static let bgLightGrey:Color = Color(red: 0.898, green: 0.898, blue: 0.898) static let white: Color = Color.white diff --git a/nirvana-ios/Views/FooterControlsView/FooterControlsView.swift b/nirvana-ios/Views/FooterControlsView/FooterControlsView.swift new file mode 100644 index 0000000..1b7b181 --- /dev/null +++ b/nirvana-ios/Views/FooterControlsView/FooterControlsView.swift @@ -0,0 +1,38 @@ +// +// FooterControlsView.swift +// nirvana-ios +// +// Created by Arjun Patel on 12/12/21. +// + +import SwiftUI + +struct FooterControlsView: View { + @StateObject var viewModel:FooterControlsViewModel = FooterControlsViewModel() + + var body: some View { + HStack(alignment: .center) { + Spacer() + + Button { + print("Button was pressed!") + } label: { + var icon:String = viewModel.isRecording ? "waveform" : "mic.fill" + + Image(systemName: icon) + .foregroundColor(.white) + .padding() + .background(NirvanaColor.teal) + .clipShape(Circle()) + } + } + .frame(maxWidth: .infinity) + .padding(.horizontal, 30) + } +} + +struct FooterControlsView_Previews: PreviewProvider { + static var previews: some View { + FooterControlsView() + } +} diff --git a/nirvana-ios/Views/FooterControlsView/FooterControlsViewModel.swift b/nirvana-ios/Views/FooterControlsView/FooterControlsViewModel.swift new file mode 100644 index 0000000..2468b0b --- /dev/null +++ b/nirvana-ios/Views/FooterControlsView/FooterControlsViewModel.swift @@ -0,0 +1,14 @@ +// +// FooterControlsViewModel.swift +// nirvana-ios +// +// Created by Arjun Patel on 12/12/21. +// + +import Foundation + + +final class FooterControlsViewModel: ObservableObject { + @Published var isRecording: Bool = false + +} diff --git a/nirvana-ios/Views/HomeView/ChatsCarouselView/ChatsCarouselView.swift b/nirvana-ios/Views/HomeView/ChatsCarouselView/ChatsCarouselView.swift index c19c636..55893b5 100644 --- a/nirvana-ios/Views/HomeView/ChatsCarouselView/ChatsCarouselView.swift +++ b/nirvana-ios/Views/HomeView/ChatsCarouselView/ChatsCarouselView.swift @@ -12,14 +12,7 @@ struct ChatsCarouselView: View { // current snapped/selected user @State var selectedUserId: String = "" @State var selectedUser: User? - - - private func getScale(proxy: GeometryProxy) -> CGFloat { - let scale:CGFloat = 2 - - return scale - } - + func getSelectedUser(userId: String) -> User { return self.viewModel.carouselUsers.filter{user in return user.id == userId @@ -33,7 +26,6 @@ struct ChatsCarouselView: View { ForEach(viewModel.carouselUsers) { carouselUser in GeometryReader {proxy in let minX = proxy.frame(in: .local).minX - let scale = getScale(proxy: proxy) Image(carouselUser.profilePictureUrl) .renderingMode(.original) @@ -45,12 +37,12 @@ struct ChatsCarouselView: View { .blur(radius: abs(minX) / 40) .scaleEffect() .padding(40) + .frame(maxWidth: UIScreen.main.bounds.width) } .tag(carouselUser.id) } } - .frame(maxWidth: UIScreen.main.bounds.width * 0.8) .tabViewStyle(.page(indexDisplayMode: .never)) .onAppear { self.selectedUserId = self.viewModel.carouselUsers.first?.id ?? "" @@ -75,7 +67,7 @@ struct ChatsCarouselView: View { .id(user.id) .overlay( RoundedRectangle(cornerRadius: 100) - .strokeBorder(NirvanaColors.teal, lineWidth: 2) + .strokeBorder(NirvanaColor.teal, lineWidth: 2) .opacity(isSelected ? 1 : 0) ) .onTapGesture { @@ -83,11 +75,11 @@ struct ChatsCarouselView: View { self.selectedUserId = user.id } } - .frame(maxHeight: 75) + .frame(maxHeight: 60) } } .frame(maxWidth: .infinity, maxHeight: .infinity) - .padding(.vertical, 40) + .padding(.top, 40) .padding(.horizontal, 40) } diff --git a/nirvana-ios/Views/HomeView/HomeView.swift b/nirvana-ios/Views/HomeView/HomeView.swift index 92323ad..cd34401 100644 --- a/nirvana-ios/Views/HomeView/HomeView.swift +++ b/nirvana-ios/Views/HomeView/HomeView.swift @@ -14,14 +14,13 @@ struct HomeView: View { ChatsCarouselView() - Text("This is the region for the bottom actions") - .padding(.vertical, 10) + FooterControlsView() Spacer() } .frame(maxWidth:.infinity, maxHeight: .infinity) - .accentColor(NirvanaColors.teal) - .background(NirvanaColors.bgLightGrey) + .accentColor(NirvanaColor.teal) + .background(NirvanaColor.bgLightGrey) } } diff --git a/nirvana-ios/Views/Templates/Footer.swift b/nirvana-ios/Views/Templates/FooterView.swift similarity index 100% rename from nirvana-ios/Views/Templates/Footer.swift rename to nirvana-ios/Views/Templates/FooterView.swift diff --git a/nirvana-ios/Views/Templates/HeaderView.swift b/nirvana-ios/Views/Templates/HeaderView.swift index fae48b1..a4e4de4 100644 --- a/nirvana-ios/Views/Templates/HeaderView.swift +++ b/nirvana-ios/Views/Templates/HeaderView.swift @@ -20,7 +20,7 @@ struct HeaderView: View { Image(systemName: "list.bullet.circle") .font(Font.system(.largeTitle)) .padding() - .foregroundColor(NirvanaColors.teal) + .foregroundColor(NirvanaColor.teal) } @@ -33,7 +33,7 @@ struct HeaderView: View { Text("nirvana") .font(Font.custom("Satisfy-Regular", size: 35)) - .foregroundColor(NirvanaColors.teal) + .foregroundColor(NirvanaColor.teal) .multilineTextAlignment(.center) } @@ -43,7 +43,7 @@ struct HeaderView: View { Image(systemName: "person.crop.circle.badge.plus") .font(Font.system(.largeTitle)) .padding() - .foregroundColor(NirvanaColors.teal) + .foregroundColor(NirvanaColor.teal) } } diff --git a/nirvana-ios/Views/WelcomeView/WelcomeView.swift b/nirvana-ios/Views/WelcomeView/WelcomeView.swift index 7e77fbf..446cafd 100644 --- a/nirvana-ios/Views/WelcomeView/WelcomeView.swift +++ b/nirvana-ios/Views/WelcomeView/WelcomeView.swift @@ -28,7 +28,7 @@ struct WelcomeView: View { .font(.title) + Text("minimalist ") .font(.title) - .foregroundColor(NirvanaColors.teal) + .foregroundColor(NirvanaColor.teal) + Text("social media.") .font(.title) @@ -50,12 +50,12 @@ struct WelcomeView: View { label: { Text("Start Your Detox") .bold() - .foregroundColor(NirvanaColors.white) + .foregroundColor(NirvanaColor.white) } ) .frame(maxWidth: .infinity) .padding(.vertical, 25) - .background(NirvanaColors.teal) + .background(NirvanaColor.teal) .clipShape(Capsule()) // .shadow(color: NirvanaColors.teal, radius: 3, x: 1, y: 2) // .cornerRadius(8) @@ -69,7 +69,7 @@ struct WelcomeView: View { .bold() } ) - .background(NirvanaColors.bgLightGrey) + .background(NirvanaColor.bgLightGrey) //learn more button to usenirvana.com } @@ -83,9 +83,9 @@ struct WelcomeView: View { } .frame(maxWidth: .infinity, maxHeight: .infinity) - .accentColor(NirvanaColors.teal) - .background(NirvanaColors.bgLightGrey) - // .background(RadialGradient(gradient: Gradient(colors: [NirvanaColors.teal.opacity(0.1), NirvanaColors.bgLightGrey, NirvanaColors.bgLightGrey]), center: .center, startRadius: 0, endRadius: 200) + .accentColor(NirvanaColor.teal) + .background(NirvanaColor.bgLightGrey) + // .background(RadialGradient(gradient: Gradient(colors: [NirvanaColor.teal.opacity(0.1), NirvanaColor.bgLightGrey, NirvanaColor.bgLightGrey]), center: .center, startRadius: 0, endRadius: 200) // ) }