Skip to content

Instantly share code, notes, and snippets.

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

Enes Karaosman EnesKaraosman

🏠
Working from home
View GitHub Profile
struct ChatUser: Identifiable {
var id = UUID()
var userName: String
var avatar: UIImage?
}
@EnesKaraosman
EnesKaraosman / chat_message_kind.swift
Last active August 4, 2020 10:01
ChatMessageKind
enum ImageLoadingKind {
case local(UIImage)
case remote(URL)
}
enum ChatMessageKind {
case text(String)
case image(ImageLoadingKind)
case location(LocationItem)
case contact(ContactItem)
struct ChatMessage: Identifiable {
var id = UUID()
var user: ChatUser
var messageKind: ChatMessageKind
var isSender: Bool
var date: Date
}
@EnesKaraosman
EnesKaraosman / SingleSelectionList.swift
Created July 9, 2020 10:19
Single item selection in a list in SwiftUI
struct SingleSelectionList<Item: Identifiable, Content: View>: View {
var items: [Item]
@Binding var selectedItem: Item?
var rowContent: (Item) -> Content
var body: some View {
List(items) { item in
rowContent(item)
.modifier(CheckmarkModifier(checked: item.id == self.selectedItem?.id))
@EnesKaraosman
EnesKaraosman / MailView.swift
Created December 10, 2020 05:48
Mail composer in SwiftUI
// https://stackoverflow.com/questions/56784722/swiftui-send-email
public struct MailView: UIViewControllerRepresentable {
@Environment(\.presentationMode) var presentation
@Binding var result: Result<MFMailComposeResult, Error>?
public var configure: ((MFMailComposeViewController) -> Void)?
public class Coordinator: NSObject, MFMailComposeViewControllerDelegate {
@Binding var presentation: PresentationMode