How to make carousel layout for UICollectionView in iOS

Issue #302 Based on AnimatedCollectionViewLayout final class CarouselLayout: UICollectionViewFlowLayout { override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { guard let attributes = super.layoutAttributesForElements(in: rect) else { return nil } guard let collectionView = collectionView else { return nil } return attributes.map({ transform(collectionView: collectionView, attribute: $0) }) } override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool { return true } private func transform(collectionView: UICollectionView, attribute: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes { let a = attribute let width = collectionView....

June 12, 2019 · 3 min · 635 words · Khoa

How to make simple pan to dismiss view in iOS

Issue #301 Make it more composable using UIViewController subclass and ThroughView to pass hit events to underlying views. class PanViewController: UIViewController { var animator = UIViewPropertyAnimator(duration: 0, curve: .easeOut) lazy var panGR = UIPanGestureRecognizer(target: self, action: #selector(handlePan(_: ))) let slideView = UIView() let gripView = UIView() var options: Options = Options() var didHide: (() -> Void)? let pullDownVelocity: CGFloat = 70 class Options { var contentView: UIView = UIView() var percentHeight: CGFloat = 0....

June 12, 2019 · 2 min · 306 words · Khoa

Getting started with WWDC 2019

Issue #300 WWDC WWDC special WWDC by Sundell NSHipster WWDC 2019 WWDC 2019 - The Things You May Have Missed 7 essential WWDC session videos for iOS developers The 15 Best WWDC Videos of All Time WWDC Extracted gists Favorite WWDC 2019 sessions Swift 5.1 Property wrappers to remove boilerplate code in Swift Understanding Opaque Return Types in Swift The Swift 5.1 features that power SwiftUI’s API What’s new in Swift 5....

June 11, 2019 · 1 min · 201 words · Khoa

How to style NSButton in AppKit

Issue #297 let button = NSButton() button.wantsLayer = true button.isBordered = false button.setButtonType(.momentaryChange) button.attributedTitle = NSAttributedString( string: "Click me", attributes: [ NSAttributedString.Key.foregroundColor: NSColor.white, NSAttributedString.Key.font: NSFont.labelFont(ofSize: 13) ] button.layer?.backgroundColor = NSColor.orange.cgColor button.layer?.cornerRadius = 12 activate( button.anchor.height.equal.to(32), button.anchor.width.equal.to(100) ) To make it have native rounded rect button.imageScaling = .scaleProportionallyDown button.setButtonType(.momentaryPushIn) button.bezelStyle = .rounded button.isBordered = true import AppKit import Omnia extension NSButton { func style(imageName: String) { image = NSImage(named: NSImage.Name(imageName)) isBordered = false imageScaling = ....

May 31, 2019 · 1 min · 102 words · Khoa

How to highlight selection of NSCollectionViewItem

Issue #296 Original answer https://stackoverflow.com/a/54793979/1418457 In your NSCollectionViewItem subclass, override isSelected and change background color of the layer. Test in macOS 10.14 and Swift 4.2 class Cell: NSCollectionViewItem { override func loadView() { self.view = NSView() self.view.wantsLayer = true } override var isSelected: Bool { didSet { self.view.layer?.backgroundColor = isSelected ? NSColor.gray.cgColor : NSColor.clear.cgColor } } }

May 30, 2019 · 1 min · 57 words · Khoa

How to debounce action in Flutter

Issue #293 Answer https://stackoverflow.com/a/55119208/1418457 This is useful to throttle TextField change event. You can make Debouncer class using Timer import 'package:flutter/foundation.dart'; import 'dart:async'; class Debouncer { final int milliseconds; VoidCallback action; Timer _timer; Debouncer({ this.milliseconds }); run(VoidCallback action) { if (_timer != null) { _timer.cancel(); } _timer = Timer(Duration(milliseconds: milliseconds), action); } } Declare and trigger final _debouncer = Debouncer(milliseconds: 500); onTextChange(String text) { _debouncer.run(() => print(text)); }

May 30, 2019 · 1 min · 68 words · Khoa

How to add indicator under tab bar buttons in iOS

