The CxjToasts Example project demonstrates the features and usage of the CxjToasts library. This includes predefined templates and fully customizable toasts.
To run the Example project, follow these steps:
-
Download the project:
- Option 1: Clone the repository using Git:
git clone https://github.com/coxijcake/CxjToastsExample.git
- Option 2: Download the project as a ZIP archive from GitHub and extract it.
- Option 1: Clone the repository using Git:
-
Open the
.xcodeprojfile in Xcode. -
Ensure all dependencies are installed:
- Swift Package Manager: All dependencies are automatically resolved by SPM.
-
Build and run the project on a simulator or a device.
The project demonstrates the use of templated toasts, which provide ready-to-use designs for common scenarios. These toasts are created using TemplatedToastFactory.
Explore the creation of custom toasts, where every aspect of the toast (e.g., layout, animations, content) can be configured. These are created using CustomToastFactory.
The project showcases predefined templates like NativeToast or UndoToast. To see them in action:
- Navigate to the corresponding example in the app.
- Tap the relevant button to trigger a toast.
Explore how to create and display fully customized toasts:
- Go to the "Custom Toasts" section.
- Experiment with configurations and layouts defined in
CustomToastFactory.
let nativeTemplatedToast = TemplatedToastFactory.nativeToast()
CxjToastsCoordinator.shared.showToast(
type: .templated(template: nativeTemplatedToast)
)let customToastData = CustomToastFactory.toastDataForType(
.sidePresentingToast,
customSourceView: self.view
)
CxjToastsCoordinator.shared.showToast(
type: .custom(
data: customToastData
)
)let customToastData = CustomToastFactory.toastDataForType(
.sidePresentingToast,
customSourceView: self.view
)
ToastPresenter.presentToastWithType(
.custom(data: customToastData),
strategy: .custom(
strategy: .init(
presentsCount: 3,
delayBetweenToasts: 1.5
)
),
animated: true
)If you encounter any issues or have suggestions, feel free to create an issue or submit a pull request on the repository.
The Example project is available under the MIT license. See the LICENSE file for more information.