Skip to content

Commit

Permalink
Merge pull request #57 from blyscuit/feature/#17-ui-survey-selection
Browse files Browse the repository at this point in the history
[#17] [iOS] [UI] As a user, I can see Survey selection page
  • Loading branch information
blyscuit authored Nov 18, 2022
2 parents 9016703 + 3315a2c commit 9aec306
Show file tree
Hide file tree
Showing 22 changed files with 681 additions and 67 deletions.
58 changes: 29 additions & 29 deletions iosApp/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ GEM
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.2.0)
aws-partitions (1.629.0)
aws-sdk-core (3.146.0)
aws-partitions (1.659.0)
aws-sdk-core (3.167.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.525.0)
aws-sigv4 (~> 1.1)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.5)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.58.0)
aws-sdk-core (~> 3, >= 3.127.0)
aws-sdk-kms (1.59.0)
aws-sdk-core (~> 3, >= 3.165.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.114.0)
aws-sdk-core (~> 3, >= 3.127.0)
aws-sdk-s3 (1.117.1)
aws-sdk-core (~> 3, >= 3.165.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.4)
aws-sigv4 (1.5.1)
aws-sigv4 (1.5.2)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
claide (1.1.0)
Expand Down Expand Up @@ -82,7 +82,7 @@ GEM
concurrent-ruby (1.1.10)
cork (0.3.0)
colored2 (~> 3.1)
danger (9.0.0)
danger (9.1.0)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
Expand Down Expand Up @@ -117,9 +117,9 @@ GEM
dotenv (2.8.1)
emoji_regex (3.2.3)
escape (0.0.4)
ethon (0.15.0)
ethon (0.16.0)
ffi (>= 1.15.0)
excon (0.92.4)
excon (0.94.0)
faraday (1.10.2)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
Expand Down Expand Up @@ -151,7 +151,7 @@ GEM
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.2.6)
fastlane (2.209.1)
fastlane (2.210.1)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
Expand Down Expand Up @@ -190,17 +190,17 @@ GEM
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3)
fastlane-plugin-firebase_app_distribution (0.3.6)
fastlane-plugin-firebase_app_distribution (0.3.7)
ffi (1.15.5)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
git (1.12.0)
addressable (~> 2.8)
rchardet (~> 1.8)
google-apis-androidpublisher_v3 (0.26.0)
google-apis-core (>= 0.7, < 2.a)
google-apis-core (0.7.0)
google-apis-androidpublisher_v3 (0.31.0)
google-apis-core (>= 0.9.1, < 2.a)
google-apis-core (0.9.1)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
Expand All @@ -209,27 +209,27 @@ GEM
retriable (>= 2.0, < 4.a)
rexml
webrick
google-apis-iamcredentials_v1 (0.13.0)
google-apis-core (>= 0.7, < 2.a)
google-apis-playcustomapp_v1 (0.10.0)
google-apis-core (>= 0.7, < 2.a)
google-apis-storage_v1 (0.17.0)
google-apis-core (>= 0.7, < 2.a)
google-apis-iamcredentials_v1 (0.16.0)
google-apis-core (>= 0.9.1, < 2.a)
google-apis-playcustomapp_v1 (0.12.0)
google-apis-core (>= 0.9.1, < 2.a)
google-apis-storage_v1 (0.19.0)
google-apis-core (>= 0.9.0, < 2.a)
google-cloud-core (1.6.0)
google-cloud-env (~> 1.0)
google-cloud-errors (~> 1.0)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.3.0)
google-cloud-storage (1.39.0)
google-cloud-storage (1.44.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
google-apis-storage_v1 (~> 0.17.0)
google-apis-storage_v1 (~> 0.19.0)
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
googleauth (1.2.0)
googleauth (1.3.0)
faraday (>= 0.17.3, < 3.a)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
Expand Down Expand Up @@ -261,7 +261,7 @@ GEM
naturally (2.2.1)
netrc (0.11.0)
no_proxy_fix (0.1.2)
octokit (5.5.0)
octokit (5.6.1)
faraday (>= 1, < 3)
sawyer (~> 0.9)
open4 (1.3.4)
Expand Down Expand Up @@ -333,7 +333,7 @@ GEM
xcpretty-travis-formatter (1.0.1)
xcpretty (~> 0.2, >= 0.0.7)
xcresult (0.2.1)
zeitwerk (2.6.0)
zeitwerk (2.6.6)

PLATFORMS
x86_64-darwin-21
Expand All @@ -350,4 +350,4 @@ DEPENDENCIES
xcov

BUNDLED WITH
2.3.20
2.3.25
150 changes: 112 additions & 38 deletions iosApp/Survey.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "nextButton.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ struct AppCoordinator: View {
ResetPasswordView()
case .splash:
SplashView(coordinator: coordinator)
case .surveySelection:
SurveySelectionView()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ extension RouteCoordinator: LoginCoordinator {
func showResetPassword() {
routes.push(.resetPassword)
}

func showHome() {
routes = [.root(.surveySelection)]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ enum Screen {
case login
case splash
case resetPassword
case surveySelection
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import SwiftUI
protocol LoginCoordinator {

func showResetPassword()
func showHome()
}

struct LoginView: View {
Expand Down Expand Up @@ -101,6 +102,9 @@ struct LoginView: View {
var loginButton: some View {
Button {
// TODO: Add action when press `login`
withAnimation {
coordinator.showHome()
}
} label: {
Text(Localize.loginButtonLogin())
.frame(maxWidth: .infinity)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// SurveyItemView.swift
// Survey
//
// Created by Bliss on 28/9/22.
// Copyright © 2022 Nimble. All rights reserved.
//

import Kingfisher
import Shared
import SwiftUI

struct SurveyItemView: View {

let survey: SurveyUiModel

var body: some View {
ZStack {
GeometryReader { geo in
KFImage(survey.largeImageUrl.asURL)
.resizable()
.scaledToFill()
.frame(maxWidth: geo.size.width, maxHeight: geo.size.height)
.clipped()
.accessibility(.surveySelection(.mainImage))
}
.ignoresSafeArea()

Rectangle()
.foregroundColor(.clear)
.background(
LinearGradient(colors: [.clear, .black], startPoint: .top, endPoint: .bottom)
)
.opacity(0.6)
.ignoresSafeArea()

GeometryReader { geo in
let titleOffset = geo.size.height - 160.0
Text(survey.title)
.font(.boldTitle)
.lineLimit(2)
.frame(maxWidth: .infinity, alignment: .leading)
.offset(y: titleOffset)
.accessibility(.surveySelection(.titleText))

let descriptionOffset = geo.size.height - 76.0
Text(survey.description_)
.font(.regularBody)
.lineLimit(2)
.frame(maxWidth: .infinity, alignment: .leading)
.offset(y: descriptionOffset)
.accessibility(.surveySelection(.detailText))
}
.id(survey.id)
.padding(.leading, 20.0)
.padding(.trailing, 76.0)
}
.accessibilityElement(children: .contain)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
//
// SurveySelectionView.swift
// Survey
//
// Created by Bliss on 28/9/22.
// Copyright © 2022 Nimble. All rights reserved.
//

import Shared
import SwiftUI

struct SurveySelectionView: View {

@State private var currentPage = 0
// TODO: Replace Example data
@State private var surveys: [SurveyUiModel] = [
SurveyUiModel(
id: "1",
imageUrl: "https://dhdbhh0jsld0o.cloudfront.net/m/1ea51560991bcb7d00d0_",
title: "Scarlett Bangkok",
description: "We'd love ot hear from you!"
),
SurveyUiModel(
id: "2",
imageUrl: "https://dhdbhh0jsld0o.cloudfront.net/m/287db81c5e4242412cc0_",
title: "ibis Bangkok Riverside",
description: "We'd love ot hear from you!"
),
SurveyUiModel(
id: "3",
imageUrl: "https://dhdbhh0jsld0o.cloudfront.net/m/1ea51560991bcb7d00d0_",
title: "Scarlett Bangkok",
description: "We'd love ot hear from you!"
)
]

var body: some View {
ZStack {
FadePaginationView(
currentPage: $currentPage,
currentView: { item in
AnyView(SurveyItemView(survey: item))
},
nextView: { item in
AnyView(SurveyItemView(survey: item))
},
items: surveys
)
.onChange(of: currentPage) { newValue in
// TODO: Update viewModel to new index
print(newValue)
}
VStack(alignment: .leading) {
Spacer()
HStack(alignment: .bottom) {
PageControlView(currentPage: $currentPage, numberOfPages: surveys.count)
.frame(width: .zero, alignment: .leading)
Spacer()
}
Spacer()
.frame(height: 190.0)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)

VStack {
Spacer()
HStack {
Spacer()
Button {
// TODO: Add action when press next
} label: {
Assets.nextButton
.image
.resizable()
.frame(width: 56.0, height: 56.0)
}
.padding(.trailing, 20.0)
.padding(.bottom, 26.0)
.accessibility(.surveySelection(.nextButton))
}
}
}
.accessibilityElement(children: .contain)
.accessibility(.surveySelection(.view))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// ViewId+SurveySelection.swift
// Survey
//
// Created by Bliss on 28/9/22.
// Copyright © 2022 Nimble. All rights reserved.
//

extension ViewId {

enum SurveySelection: String {

case view = "survey.selection.view"
case nextButton = "survey.selection.next.button"
case titleText = "survey.selection.title.text"
case detailText = "survey.selection.detail.text"
case mainImage = "survey.selection.main.image"
}
}
2 changes: 2 additions & 0 deletions iosApp/Survey/Sources/Presentation/ViewId/ViewId.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ enum ViewId {
case login(Login)
case splash(Splash)
case resetPassword(ResetPassword)
case surveySelection(SurveySelection)
case general(General)

func callAsFunction() -> String {
switch self {
case let .login(login): return login.rawValue
case let .splash(splash): return splash.rawValue
case let .resetPassword(resetPassword): return resetPassword.rawValue
case let .surveySelection(surveySelection): return surveySelection.rawValue
case let .general(general): return general.rawValue
}
}
Expand Down
Loading

0 comments on commit 9aec306

Please sign in to comment.