Skip to content

Commit 1316d71

Browse files
committed
Доработка для неавторизованного пользователя
- Для неавторизованного пользователя справа сверху на экранах с площадками и мероприятиями есть кнопка для перехода в настройки - В настройках для неавторизованного пользователя есть кнопки "регистрация" и "авторизация"
1 parent 513dc3c commit 1316d71

File tree

9 files changed

+105
-48
lines changed

9 files changed

+105
-48
lines changed

SwiftUI-WorkoutApp.xcodeproj/project.pbxproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
670CA1A0280E8F9B003914A3 /* ButtonInFormLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 670CA19F280E8F9B003914A3 /* ButtonInFormLabel.swift */; };
1717
670F16C82826D1090069D80A /* UsersListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 670F16C72826D1090069D80A /* UsersListViewModel.swift */; };
1818
67138D792971CA7A00BBF450 /* MessagingViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67138D782971CA7A00BBF450 /* MessagingViewModel.swift */; };
19+
67138D7D2972E86C00BBF450 /* IncognitoNavbarInfoButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67138D7C2972E86C00BBF450 /* IncognitoNavbarInfoButton.swift */; };
1920
671D7DEC28210D2F0068E728 /* EmptyContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 671D7DEB28210D2F0068E728 /* EmptyContentView.swift */; };
2021
671D7DEF282112140068E728 /* Text+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 671D7DEE282112140068E728 /* Text+.swift */; };
2122
671D7DF1282117FF0068E728 /* UserViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 671D7DF0282117FF0068E728 /* UserViewCell.swift */; };
@@ -163,6 +164,7 @@
163164
670CA19F280E8F9B003914A3 /* ButtonInFormLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonInFormLabel.swift; sourceTree = "<group>"; };
164165
670F16C72826D1090069D80A /* UsersListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UsersListViewModel.swift; sourceTree = "<group>"; };
165166
67138D782971CA7A00BBF450 /* MessagingViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagingViewModel.swift; sourceTree = "<group>"; };
167+
67138D7C2972E86C00BBF450 /* IncognitoNavbarInfoButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IncognitoNavbarInfoButton.swift; sourceTree = "<group>"; };
166168
671D7DEB28210D2F0068E728 /* EmptyContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyContentView.swift; sourceTree = "<group>"; };
167169
671D7DEE282112140068E728 /* Text+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Text+.swift"; sourceTree = "<group>"; };
168170
671D7DF0282117FF0068E728 /* UserViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserViewCell.swift; sourceTree = "<group>"; };
@@ -683,7 +685,7 @@
683685
6798AA6A280B277600DB76F1 /* Common */ = {
684686
isa = PBXGroup;
685687
children = (
686-
679F3B0A2969DF3E00BB3590 /* IncognitoUserButton */,
688+
679F3B0A2969DF3E00BB3590 /* IncognitoButtons */,
687689
679F3AF92968104900BB3590 /* InForm */,
688690
679F3AF8296802BA00BB3590 /* SendMessage */,
689691
679F3AF72968029900BB3590 /* SportsGroundLocation */,
@@ -742,13 +744,14 @@
742744
path = InForm;
743745
sourceTree = "<group>";
744746
};
745-
679F3B0A2969DF3E00BB3590 /* IncognitoUserButton */ = {
747+
679F3B0A2969DF3E00BB3590 /* IncognitoButtons */ = {
746748
isa = PBXGroup;
747749
children = (
748750
6798AA6F280B42BC00DB76F1 /* IncognitoButtonLabelModifier.swift */,
749751
679F3B062969D4E200BB3590 /* IncognitoUserButton.swift */,
752+
67138D7C2972E86C00BBF450 /* IncognitoNavbarInfoButton.swift */,
750753
);
751-
path = IncognitoUserButton;
754+
path = IncognitoButtons;
752755
sourceTree = "<group>";
753756
};
754757
67A9C90628427DDD005D6A36 /* Filter */ = {
@@ -962,6 +965,7 @@
962965
6798AA59280AF4B100DB76F1 /* SportsGroundsMapView.swift in Sources */,
963966
6798AA68280B23B700DB76F1 /* UserDetailsView.swift in Sources */,
964967
67DD1120282C3CE400E3917C /* TextEntryViewModel.swift in Sources */,
968+
67138D7D2972E86C00BBF450 /* IncognitoNavbarInfoButton.swift in Sources */,
965969
6773111C296607AA003CD13A /* FriendAction.swift in Sources */,
966970
67B78712281D654C008B104F /* DefaultsService.swift in Sources */,
967971
67419ACF282E70B9004F5339 /* SportsGroundsListView.swift in Sources */,

SwiftUI-WorkoutApp/Constants.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ enum Constants {
66
static let minUserAge = Calendar.current.date(byAdding: .year, value: -13, to: .now) ?? .now
77
static let maxEventFutureDate = Calendar.current.date(byAdding: .year, value: 1, to: .now) ?? .now
88
static let halfMinuteAgo = Calendar.current.date(byAdding: .second, value: -30, to: .now) ?? .now
9+
static let incognitoInfoText = "Зарегистрируйтесь или авторизуйтесь, чтобы иметь доступ ко всем возможностям приложения"
910
static let appVersion = (Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String).valueOrEmpty
1011
static let appReviewURL = URL(string: "https://apps.apple.com/app/id1035159361?action=write-review")!
1112
static let workoutShopURL = URL(string: "https://workoutshop.ru")!
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import SwiftUI
2+
3+
/// Кнопка с навигацией на экран настроек `ProfileSettingsView`
4+
struct IncognitoNavbarInfoButton: View {
5+
var body: some View {
6+
NavigationLink(destination: ProfileSettingsView(mode: .incognito)) {
7+
Image(systemName: "info.circle.fill")
8+
}
9+
}
10+
}
11+
12+
#if DEBUG
13+
struct IncognitoNavbarInfoButton_Previews: PreviewProvider {
14+
static var previews: some View {
15+
IncognitoNavbarInfoButton()
16+
}
17+
}
18+
#endif

SwiftUI-WorkoutApp/Screens/Events/List/EventsListView.swift

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct EventsListView: View {
4646
refreshButton
4747
}
4848
ToolbarItem(placement: .navigationBarTrailing) {
49-
addEventButton
49+
rightBarButton
5050
}
5151
}
5252
.navigationTitle("Мероприятия")
@@ -102,22 +102,26 @@ private extension EventsListView {
102102
}
103103
}
104104

105-
var addEventButton: some View {
106-
Button {
107-
if !defaults.hasSportsGrounds {
108-
showEventCreationRule.toggle()
109-
} else {
110-
createEventIfAvailable()
105+
@ViewBuilder
106+
var rightBarButton: some View {
107+
if defaults.isAuthorized {
108+
Button {
109+
if !defaults.hasSportsGrounds {
110+
showEventCreationRule.toggle()
111+
} else {
112+
createEventIfAvailable()
113+
}
114+
} label: {
115+
Image(systemName: "plus")
111116
}
112-
} label: {
113-
Image(systemName: "plus")
114-
}
115-
.opacity(defaults.isAuthorized ? 1 : 0)
116-
.disabled(!network.isConnected)
117-
.sheet(isPresented: $showEventCreationSheet) {
118-
ContentInSheet(title: "Новое мероприятие", spacing: .zero) {
119-
EventFormView(for: .regularCreate, refreshClbk: refreshAction)
117+
.disabled(!network.isConnected)
118+
.sheet(isPresented: $showEventCreationSheet) {
119+
ContentInSheet(title: "Новое мероприятие", spacing: .zero) {
120+
EventFormView(for: .regularCreate, refreshClbk: refreshAction)
121+
}
120122
}
123+
} else {
124+
IncognitoNavbarInfoButton()
121125
}
122126
}
123127

SwiftUI-WorkoutApp/Screens/Profile/IncognitoProfileView.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct IncognitoProfileView: View {
1010
}
1111
.toolbar {
1212
ToolbarItem(placement: .navigationBarTrailing) {
13-
infoButton
13+
IncognitoNavbarInfoButton()
1414
}
1515
}
1616
.padding()
@@ -19,7 +19,7 @@ struct IncognitoProfileView: View {
1919

2020
private extension IncognitoProfileView {
2121
var incognitoInformer: some View {
22-
Text("Зарегистрируйтесь или авторизуйтесь, чтобы иметь доступ к функционалу")
22+
Text(Constants.incognitoInfoText)
2323
.font(.title3)
2424
.multilineTextAlignment(.center)
2525
.padding()
@@ -32,12 +32,6 @@ private extension IncognitoProfileView {
3232
var loginButton: some View {
3333
IncognitoUserButton(mode: .authorize(source: .incognitoView))
3434
}
35-
36-
var infoButton: some View {
37-
NavigationLink(destination: ProfileSettingsView(mode: .incognito)) {
38-
Image(systemName: "info.circle.fill")
39-
}
40-
}
4135
}
4236

4337
#if DEBUG

SwiftUI-WorkoutApp/Screens/Profile/Settings/ProfileSettingsView.swift

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,19 @@ struct ProfileSettingsView: View {
1313

1414
var body: some View {
1515
Form {
16-
if mode == .authorized {
17-
Section("Профиль") {
16+
Section {
17+
if mode == .authorized {
1818
editAccountButton
1919
changePasswordButton
2020
logoutButton
21+
} else {
22+
registerButton
23+
authorizeButton
2124
}
25+
} header: {
26+
Text("Профиль")
27+
} footer: {
28+
mode.profileSectionFooter
2229
}
2330
Section(mode.appInfoSectionTitle) {
2431
feedbackButton
@@ -59,8 +66,18 @@ private extension ProfileSettingsView.Mode {
5966
self == .authorized ? "Настройки" : "Информация"
6067
}
6168

69+
@ViewBuilder
70+
var profileSectionFooter: some View {
71+
switch self {
72+
case .authorized:
73+
EmptyView()
74+
case .incognito:
75+
Text(Constants.incognitoInfoText)
76+
}
77+
}
78+
6279
var appInfoSectionTitle: String {
63-
self == .authorized ? "Информация о приложении" : ""
80+
self == .authorized ? "Информация о приложении" : "О приложении"
6481
}
6582

6683
var supportProjectSectionTitle: String { "Поддержать проект" }
@@ -118,6 +135,20 @@ private extension ProfileSettingsView {
118135
deleteProfileTask = Task { await viewModel.deleteProfile(with: defaults) }
119136
}
120137

138+
var registerButton: some View {
139+
NavigationLink(destination: AccountInfoView(mode: .create)) {
140+
Label("Регистрация", systemImage: "person.badge.plus.fill")
141+
.font(.system(.body).bold())
142+
}
143+
}
144+
145+
var authorizeButton: some View {
146+
NavigationLink(destination: LoginView()) {
147+
Label("Авторизация", systemImage: "arrow.forward.circle.fill")
148+
.font(.system(.body).bold())
149+
}
150+
}
151+
121152
var feedbackButton: some View {
122153
Button { viewModel.feedbackAction() } label: {
123154
Label("Отправить обратную связь", systemImage: "envelope.fill")

SwiftUI-WorkoutApp/Screens/SportsGrounds/Map/SportsGroundsMapView.swift

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct SportsGroundsMapView: View {
5858
.disabled(isLeftToolbarPartDisabled)
5959
}
6060
ToolbarItem(placement: .navigationBarTrailing) {
61-
if defaults.isAuthorized { createGroundButton }
61+
rightBarButton
6262
}
6363
}
6464
.navigationTitle("Площадки")
@@ -136,25 +136,30 @@ private extension SportsGroundsMapView {
136136
Task { await askForGrounds(refresh: true) }
137137
}
138138

139-
var createGroundButton: some View {
140-
Button {
141-
showGroundCreationSheet.toggle()
142-
} label: {
143-
Image(systemName: "plus")
144-
}
145-
.opacity(viewModel.isLoading ? 0 : 1)
146-
.disabled(!network.isConnected || !viewModel.locationErrorMessage.isEmpty)
147-
.sheet(isPresented: $showGroundCreationSheet) {
148-
ContentInSheet(title: "Новая площадка", spacing: .zero) {
149-
SportsGroundFormView(
150-
.createNew(
151-
address: $viewModel.addressString,
152-
coordinate: $viewModel.region.center,
153-
cityID: defaults.mainUserCityID
154-
),
155-
refreshClbk: updateRecent
156-
)
139+
@ViewBuilder
140+
var rightBarButton: some View {
141+
if defaults.isAuthorized {
142+
Button {
143+
showGroundCreationSheet.toggle()
144+
} label: {
145+
Image(systemName: "plus")
157146
}
147+
.opacity(viewModel.isLoading ? 0 : 1)
148+
.disabled(!network.isConnected || !viewModel.locationErrorMessage.isEmpty)
149+
.sheet(isPresented: $showGroundCreationSheet) {
150+
ContentInSheet(title: "Новая площадка", spacing: .zero) {
151+
SportsGroundFormView(
152+
.createNew(
153+
address: $viewModel.addressString,
154+
coordinate: $viewModel.region.center,
155+
cityID: defaults.mainUserCityID
156+
),
157+
refreshClbk: updateRecent
158+
)
159+
}
160+
}
161+
} else {
162+
IncognitoNavbarInfoButton()
158163
}
159164
}
160165

0 commit comments

Comments
 (0)