Skip to content

Instantly share code, notes, and snippets.

View hishd's full-sized avatar
💭
I may be slow to respond.

Hishara Dilshan hishd

💭
I may be slow to respond.
View GitHub Profile
@hishd
hishd / AppConfig.swift
Created March 27, 2024 06:35
Enabling debugging mode on iOS Apps
struct AppConfig {
static func toggleDebugMode() -> Bool {
guard !UserDefaults.standard.isDebuggingEnabled else {
return false
}
enableDebugMode()
func enableDebugMode() -> Never {
UserDefaults.standard.isDebuggingEnabled = true
//
// Logger+Extensions.swift
// SkyWizard
//
// Created by Hishara Dilshan on 2023-10-10.
//
import OSLog
extension Logger {
//
// DependencyInjector.swift
// SkyWizard
//
// Created by Hishara Dilshan on 2023-10-10.
//
import Foundation
protocol Injectable {}
//
// UserDefaults+Wrapper.swift
// SkyWizard
//
// Created by Hishara Dilshan on 2023-10-22.
//
import Foundation
import Combine
import Foundation
@dynamicMemberLookup
struct AppConfig {
let weatherApiKey: String = ""
private init() {}
static subscript<T>(dynamicMember keyPath:KeyPath<AppConfig, T>) -> T {
import Foundation
import UIKit
///Error enum for CachedImageLoader
enum CachedImageLoaderError: Error {
case errorLoading(Error)
case errorDecording
case cancelled
}
@hishd
hishd / NotificationHandler.kt
Last active July 7, 2022 21:03
Display Notifications in Android
class NotificationHandler(
private val context: Context,
private val channelID: String,
channelName: String,
channelDescription: String,
) {
private var notificationManager: NotificationManager =
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
@hishd
hishd / ItemOffsetDecoration.kt
Created July 6, 2022 17:45
RecyclerView Item Decorator in Kotlin
class ItemOffsetDecoration(
val context: Context,
@DimenRes
var top: Int,
@DimenRes
var bottom: Int,
@DimenRes
var left: Int,
@DimenRes
var right: Int
@hishd
hishd / android_animations_new.xml
Created July 2, 2022 17:44
Android Animations new
<!--make it just appear-->
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="1"
android:fromAlpha="1.0"
android:toAlpha="1.0"/>
</set>
@hishd
hishd / android_animations.xml
Last active July 2, 2022 17:34
Android Animations
<!--push_down_in-->
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="-100%p" android:toYDelta="0" android:duration="5000"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="5000" />
</set>
<!--push_down_out-->
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">