Skip to content

Commit

Permalink
Merge pull request #35 from oversizedev/develop
Browse files Browse the repository at this point in the history
Update icons and rename methods like iOS 17
  • Loading branch information
aromanov91 committed Sep 1, 2023
2 parents f83c87e + 736f1a1 commit 89a0707
Show file tree
Hide file tree
Showing 959 changed files with 3,403 additions and 2,269 deletions.
7 changes: 6 additions & 1 deletion Package.swift
Expand Up @@ -18,7 +18,12 @@ let package = Package(
],
dependencies: [],
targets: [
.target(name: "OversizeUI", dependencies: [], resources: [.process("Resources")]),
.target(
name: "OversizeUI",
dependencies: [],
resources: [.process("Resources")]
// swiftSettings: [.define("ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS")]
),
.testTarget(name: "OversizeUITests", dependencies: ["OversizeUI"]),
]
)
2 changes: 1 addition & 1 deletion Sources/OversizeUI/Controls/Checkbox/Checkbox.swift
Expand Up @@ -10,7 +10,7 @@ public enum CheckboxAlignment {
}

public struct Checkbox<Label: View>: View {
@Environment(\.rowContentInset) private var contentInset: EdgeSpaceInsets
@Environment(\.rowContentMargins) private var contentInset: EdgeSpaceInsets
@Environment(\.isEnabled) private var isEnabled: Bool
@Binding var isOn: Bool
private let label: () -> Label?
Expand Down
139 changes: 69 additions & 70 deletions Sources/OversizeUI/Controls/DateField/DateField.swift
Expand Up @@ -6,88 +6,87 @@
import SwiftUI

#if os(iOS)
@available(iOS 15.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
public struct DateField: View {
@Environment(\.theme) private var theme: ThemeSettings
@Environment(\.fieldLabelPosition) private var fieldPlaceholderPosition: FieldLabelPosition
@Binding private var selection: Date
@Binding private var optionalSelection: Date?
private let label: String
@State private var showModal = false
@available(iOS 15.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
public struct DateField: View {
@Environment(\.theme) private var theme: ThemeSettings
@Environment(\.fieldLabelPosition) private var fieldPlaceholderPosition: FieldLabelPosition
@Binding private var selection: Date
@Binding private var optionalSelection: Date?
private let label: String
@State private var showModal = false

let isOptionalSelection: Bool
let isOptionalSelection: Bool

public init(
_ sheetTitle: String = "Date",
selection: Binding<Date>
) {
label = sheetTitle
_selection = selection
_optionalSelection = .constant(nil)
isOptionalSelection = false
}
public init(
_ sheetTitle: String = "Date",
selection: Binding<Date>
) {
label = sheetTitle
_selection = selection
_optionalSelection = .constant(nil)
isOptionalSelection = false
}

public init(
_ label: String = "Date",
selection: Binding<Date?>
) {
self.label = label
_selection = .constant(Date())
_optionalSelection = selection
isOptionalSelection = true
}
public init(
_ label: String = "Date",
selection: Binding<Date?>
) {
self.label = label
_selection = .constant(Date())
_optionalSelection = selection
isOptionalSelection = true
}

public var body: some View {
VStack(alignment: .leading, spacing: .xSmall) {
if fieldPlaceholderPosition == .adjacent {
HStack {
public var body: some View {
VStack(alignment: .leading, spacing: .xSmall) {
if fieldPlaceholderPosition == .adjacent {
HStack {
Text(label)
.subheadline(.medium)
.foregroundColor(.onSurfaceHighEmphasis)
Spacer()
}
}
Button {
showModal.toggle()
} label: {
VStack(alignment: .leading, spacing: .xxxSmall) {
if fieldPlaceholderPosition == .overInput {
Text(label)
.subheadline(.medium)
.foregroundColor(.onSurfaceHighEmphasis)
Spacer()
.font(.subheadline)
.fontWeight(.semibold)
.onSurfaceDisabledForegroundColor()
}
}
Button {
showModal.toggle()
} label: {
VStack(alignment: .leading, spacing: .xxxSmall) {
if fieldPlaceholderPosition == .overInput {
Text(label)
.font(.subheadline)
.fontWeight(.semibold)
.onSurfaceDisabledForegroundColor()
}

HStack {
if isOptionalSelection, let optionalSelection {
Text(optionalSelection.formatted(date: .long, time: .shortened))
} else if isOptionalSelection {
Text(label)
} else {
Text(selection.formatted(date: .long, time: .shortened))
}
Spacer()
Icons.Base.calendar.outline
// Icon(.calendar, color: .onSurfaceHighEmphasis)
HStack {
if isOptionalSelection, let optionalSelection {
Text(optionalSelection.formatted(date: .long, time: .shortened))
} else if isOptionalSelection {
Text(label)
} else {
Text(selection.formatted(date: .long, time: .shortened))
}
Spacer()
Image.Base.calendar
}
}
.buttonStyle(.field)
}
.sheet(isPresented: $showModal) {
if isOptionalSelection {
DatePickerSheet(title: label, selection: $optionalSelection)
.presentationDetents([.height(500)])
.presentationDragIndicator(.hidden)
} else {
DatePickerSheet(title: label, selection: $selection)
.presentationDetents([.height(500)])
.presentationDragIndicator(.hidden)
}
.buttonStyle(.field)
}
.sheet(isPresented: $showModal) {
if isOptionalSelection {
DatePickerSheet(title: label, selection: $optionalSelection)
.presentationDetents([.height(500)])
.presentationDragIndicator(.hidden)
} else {
DatePickerSheet(title: label, selection: $selection)
.presentationDetents([.height(500)])
.presentationDragIndicator(.hidden)
}
}
}
}
#endif
Expand Up @@ -47,7 +47,7 @@ public struct DatePickerSheet: View {
.padding(.horizontal, .small)
.padding(.vertical, .xxxSmall)
}
.surfaceContentInsets(.zero)
.surfaceContentMargins(.zero)
}
.backgroundSecondary()
.leadingBar {
Expand Down
36 changes: 18 additions & 18 deletions Sources/OversizeUI/Controls/PhoneField/PhoneField.swift
Expand Up @@ -6,26 +6,26 @@
import SwiftUI

#if os(iOS)
@available(iOS 15.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
public struct PhoneField: View {
@Binding private var phone: String
@available(iOS 15.0, *)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
public struct PhoneField: View {
@Binding private var phone: String

@State private var textFieldHelper: FieldHelperStyle = .none
@State private var textFieldHelper: FieldHelperStyle = .none

public init(_ phone: Binding<String>) {
_phone = phone
}
public init(_ phone: Binding<String>) {
_phone = phone
}

public var body: some View {
TextField("+1 (000) 000 0000", text: $phone, onEditingChanged: { _ in
textFieldHelper = .none
}) {}
.keyboardType(.phonePad)
.textContentType(.nickname)
.fieldHelper(.constant("Invalid Phone"), style: $textFieldHelper)
}
public var body: some View {
TextField("+1 (000) 000 0000", text: $phone, onEditingChanged: { _ in
textFieldHelper = .none
}) {}
.keyboardType(.phonePad)
.textContentType(.nickname)
.fieldHelper(.constant("Invalid Phone"), style: $textFieldHelper)
}
}
#endif
26 changes: 13 additions & 13 deletions Sources/OversizeUI/Controls/PriceField/PriceField.swift
Expand Up @@ -18,20 +18,20 @@ public struct PriceField: View {

public var body: some View {
#if os(iOS)
TextField(
"0",
value: $amount,
format: .currency(code: currency.identifier)
)
.keyboardType(.decimalPad)
.textFieldStyle(.default)
TextField(
"0",
value: $amount,
format: .currency(code: currency.identifier)
)
.keyboardType(.decimalPad)
.textFieldStyle(.default)
#else
TextField(
"0",
value: $amount,
format: .currency(code: currency.identifier)
)
.textFieldStyle(.default)
TextField(
"0",
value: $amount,
format: .currency(code: currency.identifier)
)
.textFieldStyle(.default)
#endif
}
}
2 changes: 1 addition & 1 deletion Sources/OversizeUI/Controls/Radio/Radio.swift
Expand Up @@ -11,7 +11,7 @@ public enum RadioAlignment {

public struct Radio<Label: View>: View {
@Environment(\.isEnabled) private var isEnabled: Bool
@Environment(\.rowContentInset) private var contentInset: EdgeSpaceInsets
@Environment(\.rowContentMargins) private var contentInset: EdgeSpaceInsets
private var isOn: Bool
private let label: () -> Label?
private let alignment: RadioAlignment
Expand Down
27 changes: 4 additions & 23 deletions Sources/OversizeUI/Controls/Row/Row.swift
Expand Up @@ -12,7 +12,7 @@ public enum RowClearIconStyle {
public struct Row<LeadingLabel, TrailingLabel>: View where LeadingLabel: View, TrailingLabel: View {
@Environment(\.elevation) private var elevation: Elevation
@Environment(\.controlRadius) var controlRadius: Radius
@Environment(\.rowContentInset) var controlPadding: EdgeSpaceInsets
@Environment(\.rowContentMargins) var controlMargins: EdgeSpaceInsets
@Environment(\.multilineTextAlignment) var multilineTextAlignment
@Environment(\.isPremium) var premiumStatus
@Environment(\.isAccent) var isAccent
Expand Down Expand Up @@ -127,12 +127,12 @@ public struct Row<LeadingLabel, TrailingLabel>: View where LeadingLabel: View, T
.padding(.leading, .xxSmall)

if isShowArrowIcon {
Icons.Base.arrowRight2.outline
Image.Base.chevronRight
.icon(.onSurfaceDisabled)
}
}
}
.padding(controlPadding)
.padding(controlMargins)
}

private var text: some View {
Expand Down Expand Up @@ -233,32 +233,13 @@ public extension Row {
public extension View {
func rowOnSurface(_ elevation: Elevation = .z4, backgroundColor: Color? = nil) -> some View {
Surface {
self.rowContentInset(.zero)
self.rowContentMargins(.zero)
}
.surfaceBackgroundColor(backgroundColor)
.elevation(elevation)
}
}

// MARK: - Icon init

public extension Row where LeadingLabel == Icon, TrailingLabel: View {
init(_ title: String,
subtitle: String? = nil,
action: (() -> Void)? = nil,
@ViewBuilder leading: () -> LeadingLabel,
@ViewBuilder trailing: () -> TrailingLabel)
{
self.title = title
self.subtitle = subtitle
self.action = action
leadingLabel = leading()
trailingLabel = trailing()
leadingSize = nil
leadingRadius = nil
}
}

// MARK: - Image init

public extension Row where LeadingLabel == Image, TrailingLabel == EmptyView {
Expand Down
4 changes: 2 additions & 2 deletions Sources/OversizeUI/Controls/Row/RowButton.swift
Expand Up @@ -13,7 +13,7 @@ public enum RowButtonStyle {

public struct RowButton: View {
@Environment(\.multilineTextAlignment) var multilineTextAlignment
@Environment(\.controlPadding) var controlPadding: ControlPadding
@Environment(\.controlMargin) var controlPadding: ControlMargin
public var text: String
public var style: RowButtonStyle
public var icon: IconsNames
Expand Down Expand Up @@ -43,7 +43,7 @@ public struct RowButton: View {
IconDeprecated(icon)
}
.surfaceStyle(.secondary)
.surfaceContentInsets(.xxSmall)
.surfaceContentMargins(.xxSmall)
}

Text(text)
Expand Down
4 changes: 2 additions & 2 deletions Sources/OversizeUI/Controls/SectionView/SectionView.swift
Expand Up @@ -25,8 +25,8 @@ public enum SectionViewStyle {
public struct SectionView<Content: View>: View {
@Environment(\.controlRadius) private var controlRadius: Radius
@Environment(\.sectionViewStyle) private var style: SectionViewStyle
@Environment(\.surfaceContentInsets) var surfaceContentInsets: EdgeSpaceInsets
@Environment(\.sectionTitleInsets) var sectionTitleInsets: EdgeSpaceInsets
@Environment(\.surfaceContentMargins) var surfaceContentInsets: EdgeSpaceInsets
@Environment(\.sectionTitleMargins) var sectionTitleInsets: EdgeSpaceInsets
#if os(iOS)
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
#endif
Expand Down
Expand Up @@ -9,7 +9,7 @@ public struct SegmentedPickerSelector<Element: Equatable, Content, Selection>: V
@Environment(\.theme) private var theme: ThemeSettings
@Environment(\.segmentedControlStyle) private var style
@Environment(\.controlRadius) var controlRadius: Radius
@Environment(\.segmentedPickerInsets) var controlPadding: EdgeSpaceInsets
@Environment(\.segmentedPickerMargins) var controlPadding: EdgeSpaceInsets

public typealias Data = [Element]

Expand Down
2 changes: 1 addition & 1 deletion Sources/OversizeUI/Controls/Surface/MaterialSurface.swift
Expand Up @@ -12,7 +12,7 @@ public struct MaterialSurface<Label: View>: View {
@Environment(\.elevation) private var elevation: Elevation
@Environment(\.theme) private var theme: ThemeSettings
@Environment(\.controlRadius) var controlRadius: Radius
@Environment(\.surfaceContentInsets) var controlPadding: EdgeSpaceInsets
@Environment(\.surfaceContentMargins) var controlPadding: EdgeSpaceInsets

private let label: Label
private let action: (() -> Void)?
Expand Down

0 comments on commit 89a0707

Please sign in to comment.