Skip to content

Commit

Permalink
Merge pull request #129 from blyscuit/release/0.7.0
Browse files Browse the repository at this point in the history
Release - 0.7.0
  • Loading branch information
blyscuit authored Feb 22, 2023
2 parents b5b97d1 + 473ef31 commit 74fec55
Show file tree
Hide file tree
Showing 19 changed files with 445 additions and 26 deletions.
29 changes: 25 additions & 4 deletions iosApp/Survey.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,13 @@
09D09E09296E7D55009F88AF /* SurveyQuestionScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D09E06296E7D55009F88AF /* SurveyQuestionScreen.swift */; };
09D09E0B296E837F009F88AF /* QuestionPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D09E0A296E837F009F88AF /* QuestionPickerView.swift */; };
09D09E0C296EBA20009F88AF /* TimeInterval+Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09C2F4012934588400F44818 /* TimeInterval+Constants.swift */; };
09E08C4B298CB0BD00CC765C /* QuestionEmojiView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09E08C4A298CB0BD00CC765C /* QuestionEmojiView.swift */; };
09E08C562990E97F00CC765C /* Collection+Safe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09E08C552990E97F00CC765C /* Collection+Safe.swift */; };
09E08C5A2990EB4B00CC765C /* CollectionSafeSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09E08C582990EB3800CC765C /* CollectionSafeSpec.swift */; };
09E08C5C2990F8B600CC765C /* QuestionRangePickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09E08C5B2990F8B600CC765C /* QuestionRangePickerView.swift */; };
09E08C45298B7DD500CC765C /* QuestionMultiChoiceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09E08C44298B7DD500CC765C /* QuestionMultiChoiceView.swift */; };
09E08C47298B89F400CC765C /* QuestionMultiFormView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09E08C46298B89F400CC765C /* QuestionMultiFormView.swift */; };
09E08C49298B922700CC765C /* QuestionTextAreaView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09E08C48298B922700CC765C /* QuestionTextAreaView.swift */; };
09E6ABF32951D105007F1EE3 /* KIF+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09E6ABF12951D103007F1EE3 /* KIF+Swift.swift */; };
09E6ABFD2951D32F007F1EE3 /* ViewId.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09636B1428D8148C00A5CB97 /* ViewId.swift */; };
09E6ABFE2951D333007F1EE3 /* ViewId+General.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09636B2F28D8267D00A5CB97 /* ViewId+General.swift */; };
Expand Down Expand Up @@ -321,8 +326,13 @@
09D09E02296E7CF9009F88AF /* SurveyQuestionSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SurveyQuestionSpec.swift; sourceTree = "<group>"; };
09D09E06296E7D55009F88AF /* SurveyQuestionScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SurveyQuestionScreen.swift; sourceTree = "<group>"; };
09D09E0A296E837F009F88AF /* QuestionPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuestionPickerView.swift; sourceTree = "<group>"; };
09E08C4A298CB0BD00CC765C /* QuestionEmojiView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QuestionEmojiView.swift; sourceTree = "<group>"; };
09E08C552990E97F00CC765C /* Collection+Safe.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Collection+Safe.swift"; sourceTree = "<group>"; };
09E08C582990EB3800CC765C /* CollectionSafeSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionSafeSpec.swift; sourceTree = "<group>"; };
09E08C5B2990F8B600CC765C /* QuestionRangePickerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QuestionRangePickerView.swift; sourceTree = "<group>"; };
09E08C44298B7DD500CC765C /* QuestionMultiChoiceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuestionMultiChoiceView.swift; sourceTree = "<group>"; };
09E08C46298B89F400CC765C /* QuestionMultiFormView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuestionMultiFormView.swift; sourceTree = "<group>"; };
09E08C48298B922700CC765C /* QuestionTextAreaView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuestionTextAreaView.swift; sourceTree = "<group>"; };
09E6ABE42951CF3E007F1EE3 /* SurveyKIFUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SurveyKIFUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
09E6ABF12951D103007F1EE3 /* KIF+Swift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "KIF+Swift.swift"; sourceTree = "<group>"; };
09E6AC0B2951D5DD007F1EE3 /* AccountSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSpec.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -907,6 +917,11 @@
children = (
09D09DFC296E6B35009F88AF /* SurveyQuestionView.swift */,
09D09E0A296E837F009F88AF /* QuestionPickerView.swift */,
09E08C4A298CB0BD00CC765C /* QuestionEmojiView.swift */,
09E08C5B2990F8B600CC765C /* QuestionRangePickerView.swift */,
09E08C44298B7DD500CC765C /* QuestionMultiChoiceView.swift */,
09E08C46298B89F400CC765C /* QuestionMultiFormView.swift */,
09E08C48298B922700CC765C /* QuestionTextAreaView.swift */,
);
path = SurveyQuestion;
sourceTree = "<group>";
Expand Down Expand Up @@ -1902,14 +1917,17 @@
0982A80329278E9000FC1976 /* SurveyHeaderView.swift in Sources */,
09636B0D28D4917200A5CB97 /* OverlayButton.swift in Sources */,
09495FC9291106A00036BDFB /* Constants+SystemImage.swift in Sources */,
09E08C4B298CB0BD00CC765C /* QuestionEmojiView.swift in Sources */,
09E6AC102951D8B5007F1EE3 /* AccountView.swift in Sources */,
09E08C45298B7DD500CC765C /* QuestionMultiChoiceView.swift in Sources */,
09D09DCE29682B78009F88AF /* SurveyItemOverlayView.swift in Sources */,
09D09DC429681214009F88AF /* RouterCoordinator+WithoutAnimation.swift in Sources */,
09D09DC8296817E2009F88AF /* SurveyDetailImage.swift in Sources */,
686B2C185816765B3E124776 /* IOSApp.swift in Sources */,
09CE771328E1A94600EAA9EE /* ResetPasswordView.swift in Sources */,
09FE26CD294B1EE3005A7F85 /* SurveySelectionView+DataSource.swift in Sources */,
09D09DCA29682810009F88AF /* Constants+Animation.swift in Sources */,
09E08C47298B89F400CC765C /* QuestionMultiFormView.swift in Sources */,
09636B3028D8267D00A5CB97 /* ViewId+General.swift in Sources */,
09636B0228D4876100A5CB97 /* PrimaryButton.swift in Sources */,
09CE770C28E191B400EAA9EE /* AppCoordinator.swift in Sources */,
Expand Down Expand Up @@ -1949,8 +1967,11 @@
0982A7E029222EB900FC1976 /* ViewId+Splash.swift in Sources */,
097C4AE82988B96E00AE265A /* SurveyDetailView+DataSource.swift in Sources */,
0964B1D02942F3A300946FA1 /* LoginView+DataSource.swift in Sources */,
09E08C43298B74D600CC765C /* QuestionRangePickerView.swift in Sources */,
09E08C49298B922700CC765C /* QuestionTextAreaView.swift in Sources */,
09495F9C290A35BC0036BDFB /* ViewId+Account.swift in Sources */,
09CE770F28E1922000EAA9EE /* Screen.swift in Sources */,
09E08C5C2990F8B600CC765C /* QuestionRangePickerView.swift in Sources */,
09CE772528E2C1C600EAA9EE /* View+HideBackButtonTitle.swift in Sources */,
09CE771528E1AB0B00EAA9EE /* ViewId+ResetPassword.swift in Sources */,
09D09DC6296812F6009F88AF /* View+ConditionalModifier.swift in Sources */,
Expand Down Expand Up @@ -2489,7 +2510,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.6.0;
MARKETING_VERSION = 0.7.0;
PRODUCT_BUNDLE_IDENTIFIER = "co.nimblehq.bliss.kmm-ic";
PRODUCT_NAME = Survey;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -2749,7 +2770,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.6.0;
MARKETING_VERSION = 0.7.0;
PRODUCT_BUNDLE_IDENTIFIER = "co.nimblehq.bliss.kmm-ic";
PRODUCT_NAME = Survey;
SDKROOT = iphoneos;
Expand All @@ -2775,7 +2796,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.6.0;
MARKETING_VERSION = 0.7.0;
PRODUCT_BUNDLE_IDENTIFIER = "co.nimblehq.bliss.kmm-ic";
PRODUCT_NAME = Survey;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -2826,7 +2847,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.6.0;
MARKETING_VERSION = 0.7.0;
PRODUCT_BUNDLE_IDENTIFIER = "co.nimblehq.bliss.kmm-ic";
PRODUCT_NAME = Survey;
SDKROOT = iphoneos;
Expand Down
3 changes: 3 additions & 0 deletions iosApp/Survey/Sources/Constants/Constants+SystemImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
extension Constants {

enum SystemImage: String {

case backArrow = "chevron.left"
case checkmarkCircleFill = "checkmark.circle.fill"
case circle
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ extension RouteCoordinator: SurveySelectionCoordinator {
extension RouteCoordinator: SurveyDetailCoordinator {

func backToHome() {
guard routes.count > 1 else {
// Already at Home
return
}
withoutAnimation {
self.routes.dismiss()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ struct SurveyDetailView: View {

@State var isAnimating = true
@State var questionIndex = 0
// TODO: Replace with real answer object
@State var currentAnswers = [String]()
@State var isShowingQuitPrompt = false

var body: some View {
ZStack {
Expand All @@ -46,9 +49,12 @@ struct SurveyDetailView: View {
}
}
.loadingDialog(loading: $dataSource.isLoading)
.alert(isPresented: $dataSource.isShowingErrorAlert, content: {
.alert(isPresented: $dataSource.isShowingErrorAlert) {
Alert(title: Text(dataSource.viewState.error))
})
}
.alert(isPresented: $isShowingQuitPrompt) {
quitAlert
}
}

var surveyView: some View {
Expand Down Expand Up @@ -114,6 +120,7 @@ struct SurveyDetailView: View {
// TODO: Submit button logics
let totalItem = (dataSource.viewState.surveyDetail?.questions.count ?? 0) - 1
guard questionIndex < totalItem else { return }
currentAnswers = []
withAnimation(.easeIn(duration: .viewTransition)) {
questionIndex += 1
}
Expand All @@ -131,15 +138,33 @@ struct SurveyDetailView: View {

var closeButton: some View {
Button {
// TODO: Implement close button
didPressBack()
isShowingQuitPrompt = true
} label: {
Assets.closeButton
.image
.resizable()
.frame(width: 28.0, height: 28.0)
.accessibility(.surveyQuestion(.closeButton))
}
.disabled(isAnimating)
}

var quitAlert: Alert {
Alert(
title: Text(String.localizeId.survey_quit_title()),
message: Text(String.localizeId.survey_quit_message()),
primaryButton: .default(
Text(String.localizeId.survey_quit_confirm())
) {
didPressBack()
},
secondaryButton: .cancel(
Text(String.localizeId.survey_quit_cancel())
.bold()
) {
isShowingQuitPrompt = false
}
)
}

init(survey: SurveyUiModel, coordinator: SurveyDetailCoordinator) {
Expand All @@ -150,13 +175,17 @@ struct SurveyDetailView: View {
}

private func animatedSurveyQuestionView(surveyDetail: SurveyDetailUiModel) -> some View {
return SurveyQuestionView(detail: surveyDetail, questionIndex: $questionIndex)
.transition(
.asymmetric(
insertion: .move(edge: .trailing).combined(with: .opacity),
removal: .move(edge: .leading).combined(with: .opacity)
)
return SurveyQuestionView(
detail: surveyDetail,
questionIndex: $questionIndex,
answers: $currentAnswers
)
.transition(
.asymmetric(
insertion: .move(edge: .trailing).combined(with: .opacity),
removal: .move(edge: .leading).combined(with: .opacity)
)
)
}

func didPressBack() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// QuestionEmojiView.swift
// Survey
//
// Created by Bliss on 2/2/23.
// Copyright © 2023 Nimble. All rights reserved.
//

import SwiftUI

struct QuestionEmojiView: View {

enum EmojiType: String {

case like
case smile
case heart
case star

func items(count: Int) -> [String] {
let items: [String]
switch self {
case .like:
items = Array(repeatElement("👍🏻", count: count))
case .smile:
items = Array(["😡", "😕", "😐", "🙂", "😄"].prefix(count))
case .heart:
items = Array(repeatElement("❤️", count: count))
case .star:
items = Array(repeatElement("⭐️", count: count))
}
return items
}
}

@State var rating: Int = 0
@Binding var answers: [String]

let type: EmojiType
let options: [Answer]

var body: some View {
let items = type.items(count: options.count)
HStack(spacing: .itemSpacing) {
Spacer()
ForEach(0 ..< items.count, id: \.self) { index in
Text(items[index])
.font(.boldTitle)
.opacity(getOpacity(index))
.onTapGesture {
rating = index
}
.frame(width: 28.0, height: 34.0)
.tag(index)
}
Spacer()
}
.onChange(of: rating) {
answers = [options[$0].id]
}
}

private func getOpacity(_ index: Int) -> Double {
switch type {
case .smile:
return index == rating ? 1.0 : 0.5
default:
return index > rating ? 0.5 : 1.0
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// QuestionMultiChoiceView.swift
// Survey
//
// Created by Bliss on 2/2/23.
// Copyright © 2023 Nimble. All rights reserved.
//

import SwiftUI

struct QuestionMultiChoiceView: View {

let options: [Answer]

@State var inputs = Set<String>()
@Binding var answers: [String]

var body: some View {
VStack {
ForEach(Array(options.enumerated()), id: \.element.id) { index, option in
let isSelected = inputs.contains(option.id)
Button {
didPress(id: option.id)
} label: {
HStack {
Text(option.text)
.lineLimit(1)
.foregroundColor(isSelected ? .white : .white.opacity(0.5))
.font(isSelected ? .boldLarge : .regularLarge)
Spacer()
if isSelected {
Image(systemName: .checkmarkCircleFill)
.foregroundColor(.white)
.font(.system(size: 24.0))
} else {
Image(systemName: .circle)
.foregroundColor(.white.opacity(0.5))
.font(.system(size: 24.0))
}
}
}
.frame(height: 56.0)
if index != options.count - 1 {
Divider()
.frame(height: 0.5)
.overlay(Color.white)
}
}
}
.padding(.horizontal, .extraLargePadding)
}

func didPress(id: String) {
if inputs.contains(id) {
inputs.remove(id)
} else {
inputs.insert(id)
}
answers = Array(inputs)
}
}
Loading

0 comments on commit 74fec55

Please sign in to comment.