[iOS] Creating a Custom Animating Dashed Border in SwiftUI

Adding visual interest to your SwiftUI views is a breeze with animated dashed borders. Let me guide you through creating a custom dashed border that can bring a refreshing dynamism to your UI designs. Implementation Details Take a look at our refined implementation of the DashedRoundRectView. It’s designed to offer you an animated, customizable dashed border for rounded rectangles. This view is both flexible and adaptable to diverse design requirements: ...

November 25, 2024

[iOS] Enhance User Experience with Smooth Transitions in SwiftUI using AnimatedToastView

AnimatedToastView enhances SwiftUI applications by automating view transitions with smooth animations. By customizing the duration and leveraging various transition effects. Code Overview Here’s the implementation and usage of AnimatedToastView: struct AnimatedToastView<Content: View>: View { @State private var isVisible: Bool = false private let content: () -> Content private let displayDuration: CGFloat init(displayDuration: CGFloat, @ViewBuilder content: @escaping () -> Content) { self.displayDuration = displayDuration self.content = content } var body: some View { VStack { if isVisible { content() } } .task { withAnimation(.easeInOut) { isVisible = true } Timer.scheduledTimer( withTimeInterval: TimeInterval(displayDuration), repeats: false) { _ in withAnimation(.easeInOut) { isVisible = false } } } } } Understanding the Structure State Management: The @State property isVisible determines when the content should be displayed, automatically triggering animations when it changes. ...

November 19, 2024

[iOS] Handle deep link with chain responsibility pattern

The idea of deep linking is simple. You have an URL click to open your application and navigate to a specific screen. However, it can be messy when it comes to code, and you may end up with something like this. if url.absoluteString.contains("/login") { // Navigate to Login screen } else if url.absoluteString.contains("/products") { // Navigate to Products screen } else if url.absoluteString.contains("/payment") { // Navigate to Payment screen } else { // Navigate to Home screen } You can imagine what happens if you have ten types of URLs. This design also violates the Open/Closed Principle, and every time you add a new URL, you will have to open this file and add one more if-else block. Now is the solution. ...

August 2, 2023

[Flutter] Integrate Hive in 6 steps

Hive introduction You can find everything here https://pub.dev/packages/hive Steps From Visual Studio Code Cmd + Shift + P to Add dependency then search for hive_flutter. From Visual Studio Code Cmd + Shift + P to Add Dev dependency then search for build_runner and hive_generator. Mark the model as HiveType and import part [model_name].g.dart to generate the adapter in the next step. import 'package:hive_flutter/hive_flutter.dart'; part 'model.g.dart'; @HiveType(typeId: 0) class YourModel { @HiveField(0) final String property1; @HiveField(1) final String property2; YourModel(this.property1, this.property2); } From the terminal, run dart run build_runner build to generate the HiveAdapter. ...

August 1, 2023