diff --git a/.swiftformat b/.swiftformat index 8f95e5e..21f72f9 100644 --- a/.swiftformat +++ b/.swiftformat @@ -1,3 +1,2 @@ ---swiftversion 5.7 ---header "\nCopyright © {created.year} Alexander Romanov\n{file}\n" +--swiftversion 5.8 --disable preferKeyPath \ No newline at end of file diff --git a/Package.swift b/Package.swift index d257cb5..eeb3c51 100644 --- a/Package.swift +++ b/Package.swift @@ -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] = { [ @@ -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( @@ -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", @@ -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( @@ -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( @@ -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( @@ -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( @@ -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( @@ -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( diff --git a/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventViewModel.swift b/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventViewModel.swift index 27774fd..96b5472 100644 --- a/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventViewModel.swift +++ b/Sources/OversizeCalendarKit/CreateEventScreen/CreateEventViewModel.swift @@ -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?) diff --git a/Sources/OversizeKit/StoreKit/Views/StoreProductView.swift b/Sources/OversizeKit/StoreKit/Views/StoreProductView.swift index 88b7c9f..acc2cd2 100644 --- a/Sources/OversizeKit/StoreKit/Views/StoreProductView.swift +++ b/Sources/OversizeKit/StoreKit/Views/StoreProductView.swift @@ -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 { diff --git a/Sources/OversizeKit/SystemKit/SystemServices.swift b/Sources/OversizeKit/SystemKit/SystemServices.swift index 781bd93..f74efb6 100644 --- a/Sources/OversizeKit/SystemKit/SystemServices.swift +++ b/Sources/OversizeKit/SystemKit/SystemServices.swift @@ -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 diff --git a/Sources/OversizeLocationKit/AddressField/AddressField.swift b/Sources/OversizeLocationKit/AddressField/AddressField.swift index d4c8f6e..0a9a32f 100644 --- a/Sources/OversizeLocationKit/AddressField/AddressField.swift +++ b/Sources/OversizeLocationKit/AddressField/AddressField.swift @@ -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? @@ -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 { @@ -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 + } + } } diff --git a/Sources/OversizeNoticeKit/NoticeListView.swift b/Sources/OversizeNoticeKit/NoticeListView.swift index 527eb98..6c26da3 100644 --- a/Sources/OversizeNoticeKit/NoticeListView.swift +++ b/Sources/OversizeNoticeKit/NoticeListView.swift @@ -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 diff --git a/Sources/OversizeNotificationKit/LocalNotificationSetScreenViewModel.swift b/Sources/OversizeNotificationKit/LocalNotificationSetScreenViewModel.swift index 00017a9..b78293a 100644 --- a/Sources/OversizeNotificationKit/LocalNotificationSetScreenViewModel.swift +++ b/Sources/OversizeNotificationKit/LocalNotificationSetScreenViewModel.swift @@ -3,11 +3,11 @@ // LocalNotificationSetScreenViewModel.swift // +import Factory import OversizeCore import OversizeNotificationService import OversizeServices import SwiftUI -import Factory @MainActor class LocalNotificationSetScreenViewModel: ObservableObject {