Skip to content

Instantly share code, notes, and snippets.

View stleamist's full-sized avatar

Dongkyu “Max” Kim stleamist

View GitHub Profile
import SwiftUI
struct _DisclosureIndicator: View {
var body: some View {
Image(systemName: "chevron.forward")
.imageScale(.small)
.font(.body.weight(.semibold))
.foregroundColor(.primary.opacity(0.25))
}
}
@stleamist
stleamist / MailComposer.swift
Last active June 2, 2021 13:28
MFMailComposeViewController for SwiftUI
import MessageUI
import SwiftUI
struct MailComposer {
struct MessageBody {
var body: String
var isHTML: Bool
}
#!/bin/sh
PRODUCT_BUNDLE_VERSION=$(date "+%Y%m%d%H%M")
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${PRODUCT_BUNDLE_VERSION}" "${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${PRODUCT_BUNDLE_VERSION}" "${PROJECT_DIR}/${INFOPLIST_FILE}"
import Swift
extension Result {
func casting<NewSuccess, NewFailure>() -> Result<NewSuccess, NewFailure>? {
switch self {
case .success(let success as NewSuccess) where Failure.self is NewFailure.Type: return .success(success)
case .failure(let failure as NewFailure) where Success.self is NewSuccess.Type: return .failure(failure)
default: return nil
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import Combine
public extension Publisher {
func replaceError(with transform: @escaping (Self.Failure) -> Self.Output) -> Publishers.Catch<Self, Publishers.ReplaceError<Self>> {
return self.catch { error in
return self.replaceError(with: transform(error))
}
}
}
import Combine
public extension Publisher {
func flatMap<P: Publisher>(
_ transformPublisher: @escaping (Self.Output) -> P,
mapError transformError: @escaping (Self.Failure) -> P.Failure
) -> Publishers.FlatMap<P, Publishers.MapError<Self, P.Failure>> {
return self.mapError(transformError).flatMap(transformPublisher)
}
}

Keybase proof

I hereby claim:

  • I am stleamist on github.
  • I am stleamist (https://keybase.io/stleamist) on keybase.
  • I have a public key ASCNCRWLObI6Fp1T6C3xNmUPZpN6hN7FBTnIxkU952iDvQo

To claim this, I am signing this object:

import UIKit
/*
EXAMPLE:
let hangulCharacterSet = CharacterSet(charactersIn: "가"..."힣").union(CharacterSet(charactersIn: "ㄱ"..."ㆎ"))
let nanumGothicDescriptor = UIFontDescriptor(name: "NanumGothic", size: 17).addingCharacterSet(hangulCharacterSet)
let font = UIFont.systemFont(ofSize: 17).addingFrontCascadeDescriptors([nanumGothicDescriptor])
let label = UILabel()
label.font = font
import SwiftUI
extension View {
@ViewBuilder
func modify<Modified: View>(@ModifiedViewBuilder modificationBlock: (Self) -> Modified) -> some View {
let modified = modificationBlock(self)
if modified is EmptyView {