From 7275899dd0cde03ed2e4751d9d9476560307f2f3 Mon Sep 17 00:00:00 2001 From: talksik Date: Sun, 2 Jan 2022 18:46:04 -0800 Subject: [PATCH] adding in rulebook global variable for the rules of the game --- nirvana-ios.xcodeproj/project.pbxproj | 12 ++++++++++++ nirvana-ios/Views/Contacts/FindFriendsView.swift | 13 +++++++++---- nirvana-ios/Views/InnerCircle/CircleGridView.swift | 2 +- nirvana-ios/Views/RuleBook/RuleBook.swift | 12 ++++++++++++ 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 nirvana-ios/Views/RuleBook/RuleBook.swift diff --git a/nirvana-ios.xcodeproj/project.pbxproj b/nirvana-ios.xcodeproj/project.pbxproj index 35d1e49..4bd2675 100644 --- a/nirvana-ios.xcodeproj/project.pbxproj +++ b/nirvana-ios.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ 8909199C277EFDF30025F4BB /* joinSound.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 8909199B277EFDF30025F4BB /* joinSound.mp3 */; }; 8909199E278155920025F4BB /* UserStatusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8909199D278155920025F4BB /* UserStatusView.swift */; }; 890919A42781845D0025F4BB /* AlertToast in Frameworks */ = {isa = PBXBuildFile; productRef = 890919A32781845D0025F4BB /* AlertToast */; }; + 890919A7278299590025F4BB /* RuleBook.swift in Sources */ = {isa = PBXBuildFile; fileRef = 890919A6278299590025F4BB /* RuleBook.swift */; }; 890C245D277BF628009B4A30 /* AgoraRtcKit in Frameworks */ = {isa = PBXBuildFile; productRef = 890C245C277BF628009B4A30 /* AgoraRtcKit */; }; 890C2460277BF896009B4A30 /* AgoraViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 890C245F277BF896009B4A30 /* AgoraViewController.swift */; }; 890C2462277BF935009B4A30 /* CallView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 890C2461277BF935009B4A30 /* CallView.swift */; }; @@ -105,6 +106,7 @@ 89091998277EFDCC0025F4BB /* leaveSound.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = leaveSound.mp3; sourceTree = ""; }; 8909199B277EFDF30025F4BB /* joinSound.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = joinSound.mp3; sourceTree = ""; }; 8909199D278155920025F4BB /* UserStatusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserStatusView.swift; sourceTree = ""; }; + 890919A6278299590025F4BB /* RuleBook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleBook.swift; sourceTree = ""; }; 890C245F277BF896009B4A30 /* AgoraViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgoraViewController.swift; sourceTree = ""; }; 890C2461277BF935009B4A30 /* CallView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallView.swift; sourceTree = ""; }; 890C2463277BFA97009B4A30 /* AgroRep.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgroRep.swift; sourceTree = ""; }; @@ -211,6 +213,14 @@ path = sounds; sourceTree = ""; }; + 890919A5278299490025F4BB /* RuleBook */ = { + isa = PBXGroup; + children = ( + 890919A6278299590025F4BB /* RuleBook.swift */, + ); + path = RuleBook; + sourceTree = ""; + }; 890C245E277BF888009B4A30 /* VoiceCallTest */ = { isa = PBXGroup; children = ( @@ -285,6 +295,7 @@ 891A15F62765639B00B26659 /* Views */ = { isa = PBXGroup; children = ( + 890919A5278299490025F4BB /* RuleBook */, 89814681277D83CF00DA46CD /* Convos */, 896CE7032770AE3400DB474E /* Inbox */, 894E80BF276EFCF500624B72 /* AudioPlayer */, @@ -632,6 +643,7 @@ 891A160327656FC700B26659 /* HomeView.swift in Sources */, 896CE70927712CED00DB474E /* StringExtension.swift in Sources */, 89110714277166D6005797FA /* UserFriends.swift in Sources */, + 890919A7278299590025F4BB /* RuleBook.swift in Sources */, 896CE70727711BAB00DB474E /* FindFriendsView.swift in Sources */, 891A160B2765732700B26659 /* HomeViewModel.swift in Sources */, 89814685277D857300DA46CD /* Convo.swift in Sources */, diff --git a/nirvana-ios/Views/Contacts/FindFriendsView.swift b/nirvana-ios/Views/Contacts/FindFriendsView.swift index 2e4a3b8..1966c12 100644 --- a/nirvana-ios/Views/Contacts/FindFriendsView.swift +++ b/nirvana-ios/Views/Contacts/FindFriendsView.swift @@ -22,7 +22,7 @@ struct FindFriendsView: View { // main content NavigationView { VStack { - Text("You must have someone in your phone contacts to add them. Remember: \(self.authSessionStore.friendsArr.count)/10 spots filled in your circle. 🥬") + Text("You must have someone in your phone contacts to add them. Remember: \(self.authSessionStore.friendsArr.count)/\(RuleBook.maxFriends) spots filled in your circle. 🥬") .font(.subheadline) .foregroundColor(Color.gray) .padding(.horizontal) @@ -102,7 +102,7 @@ struct ListContactRow: View { @State var showAlert = false @State var alertText = "🌱Confirm Arjun into Your Circle?" - @State var alertMessage = "Note: You can have a maximium of 12 people in your circle!" + @State var alertMessage = "Note: You can have a maximium of \(RuleBook.maxFriends) people in your circle!" var body: some View { if contact.isExisting { // add to circle @@ -122,7 +122,11 @@ struct ListContactRow: View { Button { print("showing alert now") - // TODO: show alert if circle is full + if self.authSessionStore.friendsArr.count >= RuleBook.maxFriends { + self.contactsVM.toast = .maxFriendsInCircle + return + } + self.showAlert.toggle() } label: { @@ -138,7 +142,7 @@ struct ListContactRow: View { primaryButton: .default(Text("Cancel")), secondaryButton: .default(Text("Confirm")) { print("adding contact to circle") - if self.authSessionStore.friendsArr.count >= 10 { + if self.authSessionStore.friendsArr.count >= RuleBook.maxFriends { self.contactsVM.toast = .maxFriendsInCircle return } @@ -187,6 +191,7 @@ struct ListContactRow: View { UIApplication.shared.open(URL(string: strUrl)!, options: [:], completionHandler: nil) } else { print("phone number is nil of contact") + self.contactsVM.toast = .generalError } } label: { Label("Invite", systemImage: "paperplane") diff --git a/nirvana-ios/Views/InnerCircle/CircleGridView.swift b/nirvana-ios/Views/InnerCircle/CircleGridView.swift index 8d60f7b..a1f94cc 100644 --- a/nirvana-ios/Views/InnerCircle/CircleGridView.swift +++ b/nirvana-ios/Views/InnerCircle/CircleGridView.swift @@ -312,7 +312,7 @@ struct CircleGridView: View { secondaryButton: .default(Text("Add"), action: { // create user friend if have space in circle // TODO: view models should be able to do this validation, need some way of view models to speak to each other - if self.authSessionStore.friendsArr.count >= 10 { + if self.authSessionStore.friendsArr.count >= RuleBook.maxFriends { self.innerCircleVM.toast = .maxFriendsInCircle return } diff --git a/nirvana-ios/Views/RuleBook/RuleBook.swift b/nirvana-ios/Views/RuleBook/RuleBook.swift new file mode 100644 index 0000000..3609bed --- /dev/null +++ b/nirvana-ios/Views/RuleBook/RuleBook.swift @@ -0,0 +1,12 @@ +// +// Rules.swift +// nirvana-ios +// +// Created by Arjun Patel on 1/2/22. +// + +import Foundation + +class RuleBook { + static let maxFriends = 8 +}