Issue #288 selectionIndicatorImage https://developer.apple.com/documentation/uikit/uitabbar/1623456-selectionindicatorimage Should design image with enough height, transparent background and indicator at the bottom Use this property to specify a custom selection image. Your image is rendered on top of the tab bar but behind the contents of the tab bar item itself. The default value of this property is nil, which causes the tab bar to apply a default highlight to the selected item Custom UITabBar or UITabBarController Hide existing tabBar tabBar....

May 27, 2019 · 2 min · 374 words · Khoa

Understanding socket and port in TCP

Issue #287 When digging into the world of TCP, I get many terminologies I don’t know any misconceptions. But with the help of those geeks on SO, the problems were demystified. Now it’s time to sum up and share with others :D What defines a unique connection ? There are 5 elements that identify a connection. They call them 5-tuple Protocol. This is often omitted as it is understood that we are talking about TCP, which leaves 4....

May 25, 2019 · 4 min · 774 words · Khoa

How to use Gradle Kotlin DSL in Android

Issue #285 kts settings.gradle.kts include(":app") build.gradle.kts import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.kotlin import org.gradle.kotlin.dsl.* import org.jetbrains.kotlin.config.KotlinCompilerVersion plugins { id("com.android.application") kotlin("android") kotlin("android.extensions") } //apply { // from("$rootDir/tools/grgit.gradle") // from("$rootDir/buildSrc/quality.gradle.kts") // from("$rootDir/tools/ktlint.gradle") // from("$rootDir/tools/detekt.gradle") //} android { compileSdkVersion(28) flavorDimensions("default") defaultConfig { applicationId = "com.onmyway133.myapp" minSdkVersion(26) targetSdkVersion(28) // versionCode = ext.get("gitCommitCount") as? Int versionCode = 1 versionName = "1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } signingConfigs { create("release") { keyAlias = "keyalias" keyPassword = "keypassword" storePassword = "storepassword" storeFile = file("/Users/khoa/Android/Key/keystore") } } buildTypes { getByName("debug") { signingConfig = signingConfigs....

May 24, 2019 · 2 min · 271 words · Khoa

Learning VoIP, RTP and SIP (aka awesome pjsip)

Issue #284 Before working with Windows Phone and iOS, my life involved researching VoIP. That was to build a C library for voice over IP functionality for a very popular app, and that was how I got started in open source. The library I was working with were Linphone and pjsip. I learn a lot of UDP and SIP protocol, how to build C library for consumption in iOS, Android and Windows Phone, how challenging it is to support C++ component and thread pool in Windows Phone 8, how to tweak entropy functionality in OpenSSL to make it compile in Windows Phone 8, how hard it was to debug C code with Android NDK....

May 23, 2019 · 17 min · 3573 words · Khoa

How to deal with CSS responsiveness in Wordpress

Issue #283 Original post https://medium.com/fantageek/dealing-with-css-responsiveness-in-wordpress-5ad24b088b8b During the alpha test of LearnTalks, some of my friends reported that the screen is completely blank in search page, and this happened in mobile only. This article is how I identify the problem and found a workaround for the issue, it may not be the solution, but at least the screen does not appear blank anymore. As someone who likes to keep up with tech via watching conference videos, I thought it might be a good idea to collect all of these to better search and explore later....

May 23, 2019 · 3 min · 472 words · Khoa

How to use One Dark theme and Fira Code font for IDEs

Issue #281 A good theme and font can increase your development happiness a lot. Ever since using Atom, I liked its One Dark theme. The background and text colors are just elegant and pleasant to the eyes. One Dark Original designed for Atom, one-dark-ui that claims to adapt to most syntax themes, used together with Fira Mono font from mozilla. There is also Dracula which is popular, but the contrast seem too high for my eyes....

May 23, 2019 · 2 min · 346 words · Khoa

How to fix wrong status bar orientation in iOS

