Skip to content

Instantly share code, notes, and snippets.

@dqhieu
dqhieu / LicenseView.swift
Created March 14, 2024 04:25
License View
//
// LicenseView.swift
// CompressX
//
// Created by Dinh Quang Hieu on 06/01/2024.
//
import SwiftUI
struct LicenseView: View {
@dqhieu
dqhieu / LicenseManager.swift
Created March 14, 2024 03:59
Lemon Squeezy License Manager
//
// LicenseManager.swift
// CompressX
//
// Created by Dinh Quang Hieu on 06/01/2024.
//
import Foundation
import SwiftUI
import IOKit
@dqhieu
dqhieu / FolderMonitor.swift
Created March 3, 2024 16:05
Monitor a folder for new files
import Foundation
class FolderMonitor {
private var monitoredFolderURL: URL
private var folderMonitorQueue: DispatchQueue
private var folderMonitorSource: DispatchSourceFileSystemObject?
private var lastFileList: [String] = []
init(folderURL: URL) {
self.monitoredFolderURL = folderURL
struct ContentView: View {
@State private var isActive = false
@State private var isPressing = false
@State var scale: CGFloat = 1
@State var count = 0
var body: some View {
ZStack {
Circle()
@dqhieu
dqhieu / TwitterAnimation.swift
Last active April 6, 2023 00:50
Twitter's new animation ❤️
struct ContentView: View {
@State var scale: CGFloat = 0
@State var showingBlankHeart = true
@State var heartScale: CGFloat = 0
@State var textOpacity: Double = 1
@State var offset1: CGFloat = 0
@State var plus1Opacity: Double = 1
@State var offset2: CGFloat = 0
@State var plus2Opacity: Double = 1
public func setTitle(_ title: String? = nil, subTitle: String? = nil, content: String? = nil) {
_titleLabel.text = title
_subTitleLabel.text = subTitle
_contentLabel.text = content
updateFrame()
}
private func updateFrame() {
let titleLabelSize = _titleLabel.sizeThatFits(CGSize(width: _titleLabel.frame.width, height: 9999))
private func setupComponents() {
_titleLabel = UILabel(frame: .zero)
_titleLabel.textColor = UIColor.black
_titleLabel.numberOfLines = 0
_titleLabel.backgroundColor = UIColor.red
addSubview(_titleLabel)
_subTitleLabel = UILabel(frame: .zero)
_subTitleLabel.textColor = UIColor.black
_subTitleLabel.numberOfLines = 0
myView = MyView(title: "Lorem Ipsum is simply dummy text of the printing", subTitle: "Lorem Ipsum is simply dummy text of the printing", content: "Lorem Ipsum is simply dummy text of the printing")
self.view.addSubview(myView)
myView.snp.makeConstraints { (make) in
make.width.equalToSuperview().multipliedBy(0.5)
make.centerX.centerY.equalToSuperview()
}
@dqhieu
dqhieu / MyView.swift
Last active September 10, 2017 07:55
import UIKit
import SnapKit
class MyView: UIView {
private var _titleLabel: UILabel!
private var _subTitleLabel: UILabel!
private var _contentLabel: UILabel!
init(title: String? = nil, subTitle: String? = nil, content: String? = nil) {
let myView = MyView(title: "Title", subTitle: "Sub title", content: "Content")
let myView2 = MyView(frame: .zero)
myView2.setTitle("Title", subTitle: "Sub title", content: "Content")