-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[#6] [iOS] [UI] As a user, I can see Sign In screen
- Loading branch information
Showing
30 changed files
with
795 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+4.73 MB
iosApp/Survey/Resources/Assets/Assets.xcassets/Background Blur.imageset/Background Blur.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
iosApp/Survey/Resources/Assets/Assets.xcassets/Background Blur.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Background Blur.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true | ||
} | ||
} |
Binary file added
BIN
+2.82 MB
iosApp/Survey/Resources/Assets/Assets.xcassets/Background.imageset/Background.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
iosApp/Survey/Resources/Assets/Assets.xcassets/Background.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Background.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
iosApp/Survey/Resources/Assets/Assets.xcassets/Logo White.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Logo White.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true | ||
} | ||
} |
Binary file added
BIN
+7.5 KB
iosApp/Survey/Resources/Assets/Assets.xcassets/Logo White.imageset/Logo White.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
iosApp/Survey/Resources/Localizations/en.lproj/Localizable.strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
Localizable.strings | ||
Survey | ||
|
||
Created by Bliss on 16/9/22. | ||
Copyright © 2022 Nimble. All rights reserved. | ||
*/ | ||
|
||
"login.fields.email" = "Email"; | ||
"login.fields.password" = "Password"; | ||
"login.button.login" = "Log in"; | ||
"login.button.forgot" = "Forgot?"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
iosApp/Survey/Sources/Presentation/Modules/ContentView/ContentView.swift
This file was deleted.
Oops, something went wrong.
101 changes: 101 additions & 0 deletions
101
iosApp/Survey/Sources/Presentation/Modules/Login/LoginView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// | ||
// ContentView.swift | ||
// Survey | ||
// | ||
// Created by Bliss on 14/9/22. | ||
// Copyright © 2022 Nimble. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct LoginView: View { | ||
|
||
@State private var email: String = "" | ||
@State private var password: String = "" | ||
|
||
var body: some View { | ||
ZStack { | ||
Assets.backgroundBlur | ||
.image | ||
.resizable() | ||
.aspectRatio(contentMode: .fill) | ||
.ignoresSafeArea() | ||
.frame(maxWidth: .infinity, maxHeight: .infinity) | ||
VStack( | ||
alignment: .center, | ||
spacing: 20.0 | ||
) { | ||
Assets.logoWhite.image | ||
|
||
Spacer().frame(maxHeight: 70.0) | ||
|
||
loginField | ||
createPasswordField() | ||
loginButton | ||
} | ||
.padding(.horizontal, 24.0) | ||
} | ||
.onTapGesture { | ||
hideKeyboard() | ||
} | ||
.accessibilityElement(children: .contain) | ||
.accessibility(.login(.view)) | ||
} | ||
|
||
var loginField: some View { | ||
TextField(Localize.loginFieldsEmail(), text: $email) | ||
.keyboardType(.emailAddress) | ||
.primaryTextField() | ||
.accessibility(.login(.emailField)) | ||
} | ||
|
||
var passwordField: some View { | ||
HStack { | ||
SecureField(Localize.loginFieldsPassword(), text: $password) | ||
.accessibility(.login(.passwordField)) | ||
if password.isEmpty { | ||
Button(Localize.loginButtonForgot()) { | ||
// TODO: Add action then press `forgot` | ||
} | ||
.overlayButton() | ||
.accessibility(.login(.forgotButton)) | ||
} | ||
} | ||
.primaryTextField() | ||
.frame(maxHeight: 56.0) | ||
} | ||
|
||
var loginButton: some View { | ||
Button { | ||
// TODO: Add action when press `login` | ||
} label: { | ||
Text(Localize.loginButtonLogin()) | ||
.frame(maxWidth: .infinity) | ||
.primaryButton() | ||
.accessibility(.login(.loginButton)) | ||
} | ||
} | ||
|
||
func createPasswordField() -> AnyView { | ||
if #available(iOS 15.0, *) { | ||
return AnyView( | ||
passwordField | ||
.onSubmit { | ||
// TODO: Add action when press `return` | ||
} | ||
) | ||
} else { | ||
return AnyView( | ||
passwordField | ||
.primaryTextField() | ||
) | ||
} | ||
} | ||
} | ||
|
||
struct LoginView_Previews: PreviewProvider { | ||
|
||
static var previews: some View { | ||
LoginView() | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
iosApp/Survey/Sources/Presentation/ViewId/ViewId+General.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// ViewId+General.swift | ||
// Survey | ||
// | ||
// Created by Bliss on 19/9/22. | ||
// Copyright © 2022 Nimble. All rights reserved. | ||
// | ||
|
||
extension ViewId { | ||
|
||
enum General: String { | ||
|
||
case keyboard = "general.keyboard" | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
iosApp/Survey/Sources/Presentation/ViewId/ViewId+Login.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// ViewID+Login.swift | ||
// Survey | ||
// | ||
// Created by Bliss on 19/9/22. | ||
// Copyright © 2022 Nimble. All rights reserved. | ||
// | ||
|
||
extension ViewId { | ||
|
||
enum Login: String { | ||
|
||
case view = "login.view" | ||
case emailField = "login.email.textfield" | ||
case passwordField = "login.password.textfield" | ||
case forgotButton = "login.forgot.button" | ||
case loginButton = "login.login.button" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// ViewId.swift | ||
// Survey | ||
// | ||
// Created by Bliss on 19/9/22. | ||
// Copyright © 2022 Nimble. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
protocol Viewable {} | ||
|
||
enum ViewId { | ||
|
||
case login(Login) | ||
case general(General) | ||
|
||
func callAsFunction() -> String { | ||
switch self { | ||
case let .login(login): return login.rawValue | ||
case let .general(general): return general.rawValue | ||
} | ||
} | ||
} | ||
|
||
extension View { | ||
|
||
func accessibility(_ viewId: ViewId) -> some View { | ||
accessibilityIdentifier(viewId()) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
iosApp/Survey/Sources/Presentation/ViewModifiers/OverlayButton.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// OverlayButton.swift | ||
// Survey | ||
// | ||
// Created by Bliss on 16/9/22. | ||
// Copyright © 2022 Nimble. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct OverlayButton: ViewModifier { | ||
|
||
func body(content: Content) -> some View { | ||
content | ||
.font(.regularSmall) | ||
.foregroundColor(Color.white) | ||
.opacity(0.5) | ||
} | ||
} | ||
|
||
extension View { | ||
|
||
func overlayButton() -> some View { | ||
modifier(OverlayButton()) | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
iosApp/Survey/Sources/Presentation/ViewModifiers/PrimaryButton.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// PrimaryButton.swift | ||
// Survey | ||
// | ||
// Created by Bliss on 16/9/22. | ||
// Copyright © 2022 Nimble. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct PrimaryButton: ViewModifier { | ||
|
||
func body(content: Content) -> some View { | ||
content | ||
.font(.boldBody) | ||
.padding() | ||
.background(Color.white) | ||
.foregroundColor(Color.black) | ||
.cornerRadius(10.0) | ||
} | ||
} | ||
|
||
extension View { | ||
|
||
func primaryButton() -> some View { | ||
modifier(PrimaryButton()) | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
iosApp/Survey/Sources/Presentation/ViewModifiers/PrimaryTextField.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// PrimaryTextField.swift | ||
// Survey | ||
// | ||
// Created by Bliss on 16/9/22. | ||
// Copyright © 2022 Nimble. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct PrimaryTextField: ViewModifier { | ||
|
||
func body(content: Content) -> some View { | ||
content | ||
.font(.regularBody) | ||
.accentColor(Color.white) | ||
.padding() | ||
.background(Color.white.opacity(0.18)) | ||
.cornerRadius(10.0) | ||
} | ||
} | ||
|
||
extension View { | ||
|
||
func primaryTextField() -> some View { | ||
modifier(PrimaryTextField()) | ||
} | ||
} |
Oops, something went wrong.