Add swiftui, uikit & reactive programming content (#6114)
parent
d1a698447d
commit
cebb561afe
20 changed files with 188 additions and 20 deletions
@ -1 +1,9 @@ |
||||
# Combine and MVVM |
||||
|
||||
Combine and MVVM (Model-View-ViewModel) form a powerful combination in iOS development. Combine's reactive approach complements MVVM's separation of concerns. In this pairing, ViewModels use Combine publishers to expose data streams to Views, which subscribe to these streams for reactive UI updates. Models can publish changes through Combine, which ViewModels then process and transform. This setup allows for clean, declarative bindings between Views and ViewModels, reducing boilerplate code and improving testability. Combine's operators facilitate complex data transformations within ViewModels, while its handling of asynchronous operations simplifies tasks like network requests. |
||||
|
||||
Learn more from the following resoureces: |
||||
|
||||
- [@article@MVVM Design Pattern with Combine Framework](https://medium.com/@mshcheglov/mvvm-design-pattern-with-combine-framework-on-ios-5ff911011b0b) |
||||
- [@article@MVVM and Combine](https://betterprogramming.pub/uikit-mvvm-combine-912c80c02262) |
||||
- [@video@MVVM Combine Swift (2022)](https://www.youtube.com/watch?v=KK6ryBmTKHg) |
@ -1 +1,9 @@ |
||||
# Components |
||||
|
||||
Components are built by composing primitive views like Text, Image, and Button, along with container views such as VStack and HStack. They can accept parameters for customization and use `@State` and `@Binding` for internal state management and data flow. SwiftUI's modifiers allow for styling and behavior adjustments. Components can be extracted into separate files for reusability across the app. This approach encourages a modular design, improving code organization and maintainability. |
||||
|
||||
Learn more from the following resources: |
||||
|
||||
- [@article@SwiftUI Components](https://designcode.io/swiftui-handbook-components) |
||||
- [@course@Building Reusable SwiftUI Components](https://peterfriese.github.io/Building-SwiftUI-Components-Tutorial/tutorials/tutorial-table-of-contents/) |
||||
- [@video@Building SwiftUI Components](https://www.youtube.com/playlist?list=PLsnLd2esiGRTfzn8pq4ZMYyDsL8GEMZO8) |
@ -1 +1,9 @@ |
||||
# Data binding |
||||
|
||||
SwiftUI data binding is a mechanism that creates a two-way connection between a piece of data and a UI element. It uses the `@Binding` property wrapper to allow child views to share and modify data owned by parent views. Bindings ensure that changes in data are immediately reflected in the UI and vice versa. They are typically created using the `$` prefix on a `@State` property. This approach facilitates the flow of data through an app's view hierarchy, enabling reactive UI updates and maintaining a single source of truth. |
||||
|
||||
Learn more from the following resources: |
||||
|
||||
- [@official@Binding](https://developer.apple.com/documentation/swiftui/binding) |
||||
- [@video@How to use @Binding property wrapper in SwiftUI](https://www.youtube.com/watch?v=btDMzB5x2Gs) |
||||
- [@video@SwiftUI - @Binding Property Wrapper Explained](https://www.youtube.com/watch?v=lgtB3WLEOYg) |
@ -1 +1,9 @@ |
||||
# Declarative Syntax |
||||
|
||||
SwiftUI's declarative syntax allows developers to describe the desired UI state rather than the step-by-step process to achieve it. This approach uses Swift code to define what views should appear and how they should behave, with SwiftUI handling the underlying implementation details. Developers create views by combining and modifying smaller view components, using modifiers to adjust appearance and behavior. State management is integrated into this syntax, with UI automatically updating when state changes. |
||||
|
||||
Learn more from the following resources: |
||||
|
||||
- [@article@Declarative and Imperative Programming using SwiftUI and UIKit](https://medium.com/@rmeji1/declarative-and-imperative-programming-using-swiftui-and-uikit-c91f1f104252) |
||||
- [@article@Apple's SwiftUI Declarative Framework](https://www.linkedin.com/pulse/apples-swiftui-declarative-framework-vivek-singh/) |
||||
- [@video@Imperative vs Declarative Programming](https://www.youtube.com/watch?v=yOBBkIJBEL8) |
@ -1 +1,15 @@ |
||||
# Modals and Navigation |
||||
|
||||
UIKit navigation stacks support both modal presentations and hierarchical navigation: |
||||
|
||||
Modal presentations temporarily overlay new content using present(_:animated:completion:). They're suitable for self-contained tasks or information that doesn't fit the main navigation hierarchy. |
||||
|
||||
Hierarchical navigation uses push and pop operations on the navigation stack. pushViewController(_:animated:) adds a new screen, while popViewController(animated:) returns to the previous one. |
||||
|
||||
These can be combined: a modal can contain its own navigation stack, or a screen in the main navigation can present a modal. This flexibility allows developers to create complex navigation patterns that maintain clarity and context for users, adapting to various app structures and user flow requirements. |
||||
|
||||
Learn more from the following resources: |
||||
|
||||
- [@official@animate(withDuration:animations:completion:)](https://developer.apple.com/documentation/uikit/uiview/1622515-animate) |
||||
- [@officialpushViewController](https://developer.apple.com/documentation/uikit/uinavigationcontroller/1621887-pushviewcontroller) |
||||
- [@video@UIKit Programmatic Navigation](https://www.youtube.com/watch?v=c0YSGtFmik8) |
@ -1 +1,12 @@ |
||||
# Navigation Controllers, Segues |
||||
|
||||
UIKit Navigation Controllers and Segues are key components for managing app navigation: |
||||
|
||||
Navigation Controllers (`UINavigationController`) manage a stack of view controllers, providing a hierarchical interface for navigating content. They handle push and pop transitions between screens, maintain a navigation bar, and support back-navigation functionality. |
||||
|
||||
Segues are visual connections between view controllers in storyboards, defining transitions between scenes. They can be triggered programmatically or through user interactions. Types include push, modal, and custom segues. Segues simplify the process of passing data between view controllers during transitions. |
||||
|
||||
Learn more from the following resources: |
||||
|
||||
- [@video@How to Nav Bar Programmatically](https://www.youtube.com/watch?v=wcN3-E1_ZxU) |
||||
- [@official@UINavigationController](https://developer.apple.com/documentation/uikit/uinavigationcontroller) |
@ -1 +1,3 @@ |
||||
# Navigation Stacks |
||||
|
||||
UIKit Navigation Stacks, managed by UINavigationController, provide a hierarchical way to organize content in iOS apps. The stack operates on a last-in-first-out basis, where view controllers are pushed onto or popped from the top. The root view controller remains at the bottom, while subsequent screens are added above it. This structure allows for intuitive drill-down interfaces and easy back-navigation. Navigation stacks automatically handle transitions between view controllers, maintain a navigation bar with titles and back buttons, and can be customized for specific navigation patterns. They are fundamental to creating depth in app navigation, enabling users to traverse complex information hierarchies efficiently. |
@ -1 +1,9 @@ |
||||
# Observables & observers |
||||
|
||||
RxSwift Observables and Observers form the core of its reactive paradigm. Observables represent sequences of data or events over time, emitting items to subscribed Observers. Observers react to these emissions, handling new values, errors, or completion signals. This pattern allows for decoupling of data production from consumption, facilitating asynchronous programming. Observables can represent various data sources like UI events, network responses, or timer ticks. Observers can be chained with operators to transform or filter data streams. This approach simplifies complex asynchronous operations, making code more readable and maintainable. |
||||
|
||||
Learn more from the following resources: |
||||
|
||||
- [@article@RxSwift - Observables](https://medium.com/@priya_talreja/rxswift-observables-7809b474aab) |
||||
- [@video@Creating Observables](https://www.youtube.com/watch?v=h59te-_rVYg) |
||||
- [@opensource@RxSwift Documentation - Observables](https://github.com/ReactiveX/RxSwift/blob/main/Documentation/GettingStarted.md#observables-aka-sequences) |
@ -1 +1,9 @@ |
||||
# Operators & Pipelines |
||||
|
||||
The Combine framework uses operators and pipelines to process and transform data streams. Operators are methods that perform operations on publishers, such as filtering, mapping, or combining data. Pipelines are chains of these operators that process data from its source to its final destination. Common operators include `map`, `filter`, `reduce`, and `merge`. Pipelines allow developers to declaratively describe complex asynchronous operations, handling tasks like data transformation, error management, and combining multiple data sources. This approach simplifies handling of asynchronous events and state changes, enabling more robust and maintainable code in iOS applications. |
||||
|
||||
Learn more from the following resources: |
||||
|
||||
- [@video@How to master Combine like a Pro – The Operators](https://www.youtube.com/watch?v=-NDFLP7Aqeg) |
||||
- [@article@Swift Combine — Combine Operators & Filtering Operators](https://nikunj-joshi.medium.com/swift-combine-introduction-to-combine-operators-filtering-operators-510d962b95f2) |
||||
- [@article@Custom Operators in Swift Combine](https://bignerdranch.com/blog/custom-operators-in-swift-combine/) |
||||
|
@ -1 +1,8 @@ |
||||
# Operators |
||||
|
||||
RxSwift operators are functions that process, transform, or combine observable sequences. They allow developers to manipulate data streams in powerful ways. Common operators include map (transform elements), filter (select elements based on criteria), flatMap (transform elements into new observables), merge (combine multiple observables), and debounce (limit emission rate). Operators can be chained to create complex data processing pipelines. They handle tasks like error management, retrying failed operations, and combining asynchronous operations. |
||||
|
||||
Learn more from the following resources: |
||||
|
||||
- [@article@Mastering RxSwift Operators](https://medium.com/@mumensh/mastering-rxswift-operators-e66bd8ef5933) |
||||
- [@course@Interactive diagrams of Rx Observables](https://rxmarbles.com/) |
@ -1 +1,9 @@ |
||||
# Publishers / Subscribers |
||||
|
||||
The Combine framework in iOS uses Publishers and Subscribers as core components for reactive programming. Publishers are types that can emit a sequence of values over time, representing sources of asynchronous events or data. Subscribers receive and process these values, defining how to handle the published data. Publishers can emit multiple values, complete successfully, or terminate with an error. Subscribers can receive and react to these events, often updating UI or triggering further operations. |
||||
|
||||
Learn more from the following resources: |
||||
|
||||
- [@article@Combine Publishers & Subscribers](https://www.kodeco.com/books/combine-asynchronous-programming-with-swift/v2.0/chapters/2-publishers-subscribers) |
||||
- [@official@Processing Published Elements with Subscribers](https://developer.apple.com/documentation/combine/processing-published-elements-with-subscribers) |
||||
- [@video@Combine - Publishers and Subscribers Lifecycles and Error Handling](https://www.youtube.com/watch?v=4WQskqNHxhQ) |
@ -1 +1,11 @@ |
||||
# Pushing Presenting |
||||
|
||||
Pushing adds a new view controller to the top of the navigation stack, ideal for hierarchical navigation. It's done using navigationController?.pushViewController(_:animated:), which slides the new view in from the right and adds a back button. |
||||
|
||||
Presenting displays a view controller modally, often covering the entire screen or as a sheet. It's achieved using present(_:animated:completion:), suitable for temporary or standalone content. |
||||
|
||||
Learn more from the following resources: |
||||
|
||||
- [@article@Pushing, Popping, Presenting, & Dismissing ViewControllers](https://medium.com/@felicity.johnson.mail/pushing-popping-dismissing-viewcontrollers-a30e98731df5) |
||||
- [@opensource@presentViewController vs pushViewController](https://github.com/russell-archer/ModalStylesDemo) |
||||
- [@article@UINavigationController.PushViewController](https://learn.microsoft.com/en-us/dotnet/api/uikit.uinavigationcontroller.pushviewcontroller?view=xamarin-ios-sdk-12) |
@ -1 +1,9 @@ |
||||
# Reactive Programming |
||||
|
||||
Reactive Programming is a declarative programming paradigm focused on data streams and the propagation of change. It emphasizes the automatic distribution of changes through data flows. Key concepts include observable streams of data, operators to transform and combine streams, and subscribers that react to stream changes. This approach allows for handling asynchronous data flows, managing complex event sequences, and building responsive user interfaces. In iOS development, frameworks like Combine (Apple's native solution) and RxSwift implement reactive principles. |
||||
|
||||
Learn more from the following resources: |
||||
|
||||
- [@article@What is reactive programming?](https://www.baeldung.com/cs/reactive-programming#:~:text=Reactive%20programming%20is%20a%20declarative,or%20reactive%20systems%20in%20general.) |
||||
- [@article@What is Reactive Programming? Beginner's Guide to Writing Reactive Code](https://www.freecodecamp.org/news/reactive-programming-beginner-guide/) |
||||
- [@video@What is reactive programming?](https://www.youtube.com/watch?v=X-DeG_uGFUU) |
@ -1 +1,9 @@ |
||||
# RxSwift with MVVM |
||||
|
||||
RxSwift integrates seamlessly with the MVVM (Model-View-ViewModel) architecture in iOS development. In this combination, ViewModels expose Observable properties that Views can bind to, creating a reactive data flow. Models emit data changes through Observables, which ViewModels transform and expose to Views. This setup allows for clean, declarative bindings between Views and ViewModels, reducing boilerplate code and improving testability. RxSwift's operators facilitate complex data transformations within ViewModels, while its Subjects can handle user inputs. |
||||
|
||||
Learn more from the following resources: |
||||
|
||||
- [@article@How to use RxSwift with MVVM Pattern](https://www.vincit.com/blog/how-to-use-rxswift-with-mvvm-pattern) |
||||
- [@article@Implementing MVVM With RxSwift](https://betterprogramming.pub/ios-mvvm-with-rxswift-part-1-ff9f8102a3c9) |
||||
- [@opensource@MVVM with RxSwift](https://github.com/yokurin/RxSwift-MVVM-iOS) |
@ -1 +1,9 @@ |
||||
# RxSwift |
||||
|
||||
RxSwift is a reactive programming library for iOS development, implementing ReactiveX (Rx) principles in Swift. It provides a framework for composing asynchronous and event-based programs using observable sequences. RxSwift facilitates the handling of asynchronous data streams, simplifying tasks like network requests, user interface events, and data binding. It offers a rich set of operators for transforming, combining, and filtering data streams. The library promotes a declarative programming style, reducing complexities in managing state and dependencies. While similar to Apple's Combine framework, RxSwift has broader platform support and a larger ecosystem. |
||||
|
||||
Learn more from the following resources: |
||||
|
||||
- [@opensource@RxSwift Documentation](https://github.com/ReactiveX/RxSwift) |
||||
- [@official@ReactiveX Documentation](https://reactivex.io/intro.html) |
||||
- [@video@RxSwift Basics](https://www.youtube.com/watch?v=ES5RuLSv61g) |
@ -1 +1,9 @@ |
||||
# Schedulers |
||||
|
||||
RxSwift Schedulers manage the execution context of observable sequences and observers. They determine when and on which thread observables emit items and observers receive them. Key schedulers include MainScheduler (for UI operations), SerialDispatchQueueScheduler (for background serial work), and ConcurrentDispatchQueueScheduler (for concurrent background tasks). Schedulers enable fine-grained control over concurrency, allowing developers to optimize performance and maintain thread safety. They're crucial for operations like offloading heavy computations from the main thread or ensuring UI updates occur on the main thread. |
||||
|
||||
Learn more from the following resources: |
||||
|
||||
- [@official@ReactiveX Scheduler Documentation](https://reactivex.io/documentation/scheduler.html) |
||||
- [@opensource@RxSwift Scheduler Documentation](https://github.com/ReactiveX/RxSwift/blob/main/Documentation/Schedulers.md) |
||||
- [@article@RxSwift Schedulers](https://docs.rxswift.org/rxswift/schedulers) |
@ -1 +1,9 @@ |
||||
# State Management |
||||
|
||||
SwiftUI state management revolves around property wrappers that handle different types of app state. `@State` is used for local view state, `@Binding` for sharing state between views, `@ObservedObject` for external reference type state, `@EnvironmentObject` for dependency injection across the view hierarchy, and `@StateObject` for creating and managing the lifecycle of observed objects. These tools, combined with SwiftUI's declarative syntax, enable reactive UI updates based on state changes. For more complex state management, developers often use architectural patterns like MVVM or libraries such as Combine. |
||||
|
||||
Learn more from the following resources: |
||||
|
||||
- [@official@Managing user interface state](https://developer.apple.com/documentation/swiftui/managing-user-interface-state) |
||||
- [@article@Advanced: SwiftUI State Managment](https://medium.com/@canakyildz/advanced-swiftui-state-management-3816d804477e) |
||||
- [@article@A Guide to Managing State in SwiftUI](https://www.waldo.com/blog/manage-swiftui-state) |
@ -1 +1,9 @@ |
||||
# Subjects |
||||
|
||||
RxSwift Subjects are a special type of Observable that act as both an observer and an observable. They can receive and emit values, serving as a bridge between the imperative and reactive programming paradigms. Subjects allow multiple observers to react to the same source of emitted items. RxSwift provides several types of Subjects, including PublishSubject (emits only new elements), BehaviorSubject (emits the latest element to new subscribers), ReplaySubject (buffers and re-emits a specified number of elements), and Variable (a deprecated wrapper around BehaviorSubject). |
||||
|
||||
Learn more from the following resources: |
||||
|
||||
- [@article@RxSwift Subjects Reference](https://docs.rxswift.org/rxswift/subjects) |
||||
- [@article@RxSwift Subjects](https://medium.com/@jhalekhnish/rxswift-subjects-45f65649aee6) |
||||
- [@official@ReactiveX Subject Documentation](https://reactivex.io/documentation/subject.html) |
@ -1 +1,9 @@ |
||||
# UI Design |
||||
|
||||
UI Design in iOS development focuses on creating visually appealing and functional user interfaces that adhere to Apple's Human Interface Guidelines. It involves designing layouts, choosing appropriate color schemes, typography, and interactive elements that provide a seamless user experience. iOS designers use tools like Sketch, Figma, or Adobe XD to create mockups and prototypes. Key considerations include maintaining consistency with iOS design patterns, ensuring accessibility, supporting different device sizes and orientations, and implementing intuitive navigation. Effective iOS UI design balances aesthetic appeal with usability, leveraging native UI components and custom designs to create engaging, user-friendly applications that feel at home on Apple devices. |
||||
|
||||
Learn more from the following resources: |
||||
|
||||
- [@article@Design Patterns in iOS](https://shreethaanur.medium.com/design-patterns-in-ios-55d00c2eef4c) |
||||
- [@official@Sketch](https://www.sketch.com/) |
||||
- [@official@Figma](https://www.figma.com/) |
@ -1 +1,13 @@ |
||||
# Views, View Controllers |
||||
|
||||
UIKit Views and View Controllers are fundamental components in iOS app development. |
||||
|
||||
Views (UIView) are the basic building blocks of user interfaces, representing rectangular areas that can display content and respond to user interactions. They can be customized, combined, and nested to create complex layouts. Common subclasses include UILabel, UIButton, and UIImageView. |
||||
|
||||
View Controllers (UIViewController) manage a set of views and coordinate the flow of data between the app's data model and the views. They handle view lifecycle, respond to user actions, and manage transitions between different parts of the user interface. View controllers are crucial for organizing app structure and maintaining separation of concerns in UIKit-based applications. |
||||
|
||||
Learn more from the following resources: |
||||
|
||||
- [@official@UIView Documentation](https://developer.apple.com/documentation/uikit/uiview) |
||||
- [@official@UIkit View Controllers](https://developer.apple.com/documentation/uikit/view_controllers) |
||||
- [@video@Intro to UIKit and UIViews](https://www.youtube.com/watch?v=w58ncTHKiK4) |
||||
|
Loading…
Reference in new issue