Skip to content

Commit 370e8a8

Browse files
authored
Merge pull request #44 from OlegEremenko991/develop/accountCreationOnWeb
Регистрация на сайте вместо приложения
2 parents 9fe008f + 9d6cf5e commit 370e8a8

File tree

6 files changed

+56
-18
lines changed

6 files changed

+56
-18
lines changed

SwiftUI-WorkoutApp.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@
13161316
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
13171317
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
13181318
CODE_SIGN_STYLE = Automatic;
1319-
CURRENT_PROJECT_VERSION = 11;
1319+
CURRENT_PROJECT_VERSION = 12;
13201320
DEVELOPMENT_ASSET_PATHS = "SwiftUI-WorkoutApp/Preview\\ Content/PreviewContent.swift SwiftUI-WorkoutApp/Preview\\ Content";
13211321
DEVELOPMENT_TEAM = CR68PP2Z3F;
13221322
ENABLE_PREVIEWS = YES;
@@ -1352,7 +1352,7 @@
13521352
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
13531353
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
13541354
CODE_SIGN_STYLE = Automatic;
1355-
CURRENT_PROJECT_VERSION = 11;
1355+
CURRENT_PROJECT_VERSION = 12;
13561356
DEVELOPMENT_ASSET_PATHS = "SwiftUI-WorkoutApp/Preview\\ Content/PreviewContent.swift SwiftUI-WorkoutApp/Preview\\ Content";
13571357
DEVELOPMENT_TEAM = CR68PP2Z3F;
13581358
ENABLE_PREVIEWS = YES;

SwiftUI-WorkoutApp/Constants.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ enum Constants {
1111
static let appReviewURL = URL(string: "https://apps.apple.com/app/id1035159361?action=write-review")!
1212
static let workoutShopURL = URL(string: "https://workoutshop.ru")!
1313
static let officialSiteURL = URL(string: "https://workout.su")!
14+
static let accountCreationURL = URL(string: "https://m.workout.su/users/register")!
1415
static let feedbackRecipient = ["[email protected]"]
1516

1617
enum RulesOfService {

SwiftUI-WorkoutApp/Screens/Common/IncognitoButtons/IncognitoUserButton.swift

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,58 @@ struct IncognitoUserButton: View {
66
var body: some View {
77
NavigationLink(destination: mode.destination) {
88
mode.label
9-
.roundedStyle()
109
}
1110
}
1211
}
1312

1413
extension IncognitoUserButton {
15-
enum Mode { case register, authorize }
14+
enum Mode {
15+
/// Регистрация
16+
///
17+
/// `inForm = true` - отображаем кнопку внутри формы (`Form`), иначе - вне формы
18+
case register(inForm: Bool)
19+
/// Авторизация
20+
case authorize(inForm: Bool)
21+
22+
@ViewBuilder
23+
var label: some View {
24+
switch self {
25+
case let .register(inForm), let .authorize(inForm):
26+
if inForm {
27+
Label(title, systemImage: systemImageName)
28+
} else {
29+
Label(title, systemImage: systemImageName)
30+
.roundedStyle()
31+
}
32+
}
33+
}
34+
}
1635
}
1736

1837
private extension IncognitoUserButton.Mode {
19-
@ViewBuilder
20-
var destination: some View {
38+
var title: String {
2139
switch self {
22-
case .register: AccountInfoView(mode: .create)
23-
case .authorize: LoginView()
40+
case .register:
41+
return "Регистрация"
42+
case .authorize:
43+
return "Авторизация"
2444
}
2545
}
2646

27-
@ViewBuilder
28-
var label: some View {
47+
var systemImageName: String {
2948
switch self {
3049
case .register:
31-
Label("Регистрация", systemImage: "person.badge.plus")
50+
return "person.badge.plus"
3251
case .authorize:
33-
Label("Авторизация", systemImage: "arrow.forward.circle")
52+
return "arrow.forward.circle"
53+
}
54+
}
55+
56+
@ViewBuilder
57+
var destination: some View {
58+
switch self {
59+
case .register: AccountInfoView(mode: .create)
60+
case .authorize: LoginView()
3461
}
3562
}
3663
}
@@ -39,8 +66,10 @@ private extension IncognitoUserButton.Mode {
3966
struct IncognitoUserButton_Previews: PreviewProvider {
4067
static var previews: some View {
4168
VStack(spacing: 16) {
42-
IncognitoUserButton(mode: .authorize)
43-
IncognitoUserButton(mode: .register)
69+
IncognitoUserButton(mode: .authorize(inForm: true))
70+
IncognitoUserButton(mode: .register(inForm: true))
71+
IncognitoUserButton(mode: .authorize(inForm: false))
72+
IncognitoUserButton(mode: .register(inForm: false))
4473
}
4574
.padding()
4675
.previewDisplayName("Инкогнито экран")

SwiftUI-WorkoutApp/Screens/Profile/IncognitoProfileView.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ struct IncognitoProfileView: View {
55
var body: some View {
66
VStack(spacing: 16) {
77
incognitoInformer
8-
IncognitoUserButton(mode: .register)
9-
IncognitoUserButton(mode: .authorize)
8+
createAccountButton
9+
IncognitoUserButton(mode: .authorize(inForm: false))
1010
}
1111
.toolbar {
1212
ToolbarItem(placement: .navigationBarTrailing) {
@@ -24,6 +24,12 @@ private extension IncognitoProfileView {
2424
.multilineTextAlignment(.center)
2525
.padding()
2626
}
27+
28+
var createAccountButton: some View {
29+
Link(destination: Constants.accountCreationURL) {
30+
IncognitoUserButton.Mode.register(inForm: false).label
31+
}
32+
}
2733
}
2834

2935
#if DEBUG

SwiftUI-WorkoutApp/Screens/Profile/Settings/AccountInfo/AccountInfoView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ struct AccountInfoView: View {
5454
extension AccountInfoView {
5555
enum Mode: CaseIterable {
5656
/// Создание аккаунта
57+
///
58+
/// Приложение не пропускают в `appstore`, пока на бэке поля "пол" и "дата рождения" являются обязательными
5759
case create
5860
/// Изменение личных данных
5961
case edit

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ private extension ProfileSettingsView {
136136
}
137137

138138
var registerButton: some View {
139-
NavigationLink(destination: AccountInfoView(mode: .create)) {
140-
Label("Регистрация", systemImage: "person.badge.plus.fill")
139+
Link(destination: Constants.accountCreationURL) {
140+
IncognitoUserButton.Mode.register(inForm: true).label
141141
.font(.system(.body).bold())
142142
}
143143
}

0 commit comments

Comments
 (0)