Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

Commit da2abee

Browse files
authored
Merge pull request #1 from space-squad/develop
UIKit Components v.1.0.0
2 parents 6e3ed78 + f9d73db commit da2abee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2166
-80
lines changed

Diff for: .github/README.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# UIKit Components Package
2+
3+
This repository contains basic components for setting up UIKit components programmatically.
4+
5+
It is made by **[SPACE SQUAD](https://www.spacesquad.de)**! We make great software with ♥️ in Berlin.
6+
7+
<img src="assets/README-spacesquad_logo_full.png" width="120">
8+
9+
---
10+
11+
## Content
12+
- [Features](#features)
13+
- [Screenshots](#screenshots)
14+
- [Installation](#installation)
15+
- [How to Use](#how-to-use)
16+
17+
18+
## Features
19+
This package contains extensions for easily setting up AutoLayout as well as basic components to simplify initializing programmatic UI components with UIKit.
20+
21+
**Extensions**
22+
- [x] Constraining components (with optional custom padding)
23+
- [x] Constrain views to fill their superview (with optional custom padding)
24+
- [x] Constrain a view as a square
25+
- [x] Set width or height of a views
26+
- [x] Set inner padding for a UITextField
27+
28+
**Components**
29+
- [x] BaseNavigationController (to easily override status bar color)
30+
- [x] BaseCollectionViewController (to support Flow Layout and orientation change on iPad)
31+
- [x] BaseButtonWithImage
32+
- [x] BaseButtonWithText
33+
- [x] BaseImageView
34+
- [x] BaseLabel
35+
- [x] BaseStackView
36+
- [x] BaseTextField
37+
- [x] BaseTextView
38+
- [x] BaseView
39+
40+
41+
## Screenshots
42+
<img src="assets/README-examples.png" width="300">
43+
44+
45+
## Installation
46+
##### Requirements
47+
- iOS 15.0+
48+
- Xcode 13+
49+
- Swift 5+
50+
51+
##### Swift Package Manager
52+
In Xcode, go to `File > Add Packages` and add `https://github.com/space-squad/uikit-components`. Add the package to all your targets.
53+
54+
55+
## How to Use
56+
Extensions and components can be accessed by declaring `import UIKitComponents` on top of your file. All components are named after the same schema, like `Base<Component>`. To see available components, check out the list above, look at the appended screenshot or check out the example project. There is no further setup needed.
57+
58+
All views have custom initializers to set properties of your view, some of which are required. Please check our example project on how to implement the components and use the extensions.
59+
60+
In addition, we added custom delegates to **BaseTextView** and **BaseTextField** to support subscribing to whether they are currently in editing mode and to continously read the user's input. See the example code on how to subscribe to their values using the Combine framework.

Diff for: .github/assets/README-examples.png

148 KB
Loading

Diff for: .github/assets/README-spacesquad_logo_full.png

47.8 KB
Loading

Diff for: .gitignore

+40-78
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,7 @@
11
# Xcode
2-
#
3-
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4-
52
## User settings
63
xcuserdata/
7-
8-
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
9-
*.xcscmblueprint
10-
*.xccheckout
11-
12-
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
13-
build/
14-
DerivedData/
15-
*.moved-aside
16-
*.pbxuser
17-
!default.pbxuser
18-
*.mode1v3
19-
!default.mode1v3
20-
*.mode2v3
21-
!default.mode2v3
22-
*.perspectivev3
23-
!default.perspectivev3
4+
Package.resolved
245

256
## Obj-C/Swift specific
267
*.hmap
@@ -30,61 +11,42 @@ DerivedData/
3011
*.dSYM.zip
3112
*.dSYM
3213

33-
## Playgrounds
34-
timeline.xctimeline
35-
playground.xcworkspace
36-
37-
# Swift Package Manager
38-
#
39-
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
40-
# Packages/
41-
# Package.pins
42-
# Package.resolved
43-
# *.xcodeproj
44-
#
45-
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
46-
# hence it is not needed unless you have added a package configuration file to your project
47-
# .swiftpm
48-
49-
.build/
50-
51-
# CocoaPods
52-
#
53-
# We recommend against adding the Pods directory to your .gitignore. However
54-
# you should judge for yourself, the pros and cons are mentioned at:
55-
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
56-
#
57-
# Pods/
58-
#
59-
# Add this line if you want to avoid checking in source code from the Xcode workspace
60-
# *.xcworkspace
61-
62-
# Carthage
63-
#
64-
# Add this line if you want to avoid checking in source code from Carthage dependencies.
65-
# Carthage/Checkouts
66-
67-
Carthage/Build/
68-
69-
# Accio dependency management
70-
Dependencies/
71-
.accio/
72-
73-
# fastlane
74-
#
75-
# It is recommended to not store the screenshots in the git repo.
76-
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
77-
# For more information about the recommended setup visit:
78-
# https://docs.fastlane.tools/best-practices/source-control/#source-control
79-
80-
fastlane/report.xml
81-
fastlane/Preview.html
82-
fastlane/screenshots/**/*.png
83-
fastlane/test_output
84-
85-
# Code Injection
86-
#
87-
# After new code Injection tools there's a generated folder /iOSInjectionProject
88-
# https://github.com/johnno1962/injectionforxcode
89-
90-
iOSInjectionProject/
14+
# Compiled source #
15+
###################
16+
*.com
17+
*.class
18+
*.dll
19+
*.exe
20+
*.o
21+
*.so
22+
23+
# Packages #
24+
############
25+
# it's better to unpack these files and commit the raw source
26+
# git has its own built in compression methods
27+
*.7z
28+
*.dmg
29+
*.gz
30+
*.iso
31+
*.jar
32+
*.rar
33+
*.tar
34+
*.zip
35+
36+
# Logs and databases #
37+
######################
38+
*.log
39+
*.sql
40+
*.sqlite
41+
42+
# OS generated files #
43+
######################
44+
.DS_Store
45+
.DS_Store?
46+
._*
47+
.Spotlight-V100
48+
.Trashes
49+
ehthumbs.db
50+
Thumbs.db
51+
52+
Pods/

Diff for: Package.swift

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// swift-tools-version: 5.6
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "UIKitComponents",
8+
platforms: [
9+
.iOS(.v15)
10+
],
11+
products: [
12+
// Products define the executables and libraries a package produces, and make them visible to other packages.
13+
.library(
14+
name: "UIKitComponents",
15+
targets: ["UIKitComponents"]),
16+
],
17+
targets: [
18+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
19+
// Targets can depend on other targets in this package, and on products in packages this package depends on.
20+
.target(
21+
name: "UIKitComponents",
22+
dependencies: []),
23+
]
24+
)

Diff for: README.md

-2
This file was deleted.

Diff for: Sources/UIKitComponents/Extensions/UITextField.swift

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// UITextField.swift
3+
//
4+
//
5+
// Created by Kevin Waltz on 02.09.22.
6+
//
7+
8+
import UIKit
9+
10+
public extension UITextField {
11+
/**
12+
Declare a vertical padding for text within a UITextField.
13+
14+
- Parameter left: Left padding
15+
- Parameter right: Right padding
16+
*/
17+
func setTextPadding(left: CGFloat, right: CGFloat) {
18+
let leftPaddingView = UIView(frame: CGRect(x: 0, y: 0, width: left, height: frame.size.height))
19+
leftView = leftPaddingView
20+
leftViewMode = .always
21+
22+
let rightPaddingView = UIView(frame: CGRect(x: 0, y: 0, width: right, height: frame.size.height))
23+
rightView = rightPaddingView
24+
rightViewMode = .always
25+
}
26+
}

0 commit comments

Comments
 (0)