Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/app redesign/input field contact screen #944

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ struct SubmitClaimOccurrencePlusLocationScreen: View {

if let dateOfOccurrenceStep = dateOfOccurenceStep {
hSection {
hDatePickerField(config: .init(
maxDate: dateOfOccurenceStep?.getMaxDate(),
placeholder: L10n.Claims.Item.Screen.Date.Of.Incident.button,
title: L10n.Claims.Incident.Screen.Date.Of.incident),
hDatePickerField(
config: .init(
maxDate: dateOfOccurenceStep?.getMaxDate(),
placeholder: L10n.Claims.Item.Screen.Date.Of.Incident.button,
title: L10n.Claims.Incident.Screen.Date.Of.incident
),
selectedDate: dateOfOccurrenceStep.dateOfOccurence?.localDateToDate,
placehodlerText: L10n.Claims.Item.Screen.Date.Of.Incident.button
) { date in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import Combine
import SwiftUI
import hCore
import hCoreUI

public struct SubmitClaimContactScreen: View {
public struct SubmitClaimContactScreen: View, KeyboardReadable {
@PresentableStore var store: SubmitClaimStore
@State var phoneNumber: String
@State var type: ClaimsFlowContactType?
@State var keyboardEnabled: Bool = false

public init(
model: FlowClaimPhoneNumberStepModel
Expand All @@ -26,17 +28,25 @@ public struct SubmitClaimContactScreen: View {
placeholder: L10n.phoneNumberRowTitle
)
}
.onReceive(keyboardPublisher) { newIsKeyboardEnabled in
keyboardEnabled = newIsKeyboardEnabled
}
.sectionContainerStyle(.transparent)
.disableOn(SubmitClaimStore.self, [.postPhoneNumber])
LoadingButtonWithContent(SubmitClaimStore.self, ClaimsLoadingType.postPhoneNumber) {
store.send(.phoneNumberRequest(phoneNumber: phoneNumber))
UIApplication.dismissKeyboard()
if keyboardEnabled {
UIApplication.dismissKeyboard()
} else {
store.send(.phoneNumberRequest(phoneNumber: phoneNumber))
UIApplication.dismissKeyboard()
}
} content: {
hText(L10n.saveAndContinueButtonLabel, style: .body)
hText(keyboardEnabled ? L10n.generalSaveButton : L10n.generalContinueButton)
}
.frame(maxWidth: .infinity, alignment: .bottom)
.padding(.horizontal, 16)
}
.padding(.bottom, 16)
}
}
}
Expand All @@ -55,3 +65,22 @@ enum ClaimsFlowContactType: hTextFieldFocusStateCompliant {

case phoneNumber
}

protocol KeyboardReadable {
var keyboardPublisher: AnyPublisher<Bool, Never> { get }
}

extension KeyboardReadable {
var keyboardPublisher: AnyPublisher<Bool, Never> {
Publishers.Merge(
NotificationCenter.default
.publisher(for: UIResponder.keyboardWillShowNotification)
.map { _ in true },

NotificationCenter.default
.publisher(for: UIResponder.keyboardWillHideNotification)
.map { _ in false }
)
.eraseToAnyPublisher()
}
}
1 change: 1 addition & 0 deletions Projects/Home/Sources/Components/HomeSection.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import hGraphQL
public struct InsurableLimitsSectionView: View {
var limits: [InsurableLimits]
var didTap: (_ limit: InsurableLimits) -> Void

public init(
limits: [InsurableLimits],
didTap: @escaping (InsurableLimits) -> Void
) {
self.limits = limits
self.didTap = didTap
}

public var body: some View {
hSection(limits, id: \.label) { limit in
hRow {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import Foundation
import SwiftUI

public struct ChecboxToggleStyle: ToggleStyle {
public init(){}

public init() {}

public func makeBody(configuration: Configuration) -> some View {
if #available(iOS 15.0, *) {
HStack {
Expand Down
2 changes: 1 addition & 1 deletion Projects/hCoreUI/Sources/Views/MarqueeText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public struct MarqueeText: View {
Text(self.text)
.lineLimit(1)
.font(.init(font))
.offset(x:0)
.offset(x: 0)
.offset(x: self.animate ? -(stringWidth - geo.size.width) - 6 : 0) //
.animation(
self.animate
Expand Down
1 change: 1 addition & 0 deletions Projects/hCoreUI/Sources/hForm/hFloatingTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public struct hFloatingTextField<Value: hTextFieldFocusStateCompliant>: View {
}
.onTapGesture {
self.equals = self.focusValue
self.vm.textField?.becomeFirstResponder()
}
.onChange(of: error) { error in
self.animate = true
Expand Down
8 changes: 4 additions & 4 deletions Projects/hCoreUI/Sources/hForm/hRadioField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public struct hRadioField<Content: View>: View {
@Binding var selected: String?
@Binding private var error: String?
@State private var animate = false

public init(
id: String,
content: @escaping () -> Content,
Expand All @@ -23,7 +23,7 @@ public struct hRadioField<Content: View>: View {
self._error = error ?? Binding.constant(nil)
self.useAnimation = useAnimation
}

public var body: some View {
HStack {
content
Expand Down Expand Up @@ -53,7 +53,7 @@ public struct hRadioField<Content: View>: View {
}
}
}

@hColorBuilder
func retColor(isSelected: Bool) -> some hColor {
if isSelected {
Expand All @@ -62,7 +62,7 @@ public struct hRadioField<Content: View>: View {
hFillColorNew.opaqueOne
}
}

@hColorBuilder
func getBorderColor(isSelected: Bool) -> some hColor {
if isSelected {
Expand Down