Skip to content

v1.5.1 #84

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

Draft
wants to merge 68 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
aedb812
SUButton new params
VislovIvan Apr 3, 2025
f3949d5
image fix
VislovIvan Apr 3, 2025
9e5d302
improve UKButton
VislovIvan Apr 3, 2025
68848a0
swiftlint fix
VislovIvan Apr 3, 2025
572135f
code style fix
VislovIvan Apr 6, 2025
6ac6171
shouldUpdateSize fix
VislovIvan Apr 6, 2025
ffd1d59
extension ImageSource and ImageLocation extracted
VislovIvan Apr 6, 2025
3171a79
rename extension buttonImage
VislovIvan Apr 6, 2025
f9bd154
params in alphabetical order
VislovIvan Apr 6, 2025
f316b55
fix some logic
VislovIvan Apr 6, 2025
8627341
fix uikit bug
VislovIvan Apr 6, 2025
31cc411
local image size bug fix
VislovIvan Apr 6, 2025
f74bf7b
added contentSpacing into preview
VislovIvan Apr 6, 2025
f48ce2c
hide title toggle
VislovIvan Apr 6, 2025
9923987
imageView contentMode
VislovIvan Apr 7, 2025
74e1bf1
swiftui image size bug fix
VislovIvan Apr 7, 2025
6a90b2b
preview "if" deleted
VislovIvan Apr 7, 2025
d97a971
deleted unused code
VislovIvan Apr 7, 2025
ef33dcd
fix constraints
VislovIvan Apr 7, 2025
29a2e9b
intrinsicContentSize fix
VislovIvan Apr 7, 2025
1af1227
uikit component code restructurization
VislovIvan Apr 7, 2025
9448544
image tint color extracted into model
VislovIvan Apr 7, 2025
19a71e6
func updateUIView fix
VislovIvan Apr 7, 2025
97622af
image extension fix
VislovIvan Apr 7, 2025
14d93ad
ImageLocation extracted
VislovIvan Apr 7, 2025
8971daa
fix spacing white titleLabel is hidden
VislovIvan Apr 7, 2025
5058c92
deleted if/else from swiftui component
VislovIvan Apr 7, 2025
0b523e4
fix tint color to local image
VislovIvan Apr 7, 2025
5cfdf75
fix preview sort
VislovIvan Apr 8, 2025
f3a2ee2
code fix
VislovIvan Apr 8, 2025
073f1ef
fix image size updating
VislovIvan Apr 8, 2025
9243dcd
some fix stackView
VislovIvan Apr 8, 2025
ae6e9c5
tint color fix
VislovIvan Apr 8, 2025
3ff5b27
fix imageView location bug
VislovIvan Apr 8, 2025
04ea424
improvements and bug fixes
mikhailChelbaev Apr 8, 2025
183b632
Merge pull request #83 from componentskit/improve-button
mikhailChelbaev Apr 8, 2025
bc5e1b3
change checkbox and checkmark sizes
mikhailChelbaev Apr 17, 2025
a799001
change checkmark line width
mikhailChelbaev Apr 17, 2025
4724c84
Merge branch 'dev' into improve-checkbox
mikhailChelbaev Apr 17, 2025
34f9d46
Merge branch 'main' into dev
mikhailChelbaev Apr 17, 2025
0e99fb5
Merge branch 'dev' into improve-checkbox
mikhailChelbaev Apr 17, 2025
9d5e14d
add `borderColor` param to `CardVM`
mikhailChelbaev Apr 17, 2025
4597913
make card components tappable
mikhailChelbaev Apr 17, 2025
329ac0f
Merge pull request #86 from componentskit/improve-checkbox
mikhailChelbaev Apr 18, 2025
d159ace
Merge pull request #87 from componentskit/improve-card
mikhailChelbaev Apr 18, 2025
71adcf1
add no focus init to `SUInputField`
mikhailChelbaev Apr 18, 2025
a7b57ee
add no focus init to `SUTextInput`
mikhailChelbaev Apr 18, 2025
ca0ee89
fix text container paddings in `UKTextInput` for ios 16
mikhailChelbaev Apr 18, 2025
4317b07
add `TitlePosition` param to `InputFieldVM` and implement in `SUInput…
mikhailChelbaev Apr 18, 2025
0a1554b
add bordered style for input field
mikhailChelbaev Apr 22, 2025
0a9ca09
update `UKInputField` to support `titlePosition`
mikhailChelbaev Apr 23, 2025
9f07a7b
Merge pull request #88 from componentskit/no-focus-inits
mikhailChelbaev Apr 23, 2025
8efeeca
add caption and titleFont for input fields
mikhailChelbaev Apr 23, 2025
4dddef4
add faded style for input fields
mikhailChelbaev Apr 23, 2025
07af638
add missing docs
mikhailChelbaev Apr 23, 2025
7c467a6
improve docs in `UKInputField`
mikhailChelbaev Apr 23, 2025
b559dc8
improve `UKInputField` docs
mikhailChelbaev Apr 23, 2025
baa06b2
remove commas from last params
mikhailChelbaev Apr 23, 2025
5cd211e
change a color of a star sign when the input field is disabled
mikhailChelbaev Apr 23, 2025
e84ffd6
Merge pull request #89 from componentskit/improve-input-field
mikhailChelbaev Apr 23, 2025
8dbba1e
add a shared `InputStyle` enum
mikhailChelbaev Apr 23, 2025
3d82608
add styles to text input
mikhailChelbaev Apr 23, 2025
4653a34
fix text input layout bug
mikhailChelbaev Apr 24, 2025
b68f23b
add minimal button style
mikhailChelbaev Apr 24, 2025
caf0a63
update `UKAlertController` to properly display buttons with `minimal`…
mikhailChelbaev Apr 27, 2025
6641e46
add `ButtonStylePicker` helper
mikhailChelbaev Apr 27, 2025
aed772d
Merge pull request #90 from componentskit/improve-text-input
mikhailChelbaev Apr 28, 2025
e4cff7c
Merge pull request #91 from componentskit/new-button-styles
mikhailChelbaev Apr 28, 2025
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 @@ -23,7 +23,7 @@ struct AutocapitalizationPicker: View {
@Binding var selection: TextAutocapitalization

var body: some View {
Picker("Autocapitalization", selection: $selection) {
Picker("Autocapitalization", selection: self.$selection) {
Text("Never").tag(TextAutocapitalization.never)
Text("Characters").tag(TextAutocapitalization.characters)
Text("Words").tag(TextAutocapitalization.words)
Expand All @@ -36,7 +36,7 @@ struct AutocapitalizationPicker: View {

struct BorderWidthPicker: View {
@Binding var selection: BorderWidth

var body: some View {
Picker("Border Width", selection: self.$selection) {
Text("None").tag(BorderWidth.none)
Expand All @@ -47,6 +47,22 @@ struct BorderWidthPicker: View {
}
}

struct ButtonStylePicker: View {
@Binding var selection: ComponentsKit.ButtonStyle

var body: some View {
Picker("Style", selection: $selection) {
Text("Filled").tag(ButtonStyle.filled)
Text("Plain").tag(ButtonStyle.plain)
Text("Light").tag(ButtonStyle.light)
Text("Minimal").tag(ButtonStyle.minimal)
Text("Bordered with small border").tag(ButtonStyle.bordered(.small))
Text("Bordered with medium border").tag(ButtonStyle.bordered(.medium))
Text("Bordered with large border").tag(ButtonStyle.bordered(.large))
}
}
}

// MARK: - ComponentColorPicker

struct ComponentColorPicker: View {
Expand Down Expand Up @@ -203,13 +219,25 @@ struct CaptionFontPicker: View {
}
}

struct InputStylePicker: View {
@Binding var selection: InputStyle

var body: some View {
Picker("Style", selection: self.$selection) {
Text("Light").tag(InputStyle.light)
Text("Bordered").tag(InputStyle.bordered)
Text("Faded").tag(InputStyle.faded)
}
}
}

// MARK: - KeyboardTypePicker

struct KeyboardTypePicker: View {
@Binding var selection: UIKeyboardType

var body: some View {
Picker("Keyboard Type", selection: $selection) {
Picker("Keyboard Type", selection: self.$selection) {
Text("Default").tag(UIKeyboardType.default)
Text("asciiCapable").tag(UIKeyboardType.asciiCapable)
Text("numbersAndPunctuation").tag(UIKeyboardType.numbersAndPunctuation)
Expand Down Expand Up @@ -260,7 +288,7 @@ struct SubmitTypePicker: View {
@Binding var selection: SubmitType

var body: some View {
Picker("Submit Type", selection: $selection) {
Picker("Submit Type", selection: self.$selection) {
Text("done").tag(SubmitType.done)
Text("go").tag(SubmitType.go)
Text("join").tag(SubmitType.join)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,7 @@ struct AlertPreview: View {
ComponentRadiusPicker(selection: buttonVM.cornerRadius) {
Text("Custom: 20px").tag(ComponentRadius.custom(20))
}
Picker("Style", selection: buttonVM.style) {
Text("Filled").tag(ButtonStyle.filled)
Text("Plain").tag(ButtonStyle.plain)
Text("Light").tag(ButtonStyle.light)
Text("Bordered with small border").tag(ButtonStyle.bordered(.small))
Text("Bordered with medium border").tag(ButtonStyle.bordered(.medium))
Text("Bordered with large border").tag(ButtonStyle.bordered(.large))
}
ButtonStylePicker(selection: buttonVM.style)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import SwiftUI
import UIKit

struct ButtonPreview: View {
private static let title = "Button"
@State private var model = ButtonVM {
$0.title = "Button"
$0.title = Self.title
}

var body: some View {
VStack {
PreviewWrapper(title: "UIKit") {
Expand All @@ -19,21 +20,35 @@ struct ButtonPreview: View {
Form {
AnimationScalePicker(selection: self.$model.animationScale)
ComponentOptionalColorPicker(selection: self.$model.color)
Picker("Content Spacing", selection: self.$model.contentSpacing) {
Text("4").tag(CGFloat(4))
Text("8").tag(CGFloat(8))
Text("12").tag(CGFloat(12))
}
ComponentRadiusPicker(selection: self.$model.cornerRadius) {
Text("Custom: 20px").tag(ComponentRadius.custom(20))
}
ButtonFontPicker(selection: self.$model.font)
Toggle("Enabled", isOn: self.$model.isEnabled)
ButtonFontPicker(selection: self.$model.font)
Toggle("Full Width", isOn: self.$model.isFullWidth)
SizePicker(selection: self.$model.size)
Picker("Style", selection: self.$model.style) {
Text("Filled").tag(ButtonStyle.filled)
Text("Plain").tag(ButtonStyle.plain)
Text("Light").tag(ButtonStyle.light)
Text("Bordered with small border").tag(ButtonStyle.bordered(.small))
Text("Bordered with medium border").tag(ButtonStyle.bordered(.medium))
Text("Bordered with large border").tag(ButtonStyle.bordered(.large))
Picker("Image Location", selection: self.$model.imageLocation) {
Text("Leading").tag(ButtonVM.ImageLocation.leading)
Text("Trailing").tag(ButtonVM.ImageLocation.trailing)
}
Picker("Image Source", selection: self.$model.imageSrc) {
Text("SF Symbol").tag(ButtonVM.ImageSource.sfSymbol("camera.fill"))
Text("Local").tag(ButtonVM.ImageSource.local("avatar_placeholder"))
Text("None").tag(Optional<ButtonVM.ImageSource>.none)
}
Toggle("Loading", isOn: self.$model.isLoading)
Toggle("Show Title", isOn: Binding<Bool>(
get: { !self.model.title.isEmpty },
set: { newValue in
self.model.title = newValue ? Self.title : ""
}
))
SizePicker(selection: self.$model.size)
ButtonStylePicker(selection: self.$model.style)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,24 @@ struct CardPreview: View {
SUCard(model: self.model, content: self.suCardContent)
}
Form {
AnimationScalePicker(selection: self.$model.animationScale)
Picker("Background Color", selection: self.$model.backgroundColor) {
Text("Default").tag(Optional<UniversalColor>.none)
Text("Background").tag(UniversalColor.background)
Text("Secondary Background").tag(UniversalColor.secondaryBackground)
Text("Accent Background").tag(UniversalColor.accentBackground)
Text("Success Background").tag(UniversalColor.successBackground)
Text("Warning Background").tag(UniversalColor.warningBackground)
Text("Danger Background").tag(UniversalColor.dangerBackground)
}
Picker("Border Color", selection: self.$model.borderColor) {
Text("Divider").tag(UniversalColor.divider)
Text("Primary").tag(UniversalColor.primary)
Text("Accent").tag(UniversalColor.accent)
Text("Success").tag(UniversalColor.success)
Text("Warning").tag(UniversalColor.warning)
Text("Danger").tag(UniversalColor.danger)
Text("Custom").tag(UniversalColor.universal(.uiColor(.systemPurple)))
}
BorderWidthPicker(selection: self.$model.borderWidth)
Picker("Content Paddings", selection: self.$model.contentPaddings) {
Text("12px").tag(Paddings(padding: 12))
Expand All @@ -39,6 +49,7 @@ struct CardPreview: View {
Text("Large").tag(Shadow.large)
Text("Custom").tag(Shadow.custom(20.0, .zero, UniversalColor.accentBackground))
}
Toggle("Tappable", isOn: self.$model.isTappable)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ struct InputFieldPreview: View {
Form {
AutocapitalizationPicker(selection: self.$model.autocapitalization)
Toggle("Autocorrection Enabled", isOn: self.$model.isAutocorrectionEnabled)
Toggle("Caption", isOn: .init(
get: {
return self.model.caption != nil
},
set: { newValue in
self.model.caption = newValue ? Self.caption : nil
}
))
CaptionFontPicker(title: "Caption Font", selection: self.$model.captionFont)
ComponentOptionalColorPicker(selection: self.$model.color)
ComponentRadiusPicker(selection: self.$model.cornerRadius) {
Text("Custom: 20px").tag(ComponentRadius.custom(20))
Expand All @@ -46,12 +55,13 @@ struct InputFieldPreview: View {
return self.model.placeholder != nil
},
set: { newValue in
self.model.placeholder = newValue ? "Placeholder" : nil
self.model.placeholder = newValue ? Self.placeholder : nil
}
))
Toggle("Required", isOn: self.$model.isRequired)
Toggle("Secure Input", isOn: self.$model.isSecureInput)
SizePicker(selection: self.$model.size)
InputStylePicker(selection: self.$model.style)
SubmitTypePicker(selection: self.$model.submitType)
UniversalColorPicker(
title: "Tint Color",
Expand All @@ -62,9 +72,14 @@ struct InputFieldPreview: View {
return self.model.title != nil
},
set: { newValue in
self.model.title = newValue ? "Title" : nil
self.model.title = newValue ? Self.title : nil
}
))
BodyFontPicker(title: "Title Font", selection: self.$model.titleFont)
Picker("Title Position", selection: self.$model.titlePosition) {
Text("Inside").tag(InputFieldVM.TitlePosition.inside)
Text("Outside").tag(InputFieldVM.TitlePosition.outside)
}
}
}
.toolbar {
Expand All @@ -79,9 +94,14 @@ struct InputFieldPreview: View {
}
}

private static let title = "Email"
private static let placeholder = "Enter your email"
private static let caption = "Your email address will be used to send a verification code"
private static var initialModel: InputFieldVM {
return .init {
$0.title = "Title"
$0.title = Self.title
$0.placeholder = Self.placeholder
$0.caption = Self.caption
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct TextInputPreviewPreview: View {
}
))
SizePicker(selection: self.$model.size)
InputStylePicker(selection: self.$model.style)
SubmitTypePicker(selection: self.$model.submitType)
UniversalColorPicker(
title: "Tint Color",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,14 @@ public class UKAlertController: UKCenterModalController {
self.buttonsStackView.removeArrangedSubview(self.secondaryButton)
self.buttonsStackView.insertArrangedSubview(self.secondaryButton, at: 0)
self.buttonsStackView.axis = .horizontal
self.buttonsStackView.distribution = .fillEqually
case .vertical:
self.buttonsStackView.axis = .vertical
self.buttonsStackView.distribution = .fillProportionally
}
} else {
self.buttonsStackView.axis = .vertical
self.buttonsStackView.distribution = .fillProportionally
}
}
}
Expand All @@ -173,7 +176,6 @@ extension UKAlertController {
}

static func buttonsStackView(_ stackView: UIStackView) {
stackView.distribution = .fillEqually
stackView.spacing = AlertVM.buttonsSpacing
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Foundation

/// Specifies the position of the image relative to the button's title.
extension ButtonVM {
public enum ImageLocation {
/// The image is displayed before the title.
case leading
/// The image is displayed after the title.
case trailing
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Foundation

/// Defines the image source options for a button.
extension ButtonVM {
public enum ImageSource: Hashable {
/// An image loaded from a system SF Symbol.
///
/// - Parameter name: The name of the SF Symbol.
case sfSymbol(String)

/// An image loaded from a local asset.
///
/// - Parameters:
/// - name: The name of the local image asset.
/// - bundle: The bundle containing the image resource. Defaults to `nil` to use the main bundle.
case local(String, bundle: Bundle? = nil)
}
}
Loading