Welcome to my programming diary! I'm a senior software engineer from Italy sharing my experiences & lessons learned in Java, Swift, & Flutter development. Expect hands-on tutorials, tips, and practical examples to improve your skills and build quality apps. Follow for the latest updates & insights.
Posts
Basic animations in SwiftUI
- Get link
- X
- Other Apps
Animations in SwiftUI SwiftUI provides a simple and intuitive way to add animations to your applications. In this article, we'll explore the basics of animations in SwiftUI and how to add them to your app. What are animations in SwiftUI? Animations in SwiftUI are visual effects that add movement and interactivity to your app. They help make your app more engaging and improve the user experience by providing visual cues and feedback. With SwiftUI, you can easily add animations to any view using a main methods: Animation View Modifier withAnimation Global Function in SwiftUI Both of these methods allow you to animate changes in your views, but they are used differently and provide different levels of control over the animation. The Animation View Modifier The Animation View Modifier is used to specify the animation style for a view. It's a view modifier that can be applied to any view and allows you to control the duration, curve, and other aspects of the animation. Here's a...
Searching for a String in Java 8
- Get link
- X
- Other Apps
Java 8 introduced a lot of functional programming features and one of them is the stream() method which allows us to manipulate collections in a functional way. In this article, we’ll see how we can use the stream() method and the anyMatch() method to search for a string in a list of strings and return true if any of the strings in the list are present in the source string. First, let's write the method to do the search: import java.util.List; public class Main { public static boolean containsString(String source, List targets) { return targets.stream().anyMatch(target -> source.contains(target)); } } The containsString() method takes two arguments: source which is the string that we want to search in, and targets which is the list of strings that we want to search for. The method returns a boolean value indicating whether any of the strings in the list are present in the source string. To use the containsString() method, we need to call it and pass in the source...