I have been working on a little library that is a natural extension to the SwiftUI library. It adds very few new features to SwiftUI but addresses 3 key shortcomings that I feel are worth addressing.
SwiftUI is an open-source project that aims to provide a flexible, scalable, and well-documented canvas to quickly get started with the iOS UI design workflow. SwiftUI features a common core that is easily extended with custom controls, but can also be used with any other UI components. Over the course of the last few months, several people in the community have contributed extensions to the core SwiftUI library in various ways, but none in the same way as the one I’d like to present in this blog post.
The idea of writing this post was actually inspired by some code I saw some time ago. The code was meant to integrate the SwiftUI library, which is a UIKit based library, with some custom code. There are several ways of integrating libraries with your code, but some people may not be aware that you can easily import UI elements into your Swift code, and that you do not need to write any extra code.
SwiftUIX aims to address the gaps in the SwiftUI framework, which is still in its infancy, by offering a comprehensive set of components, extensions, and utilities to supplement the standard library. This project is by far the most comprehensive transfer of missing UIKit/AppKit features, aiming for the most Apple-like implementation feasible.
The aim of this project is to provide hundreds of extensions and views to the SwiftUI standard library, allowing you, the developer, to create apps with the simplicity promised by SwiftUI’s revolution.
- iOS 13, macOS 10.15, tvOS 13, or watchOS 6 are the latest versions of Apple’s operating system.
- Swift 5.3 is the latest version.
- Xcode 12.4+ is required.
The Swift Package Manager is the recommended method of installing SwiftUIX.
libSwiftPM is included into Xcode 11 to offer compatibility for the iOS, watchOS, macOS, and tvOS platforms.
- Open your project in Xcode and go to File Swift Packages. Dependency on a Package…
- Click Next after pasting the repository URL (https://github.com/SwiftUIX/SwiftUIX).
- Select Branch for Rules (with branch set to master).
- Finish by clicking the Finish button.
- Add SwiftUI.framework to the Linked Frameworks and Libraries and set Status to Optional in the Project settings.
The repository wiki has all documentation.
While the project is robust and widely used in production, the documentation is still in the works. Contributions are accepted and encouraged.
SwiftUI UIKit UIKit UIKit UIKit UIKit
UIKit | SwiftUI | SwiftUIX |
---|---|---|
LPLinkView | – | LinkPresentationView |
UIActivityIndicatorView | – | ActivityIndicator |
UIActivityViewController | – | AppActivityView |
UIBlurEffect | – | BlurEffectView |
UICollectionView | – | CollectionView |
UIDeviceOrientation | – | DeviceLayoutOrientation |
UIImagePickerController | – | ImagePicker |
UIPageViewController | – | PaginationView |
UIScreen | – | Screen |
UISearchBar | – | SearchBar |
UIScrollView | ScrollView | CocoaScrollView |
UISwipeGestureRecognizer | – | SwipeGestureOverlay |
UITableView | List | CocoaList |
UITextField | TextField | CocoaTextField |
UIModalPresentationStyle | – | ModalPresentationStyle |
UIViewControllerTransitioningDelegate | – | UIHostingControllerTransitioningDelegate |
UIVisualEffectView | – | VisualEffectView |
UIWindow | – | WindowOverlay |
Activity
-
ActivityIndicator
ActivityIndicator() is a function that calculates how active a user is. true(animated) style(.large)
-
UIActivityViewController has a SwiftUI port called AppActivityView.
AppActivityView(activityItems: […]) is a view of an app’s activities. excludeActivityTypes([…]) is a function that allows you to exclude certain types of activities. onCancel is a function that is called when a program is terminated. result in foo(result) onComplete
Appearance
- View/visible(_:) – Controls the visibility of a view.
Handling Errors
- TryButton – A button that can be used to conduct throwing actions.
Geometry
- flip3D( :axis:reverse:) – This perspective is flipped.
- RectangleCorner – A Rectangle’s corner.
- ZeroSizeView – A zero-size view for when EmptyView isn’t sufficient.
Keyboard
- The keyboard is represented by the object keyboard.
- Pads this view with the active system height of the keyboard. View/padding(.keyboard)- Pads this view with the active system height of the keyboard.
Presentation of the Link:
Navigation
- View/navigationBarColor(_:) – Sets the color of this view’s navigation bar.
- View/navigationBarTranslucent(_:) – Sets the navigation bar’s translucency for this view.
- View/navigation BarTransparent(_:) – Sets the navigation bar’s transparency for this view.
-
PaginationView
PaginationView(axis: .horizontal) { ForEach(0..<10, id: .hashValue) { index in Text(String(index)) } } .currentPageIndex($…) .pageIndicatorAlignment(…) .pageIndicatorTintColor(…) .currentPageIndicatorTintColor(…)
Scrolling
-
View/isScrollEnabled(_:) – Adds a condition that determines whether or not users may scroll in this view. Works well with:
- CocoaList
- CocoaScrollView
- CollectionView
- TextView
SwiftUI’s ScrollView does not function.
Search
-
UISearchBar is ported to SwiftUI as SearchBar.
@State var isEditing: Bool = false @State var isEditing: Bool = false @State var isEditing: Bool = false @State var isEditing: Boo searchText: String = “” State var searchText: String = “” body variable: some SearchBar(“Search…”, text: $searchText, isEditing: $isEditing) is an example of a search bar. isEditing). showsCancelButton(isEditing). onCancel print(“Canceled!”) onCancel print(“Canceled!”) onCancel print(“Canceled!”) onCancel print(“Canceled!”
-
View/navigation Sets the navigation search bar for this view. SearchBar(_:)
“Hello, world!” says the text. navigation SearchBar(“Placeholder”, text: $text) SearchBar(“Placeholder”, text: $text)
-
View/navigation When scrolling any underlying material, SearchBarHiddenWhenScrolling(_:) hides the integrated search bar.
Screen
- Screen – An image of the device’s display.
- UIUserInterfaceIdiom is ported to SwiftUI as UserInterfaceIdiom.
- UserInterfaceOrientation – UserInterfaceOrientation in SwiftUI.
Scroll
- ScrollIndicatorStyle – A type that defines how all scroll indicators in a view hierarchy look and interact.
- A scroll indicator style that conceals all scroll view indicators inside a view hierarchy is HiddenScrollViewIndicatorStyle.
The Status Bar displays information about your current status.
-
View/statusItem(id:image:) – Adds a status bar item that, when clicked, displays a popover.
“Hello, world!” says the text. image:.system(.exclamationmark)) statusItem(id: “foo”) statusItem(id: “foo”) statusItem(id: “foo”) statusItem(id: “f “Popover!” Text(“Popover!”) padding() is a function that is used to add padding to a
Text
Effects on the eye
Window
- View/windowOverlay(isKeyAndVisible:content:) – Creates a window key that is visible when a condition is met.
@vmanot is the creator of SwiftUIX.
GitHub
https://github.com/SwiftUIX/SwiftUIX
SwiftUI (formerly known as SwiftyUI) is a collection of components that makes it easy to build modern mobile apps. It leverages the popularity of iOS8’s native UI elements, but provides a clean API for developers to work with. SwiftUI is focused on providing a consistent API for all the common user interface elements used in iOS8 apps, letting developers build apps that are both responsive and consistent.. Read more about awesome swiftui and let us know what you think.