Skip to content

Instantly share code, notes, and snippets.

View Pheayuth222's full-sized avatar
🏠
Working from home

Yuth Fight Pheayuth222

🏠
Working from home
View GitHub Profile
@Pheayuth222
Pheayuth222 / openSwipe.md
Last active September 25, 2024 04:07
Swipe Open in Swift (UIKit)
Screenshot Video Demo
@Pheayuth222
Pheayuth222 / Advanced didSet.md
Last active September 10, 2024 06:35
Advanced didSet

🚀 More Advanced Property Observer didSet

1️⃣. Two-Way Data Binding in a View-Model Architecture

In MVVM (Model-View-ViewModel) architecture, didSet can be used to update the view when the model changes, establishing a simple form of two-way data binding.

class ViewModel {
    var username: String = "" {
@Pheayuth222
Pheayuth222 / Property_Observer.md
Last active September 10, 2024 01:23
Property Observer willSet & didSet

🚀 Property Observer willSet & didSet

1️⃣. Updating a Related Property

class Rectangle {
    var width: Double = 0 {
        didSet {
            area = width * height
        }
@Pheayuth222
Pheayuth222 / QR&BardCode.md
Last active September 18, 2024 07:46
Show Barcode and QR Code in iOS Native

Barcode and QR Code

  • Show Barcode and QR Code in iOS Native

* Swift Source Code `

import UIKit
import SwiftUI
import AVFoundation
import CoreImage.CIFilterBuiltins
@Pheayuth222
Pheayuth222 / guard condition.swift
Last active September 4, 2024 09:59
guards for Early Exits
func invertedCombobulatoryFactory(of value: Int) -> Int {
// Example transformation: return the negative of the value
return -value
}
func discombobulate(_ values: [Int]) throws -> Int {
guard let first = values.first else {
throw DiscombobulationError.arrayWasEmpty
}
guard first >= 0 else {

Swift-Snippets

🚀 Snippets for my iOS Projects 😚😘

  1. Disable Screenshot in iOS:
    1. Before
    2. After
@Pheayuth222
Pheayuth222 / PreviewStoryboardVC.swift
Last active August 12, 2024 06:48
Preview ViewContrroller with storyboard or without storyboard in Swift
import UIKit
import SwiftUI
class PreviewStoryboardVC: UIViewController {
@IBOutlet weak var showResult: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
@Pheayuth222
Pheayuth222 / Custom Dynamic Model in Swift.swift
Last active July 26, 2024 07:26
Custom Dynamic Model in Swift
enum RowType: String, CaseIterable {
case Profile
case Info
case Rewards
}
// big array model to store all detail
struct DetailInfoModel <T> {
var headerTitle : String?
var value : T?
@Pheayuth222
Pheayuth222 / Push Value Using Combine framework.swift
Last active July 26, 2024 06:52
Push value to another ViewController using Combine framework in Swift
import Combine
class ViewModel {
@Published var passedString: String = ""
}
class FirstViewController: UIViewController {
var viewModel = ViewModel()
@Pheayuth222
Pheayuth222 / Custom_Func_Navigation.swift
Last active July 15, 2024 06:41
Custom Func Navigation Bar in Swift Programming
func setNavBar( title: String,
animated : Bool,
leftButtonImage leftImgs : UIImage? = UIImage(named:"Default Image"),
leftBarButtonTitle leftBarTitle: String? = nil,
leftSelector : Selector? = #selector(leftBarButtonAction),
rightBarButtonImage images : [UIImage?] = [],
rightButtonColor buttonColors : [UIColor]? = nil,
rightButtonTitle buttonTitles : [String]? = nil,
rightSelectors : [Selector]? = nil,
isHidden : Bool = false,