This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public protocol NetworkLoggable { | |
func log<T: CustomStringConvertible>( | |
label: String, | |
value: T?, | |
level: NetworkLogger, | |
function: StaticString, | |
line: UInt, | |
file: String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"packages":[{"url":"https:\/\/github.com\/vinhnx\/DictionaryNestedSubscript.git","versions":[{"license":{"url":"https:\/\/github.com\/vinhnx\/DictionaryNestedSubscript\/blob\/master\/LICENSE","name":"MIT"},"defaultToolsVersion":"5.1.0","verifiedCompatibility":[{"swiftVersion":"5.1","platform":{"name":"ios"}},{"swiftVersion":"5.2","platform":{"name":"ios"}},{"swiftVersion":"5.3","platform":{"name":"ios"}},{"swiftVersion":"5.4","platform":{"name":"ios"}},{"swiftVersion":"5.5","platform":{"name":"ios"}},{"swiftVersion":"5.1","platform":{"name":"linux"}},{"swiftVersion":"5.2","platform":{"name":"linux"}},{"swiftVersion":"5.3","platform":{"name":"linux"}},{"swiftVersion":"5.4","platform":{"name":"linux"}},{"swiftVersion":"5.5","platform":{"name":"linux"}},{"swiftVersion":"5.1","platform":{"name":"macos"}},{"swiftVersion":"5.2","platform":{"name":"macos"}},{"swiftVersion":"5.3","platform":{"name":"macos"}},{"swiftVersion":"5.4","platform":{"name":"macos"}},{"swiftVersion":"5.5","platform":{"name":"macos"}},{"swift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
agvtool new-version -all $(TZ="Asia/Ho_Chi_Minh" date +%Y%m%d.%H%M) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# docs: https://docs.microsoft.com/en-us/appcenter/build/custom/scripts/ | |
# Increment build version on Release | |
# format: %Y%m%d.%H%M | |
# reference: https://gist.github.com/sekati/3172554 | |
if [ "${CONFIGURATION}" = "Release" ]; then | |
echo "----" | |
buildNumber=$(TZ="Asia/Ho_Chi_Minh" date +%Y%m%d.%H%M) | |
echo "Build # set to: $buildNumber" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://kean.blog/post/swiftui-data-flow | |
struct SearchView: View { | |
@ObservedObject var viewModel: SearchViewModel | |
var body: some View { | |
VStack { | |
TextField("Search", text: $viewModel.query) | |
List(viewModel.songs) { | |
Text($0.name) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LocalConfigLoader: LocalConfigLoading { | |
private var cachedConfigUrl: URL? { | |
guard let documentsUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { | |
return nil | |
} | |
return documentsUrl.appendingPathComponent("config.json") | |
} | |
private var cachedConfig: AppConfig? { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Orginal code from: https://gist.github.com/mecid/f8859ea4bdbd02cf5d440d58e936faec | |
//I just made some modification in appearnce, show monthly navigator and weekdays. | |
import SwiftUI | |
struct ContentView: View { | |
@Environment(\.calendar) var calendar | |
private var year: DateInterval { | |
calendar.dateInterval(of: .month, for: Date())! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let notificationCenter = NotificationCenter.default | |
notificationCenter.addObserver(self, selector: #selector(adjustForKeyboard), name: UIResponder.keyboardWillHideNotification, object: nil) | |
notificationCenter.addObserver(self, selector: #selector(adjustForKeyboard), name: UIResponder.keyboardWillChangeFrameNotification, object: nil) | |
@objc func adjustForKeyboard(notification: Notification) { | |
guard let keyboardValue = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else { return } | |
let keyboardScreenEndFrame = keyboardValue.cgRectValue | |
let keyboardViewEndFrame = view.convert(keyboardScreenEndFrame, from: view.window) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Diffable datasource and compositional layout: | |
+ https://www.donnywals.com/modern-table-views-with-diffable-data-sources/ | |
+ https://www.swiftbysundell.com/articles/building-modern-collection-views-in-swift/ | |
> **UICollectionViewDiffableDataSource** let us compute UICollectionView datasource and configuration, as a replacement for plain old UICollectionViewDatasource/UICollectionViewDelegate. We also have table view counter part, they are **UITableViewDiffableDataSource**. | |
> we can now use **UICollectionViewComposableLayout** as replacement for **UITableView**. | |
```swift | |
func makeCollectionView() -> UICollectionView { |