iOS Components 由 Trendyol 应用开发团队为 iOS 构建。
“iOS Components” 包含多个由纯 swift 编写的 ios 自定义视图和辅助框架。由 Trendyol 的 iOS 应用开发团队开发。
为什么
旨在帮助社区中的 iOS 开发者用更少的努力构建美观且实用的 iOS 应用。
组件测试应用
您可以通过克隆仓库来查看名为 ComponentsTestApp 的测试应用。这里共享的所有组件也在测试应用中实现。
组件
以下是所有组件的简要总结。有关详细信息,请点击每个组件部分中提供的组件链接。
ImageSlider
基于自定义集合视图的无限循环滚动滑动组件
可缩放ImageView
提供了类似于Instagram的ImageView的全屏缩放功能。
自动完成UITextField
属性包装器
当你需要在DTO上使用枚举类型时,你需要确保所有的类型都能被确认。为此,你需要创建自定义初始化。使用这种实现,你再也不需要编写自定义初始化了。我们还认为在DTO上不需要使用可选的布尔值。因为当我们在代码中使用可选布尔值时,我们通常使用默认值。你可以在你的DTO中使用DefaultTrue或DefaultFalse包装器,如果该字段为nil,它将被设置默认值。
// With this implemantation you can be sure your code can't crash when new UserType added.
enum UserType: String, Codable {
case admin, user, none
public init(from decoder: Decoder) throws {
self = try UserType(rawValue: decoder.singleValueContainer().decode(RawValue.self)) ?? .none
}
}
// With This Property Wrapper you can set Default value for UserType. You can set default value with LastCase or FirstCase.
// Also With DefaultFalse or DefaultTrue you can save your code from `UserResponse.isAdmin ?? false`
enum UserType: String, EnumDefaultValueSelectable {
case admin, user, none
}
struct UserResponse: Codable {
@DefaultCodable<LastCase> var user: UserType
@DefaultCodable<DefaultFalse> var isAdmin: Bool
}
连续分页视图
自定义具有分页实现的集合视图,确保所有页面都填充了相同数量的项目。
许可证
Copyright 2019 Trendyol.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://apache.ac.cn/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.