Skip to content

Commit

Permalink
update tab size to 4 to match company default
Browse files Browse the repository at this point in the history
  • Loading branch information
lkzhao committed Apr 21, 2022
1 parent 5e172dd commit e03d369
Show file tree
Hide file tree
Showing 82 changed files with 3,780 additions and 3,761 deletions.
4 changes: 2 additions & 2 deletions .swift-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"accessLevel" : "private"
},
"indentation" : {
"spaces" : 2
"spaces" : 4
},
"indentConditionalCompilationBlocks" : true,
"indentSwitchCaseLabels" : false,
Expand Down Expand Up @@ -49,6 +49,6 @@
"UseTripleSlashForDocumentationComments" : true,
"ValidateDocumentationComments" : false
},
"tabWidth" : 8,
"tabWidth" : 4,
"version" : 1
}
68 changes: 34 additions & 34 deletions Examples/UIComponentExample/Examples/AsyncImage/AsyncImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,42 @@ import UIKit

public struct AsyncImage: ViewComponentBuilder {

public typealias AsyncIndicatorType = IndicatorType
public typealias ConfigurationBuilder = (KF.Builder) -> KF.Builder
public typealias AsyncIndicatorType = IndicatorType
public typealias ConfigurationBuilder = (KF.Builder) -> KF.Builder

public let url: URL?
public let indicatorType: AsyncIndicatorType
public let configurationBuilder: ConfigurationBuilder?
public let url: URL?
public let indicatorType: AsyncIndicatorType
public let configurationBuilder: ConfigurationBuilder?

public init(
_ url: URL?,
indicatorType: AsyncIndicatorType = .none,
configurationBuilder: ConfigurationBuilder? = nil
) {
self.url = url
self.indicatorType = indicatorType
self.configurationBuilder = configurationBuilder
}
public init(
_ url: URL?,
indicatorType: AsyncIndicatorType = .none,
configurationBuilder: ConfigurationBuilder? = nil
) {
self.url = url
self.indicatorType = indicatorType
self.configurationBuilder = configurationBuilder
}

public init(
_ urlString: String,
indicatorType: AsyncIndicatorType = .none,
configurationBuilder: ConfigurationBuilder? = nil
) {
self.url = URL(string: urlString)
self.indicatorType = indicatorType
self.configurationBuilder = configurationBuilder
}
public init(
_ urlString: String,
indicatorType: AsyncIndicatorType = .none,
configurationBuilder: ConfigurationBuilder? = nil
) {
self.url = URL(string: urlString)
self.indicatorType = indicatorType
self.configurationBuilder = configurationBuilder
}

public func build() -> ViewUpdateComponent<SimpleViewComponent<UIImageView>> {
SimpleViewComponent<UIImageView>()
.update {
$0.kf.indicatorType = indicatorType
if let configurationBuilder = configurationBuilder {
configurationBuilder(KF.url(url)).set(to: $0)
} else {
KF.url(url).set(to: $0)
}
}
}
public func build() -> ViewUpdateComponent<SimpleViewComponent<UIImageView>> {
SimpleViewComponent<UIImageView>()
.update {
$0.kf.indicatorType = indicatorType
if let configurationBuilder = configurationBuilder {
configurationBuilder(KF.url(url)).set(to: $0)
} else {
KF.url(url).set(to: $0)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,94 +4,94 @@ import UIComponent
import UIKit

struct ImageData {
let url: URL
let size: CGSize
let url: URL
let size: CGSize
}

class AsyncImageViewController: ComponentViewController {
var images = [
ImageData(
url: URL(string: "https://unsplash.com/photos/Yn0l7uwBrpw/download?force=true&w=640")!,
size: CGSize(width: 640, height: 360)
),
ImageData(
url: URL(string: "https://unsplash.com/photos/J4-xolC4CCU/download?force=true&w=640")!,
size: CGSize(width: 640, height: 800)
),
ImageData(
url: URL(string: "https://unsplash.com/photos/biggKnv1Oag/download?force=true&w=640")!,
size: CGSize(width: 640, height: 434)
),
ImageData(
url: URL(string: "https://unsplash.com/photos/MR2A97jFDAs/download?force=true&w=640")!,
size: CGSize(width: 640, height: 959)
),
ImageData(
url: URL(string: "https://unsplash.com/photos/oaCnDk89aho/download?force=true&w=640")!,
size: CGSize(width: 640, height: 426)
),
ImageData(
url: URL(string: "https://unsplash.com/photos/MOfETox0bkE/download?force=true&w=640")!,
size: CGSize(width: 640, height: 426)
),
] {
didSet {
reloadComponent()
var images = [
ImageData(
url: URL(string: "https://unsplash.com/photos/Yn0l7uwBrpw/download?force=true&w=640")!,
size: CGSize(width: 640, height: 360)
),
ImageData(
url: URL(string: "https://unsplash.com/photos/J4-xolC4CCU/download?force=true&w=640")!,
size: CGSize(width: 640, height: 800)
),
ImageData(
url: URL(string: "https://unsplash.com/photos/biggKnv1Oag/download?force=true&w=640")!,
size: CGSize(width: 640, height: 434)
),
ImageData(
url: URL(string: "https://unsplash.com/photos/MR2A97jFDAs/download?force=true&w=640")!,
size: CGSize(width: 640, height: 959)
),
ImageData(
url: URL(string: "https://unsplash.com/photos/oaCnDk89aho/download?force=true&w=640")!,
size: CGSize(width: 640, height: 426)
),
ImageData(
url: URL(string: "https://unsplash.com/photos/MOfETox0bkE/download?force=true&w=640")!,
size: CGSize(width: 640, height: 426)
),
] {
didSet {
reloadComponent()
}
}
}

override var component: Component {
Waterfall(columns: 2, spacing: 1) {
for (index, image) in images.enumerated() {
AsyncImage(image.url)
.size(width: .fill, height: .aspectPercentage(image.size.height / image.size.width))
.tappableView {
let detailVC = AsyncImageDetailViewController()
detailVC.image = image
$0.parentViewController?.navigationController?.pushViewController(detailVC, animated: true)
}
.previewBackgroundColor(.systemBackground.withAlphaComponent(0.7))
.previewProvider {
let detailVC = AsyncImageDetailViewController()
detailVC.image = image
detailVC.preferredContentSize = image.size
detailVC.view.backgroundColor = .clear
return detailVC
}
.contextMenuProvider { [weak self] in
UIMenu(children: [
UIAction(
title: "Delete",
image: UIImage(systemName: "trash"),
attributes: [.destructive],
handler: { action in
self?.images.remove(at: index)
}
)
])
}
.id(image.url.absoluteString)
}
override var component: Component {
Waterfall(columns: 2, spacing: 1) {
for (index, image) in images.enumerated() {
AsyncImage(image.url)
.size(width: .fill, height: .aspectPercentage(image.size.height / image.size.width))
.tappableView {
let detailVC = AsyncImageDetailViewController()
detailVC.image = image
$0.parentViewController?.navigationController?.pushViewController(detailVC, animated: true)
}
.previewBackgroundColor(.systemBackground.withAlphaComponent(0.7))
.previewProvider {
let detailVC = AsyncImageDetailViewController()
detailVC.image = image
detailVC.preferredContentSize = image.size
detailVC.view.backgroundColor = .clear
return detailVC
}
.contextMenuProvider { [weak self] in
UIMenu(children: [
UIAction(
title: "Delete",
image: UIImage(systemName: "trash"),
attributes: [.destructive],
handler: { action in
self?.images.remove(at: index)
}
)
])
}
.id(image.url.absoluteString)
}
}
}
}

override func viewDidLoad() {
super.viewDidLoad()
componentView.animator = AnimatedReloadAnimator()
title = "Async Image"
}
override func viewDidLoad() {
super.viewDidLoad()
componentView.animator = AnimatedReloadAnimator()
title = "Async Image"
}
}

class AsyncImageDetailViewController: ComponentViewController {
var image: ImageData!
var image: ImageData!

override var component: Component {
VStack {
AsyncImage(image.url)
.size(width: .fill, height: .aspectPercentage(image.size.height / image.size.width))
.tappableView {
$0.parentViewController?.navigationController?.popViewController(animated: true)
override var component: Component {
VStack {
AsyncImage(image.url)
.size(width: .fill, height: .aspectPercentage(image.size.height / image.size.width))
.tappableView {
$0.parentViewController?.navigationController?.popViewController(animated: true)
}
}
}
}
}
Loading

0 comments on commit e03d369

Please sign in to comment.