Issue #280 Original post https://medium.com/fantageek/how-to-fix-wrong-status-bar-orientation-in-ios-f044f840b9ed When I first started iOS, it was iOS 8 at that time, I had a bug that took my nearly a day to figure out. The issue was that the status bar always orients to device orientation despite I already locked my main ViewController to portrait. This was why I started notes project on GitHub detailing what issues I ‘ve been facing. ViewController is locked to portrait but the status bar rotates when device rotates · Issue #2 ·… *PROBLEM The rootViewController is locked to portrait....

May 23, 2019 · 3 min · 600 words · Khoa

What is create-react-native-app

Issue #279 Original post https://medium.com/fantageek/what-is-create-react-native-app-9f3bc5a6c2a3 As someone who comes to React Native from iOS and Android background, I like React and Javascript as much as I like Swift and Kotlin. React Native is a cool concept, but things that sound good in theory may not work well in practice. Another layer of abstraction Up until now, I still don’t get why big companies choose React Native over native ones, as in the end what we do is to deliver good experience to the end user, not the easy development for developers....

May 23, 2019 · 5 min · 948 words · Khoa

How to use Bitrise CI for React Native apps

Issue #277 Original post https://codeburst.io/using-bitrise-ci-for-react-native-apps-b9e7b2722fe5 After trying Travis, CircleCI and BuddyBuild, I now choose Bitrise for my mobile applications. The many cool steps and workflows make Bitrise an ideal CI to try. Like any other CIs, the learning steps and configurations can be intimidating at first. Things that work locally can fail on CI, and how to send things that are marked as git ignore to be used in CI builds are popular issues....

May 23, 2019 · 6 min · 1078 words · Khoa

How to make Unity games in pure C#

Issue #275 Original post https://codeburst.io/making-unity-games-in-pure-c-2b1723cdc71f As an iOS engineers, I ditched Storyboard to avoid all possible hassles and write UI components in pure Swift code. I did XAML in Visual Studio for Windows Phone apps and XML in Android Studio for Android apps some time ago, and I had good experience. However since I’m used to writing things in code, I like to do the same for Unity games, although the Unity editor and simulator are pretty good....

May 23, 2019 · 4 min · 711 words · Khoa

20 recommended utility apps for macOS

Issue #274 Original post https://hackernoon.com/20-recommended-utility-apps-for-macos-in-2018-ea494b4db72b Depending on the need, we have different apps on the mac. As someone who worked mostly with development, below are my indispensable apps. They are like suits to Tony Stark. Since I love open source apps, they have higher priority in the list. Open source apps iTerm 2 https://www.iterm2.com/ iTerm2 is a replacement for Terminal and the successor to iTerm. It works on Macs with macOS 10....

May 23, 2019 · 6 min · 1174 words · Khoa

How to run Android apps in Bitrise

Issue #273 Original post https://hackernoon.com/using-bitrise-ci-for-android-apps-fa9c48e301d8 CI, short for Continuous Integration, is a good practice to move fast and confidently where code is integrated into shared repository many times a day. The ability to have pull requests get built, tested and release builds get distributed to testers allows team to verify automated build and identify problems quickly. I ‘ve been using BuddyBuild for both iOS and Android apps and were very happy with it....

May 23, 2019 · 5 min · 1059 words · Khoa

How to make tag selection view in React Native

Issue #271 Original post https://hackernoon.com/how-to-make-tag-selection-view-in-react-native-b6f8b0adc891 Besides React style programming, Yoga is another cool feature of React Native. It is a cross-platform layout engine which implements Flexbox so we use the same layout code for both platforms. As someone who uses Auto Layout in iOS and Constraint Layout in Android, I find Flexbox bit hard to use at first, but there are many tasks that Flexbox does very well, they are distribute elements in space and flow layout....

May 23, 2019 · 6 min · 1211 words · Khoa

Getting to know some pragmatic programming language features

Issue #270 As you know, in the Pragmatic Programmer, section Your Knowledge Portfolio, it is said that Learn at least one new language every year. Different languages solve the same problems in different ways. By learning several different approaches, you can help broaden your thinking and avoid getting stuck in a rut. Additionally, learning many languages is far easier now, thanks to the wealth of freely available software on the Internet...

May 23, 2019 · 8 min · 1570 words · Khoa