Skip to content

Commit

Permalink
Fix adress picker
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanov91 committed Apr 19, 2023
1 parent c3ec8ce commit 5ac3e2f
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 38 deletions.
3 changes: 1 addition & 2 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
--swiftversion 5.7
--header "\nCopyright © {created.year} Alexander Romanov\n{file}\n"
--swiftversion 5.8
--disable preferKeyPath
18 changes: 9 additions & 9 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let productionDependencies: [PackageDescription.Package.Dependency] = { [
.package(url: "https://github.com/oversizedev/OversizeLocalizable.git", .upToNextMajor(from: "1.4.0")),
.package(url: "https://github.com/oversizedev/OversizeComponents.git", .upToNextMajor(from: "1.2.0")),
.package(url: "https://github.com/oversizedev/OversizeResources.git", .upToNextMajor(from: "1.3.0")),
.package(url: "https://github.com/hmlongco/Factory.git", .upToNextMajor(from: "2.1.3"))
.package(url: "https://github.com/hmlongco/Factory.git", .upToNextMajor(from: "2.1.3")),
] }()

let developmentDependencies: [PackageDescription.Package.Dependency] = { [
Expand All @@ -20,7 +20,7 @@ let developmentDependencies: [PackageDescription.Package.Dependency] = { [
.package(name: "OversizeCore", path: "../OversizeCore"),
.package(name: "OversizeComponents", path: "../OversizeComponents"),
.package(name: "OversizeResources", path: "../OversizeResources"),
.package(url: "https://github.com/hmlongco/Factory.git", .upToNextMajor(from: "2.1.3"))
.package(url: "https://github.com/hmlongco/Factory.git", .upToNextMajor(from: "2.1.3")),
] }()

let package = Package(
Expand All @@ -42,7 +42,7 @@ let package = Package(
.library(name: "OversizeNotificationKit", targets: ["OversizeNotificationKit"]),
.library(name: "OversizePhotoKit", targets: ["OversizePhotoKit"]),
],
dependencies: productionDependencies,
dependencies: developmentDependencies,
targets: [
.target(
name: "OversizeKit",
Expand All @@ -54,7 +54,7 @@ let package = Package(
.product(name: "OversizeComponents", package: "OversizeComponents"),
.product(name: "OversizeLocalizable", package: "OversizeLocalizable"),
.product(name: "OversizeResources", package: "OversizeResources"),
.product(name: "Factory", package: "Factory")
.product(name: "Factory", package: "Factory"),
]
),
.target(
Expand All @@ -74,7 +74,7 @@ let package = Package(
.product(name: "OversizeServices", package: "OversizeServices"),
.product(name: "OversizeCalendarService", package: "OversizeServices"),
.product(name: "OversizeLocationService", package: "OversizeServices"),
.product(name: "Factory", package: "Factory")
.product(name: "Factory", package: "Factory"),
]
),
.target(
Expand All @@ -85,7 +85,7 @@ let package = Package(
.product(name: "OversizeServices", package: "OversizeServices"),
.product(name: "OversizeContactsService", package: "OversizeServices"),
.product(name: "OversizeCalendarService", package: "OversizeServices"),
.product(name: "Factory", package: "Factory")
.product(name: "Factory", package: "Factory"),
]
),
.target(
Expand All @@ -94,7 +94,7 @@ let package = Package(
.product(name: "OversizeUI", package: "OversizeUI"),
.product(name: "OversizeServices", package: "OversizeServices"),
.product(name: "OversizeLocationService", package: "OversizeServices"),
.product(name: "Factory", package: "Factory")
.product(name: "Factory", package: "Factory"),
]
),
.target(
Expand All @@ -105,7 +105,7 @@ let package = Package(
.product(name: "OversizeUI", package: "OversizeUI"),
.product(name: "OversizeServices", package: "OversizeServices"),
.product(name: "OversizeStoreService", package: "OversizeServices"),
.product(name: "Factory", package: "Factory")
.product(name: "Factory", package: "Factory"),
]
),
.target(
Expand All @@ -121,7 +121,7 @@ let package = Package(
.product(name: "OversizeUI", package: "OversizeUI"),
.product(name: "OversizeServices", package: "OversizeServices"),
.product(name: "OversizeNotificationService", package: "OversizeServices"),
.product(name: "Factory", package: "Factory")
.product(name: "Factory", package: "Factory"),
]
),
.target(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
//

import EventKit
import Factory
import OversizeCalendarService
import OversizeCore
import OversizeLocationService
import OversizeServices
import SwiftUI
import Factory

public enum CreateEventType: Equatable {
case new(Date?, calendar: EKCalendar?)
Expand Down
2 changes: 1 addition & 1 deletion Sources/OversizeKit/StoreKit/Views/StoreProductView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
// StoreProductView.swift
//

import Factory
import OversizeServices
import OversizeStoreService
import OversizeUI
import StoreKit
import SwiftUI
import Factory

public struct StoreProductView: View {
public enum StoreProductViewType {
Expand Down
2 changes: 1 addition & 1 deletion Sources/OversizeKit/SystemKit/SystemServices.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
// SystemServices.swift
//

import Factory
import OversizeCore
import OversizeLocalizable
import OversizeServices
import OversizeStoreService
import OversizeUI
import SwiftUI
import Factory

public struct SystemServicesModifier: ViewModifier {
@Injected(\.appStateService) var appState: AppStateService
Expand Down
74 changes: 52 additions & 22 deletions Sources/OversizeLocationKit/AddressField/AddressField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SwiftUI

public struct AddressField: View {
@Environment(\.theme) private var theme: ThemeSettings
@Environment(\.fieldLabelPosition) private var fieldPlaceholderPosition: FieldLabelPosition
@Binding private var seletedAddress: String?
@Binding private var seletedLocation: CLLocationCoordinate2D?
@Binding private var seletedPlace: LocationAddress?
Expand All @@ -29,9 +30,17 @@ public struct AddressField: View {
_seletedPlace = place
}

var addressText: String {
var isSlectedAddress: Bool {
if let seletedAddress, !seletedAddress.isEmpty {
return seletedAddress
return true
} else {
return false
}
}

var addressText: String {
if isSlectedAddress {
return seletedAddress ?? "Address selected"
} else if let seletedLocation {
return "Сoordinates: \(seletedLocation.latitude), \(seletedLocation.longitude)"
} else {
Expand All @@ -43,32 +52,53 @@ public struct AddressField: View {
Button {
isShowPicker.toggle()
} label: {
HStack {
Text(title)
Spacer()
Icon(.chevronDown, color: .onSurfaceHighEmphasis)
VStack(alignment: .leading, spacing: .xSmall) {
if fieldPlaceholderPosition == .adjacent {
HStack {
Text(title)
.subheadline(.medium)
.foregroundColor(.onSurfaceHighEmphasis)
Spacer()
}
}

HStack {
ZStack(alignment: .leading) {
if fieldPlaceholderPosition == .overInput {
Text(title)
.font(!isSlectedAddress ? .headline : .subheadline)
.fontWeight(!isSlectedAddress ? .medium : .semibold)
.onSurfaceDisabledForegroundColor()
.offset(y: !isSlectedAddress ? 0 : -13)
.opacity(!isSlectedAddress ? 0 : 1)
}

Text(addressText)
.padding(.vertical, fieldPlaceholderPosition == .overInput ? .xxxSmall : .zero)
.offset(y: fieldOffset)
.lineLimit(1)
}
Spacer()
Icon(.chevronDown, color: .onSurfaceHighEmphasis)
}
}
.contentShape(Rectangle())
}
.frame(minWidth: 0, maxWidth: .infinity)
.padding()
.background(
RoundedRectangle(cornerRadius: Radius.medium,
style: .continuous)
.fill(Color.surfaceSecondary)
.overlay(
RoundedRectangle(cornerRadius: Radius.medium,
style: .continuous)
.stroke(theme.borderTextFields
? Color.border
: Color.surfaceSecondary, lineWidth: CGFloat(theme.borderSize))
)
)
.headline()
.foregroundColor(.onSurfaceHighEmphasis)
.buttonStyle(.scale)
.buttonStyle(.field)
.sheet(isPresented: $isShowPicker) {
AddressPicker(address: $seletedAddress, location: $seletedLocation, place: $seletedPlace)
}
}

private var fieldOffset: CGFloat {
switch fieldPlaceholderPosition {
case .default:
return 0
case .adjacent:
return 0
case .overInput:
return !isSlectedAddress ? 0 : 10
}
}
}
2 changes: 1 addition & 1 deletion Sources/OversizeNoticeKit/NoticeListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
// NoticeListView.swift
//

import Factory
import OversizeKit
import OversizeServices
import OversizeStoreService
import OversizeUI
import StoreKit
import SwiftUI
import Factory

public struct NoticeListView: View {
@Injected(\.appStoreReviewService) var reviewService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
// LocalNotificationSetScreenViewModel.swift
//

import Factory
import OversizeCore
import OversizeNotificationService
import OversizeServices
import SwiftUI
import Factory

@MainActor
class LocalNotificationSetScreenViewModel: ObservableObject {
Expand Down

0 comments on commit 5ac3e2f

Please sign in to comment.