Skip to content

Instantly share code, notes, and snippets.

View damodarnamala's full-sized avatar

Damodar damodarnamala

  • Hyderabad
View GitHub Profile
//
// ContentView.swift
// ToolTOPS
//
// Created by Damodar Namala on 02/02/22.
//
import SwiftUI
import Combine
struct ContentView: View {
let keyboard: UIKeyboardType = .emailAddress
@State var text = ""
var body: some View {
Text("Hello, world!")
.padding()
TextField("Home", text: $text.limit(by: 10).trim(.numeric))
.keyboardType(keyboard)
import Foundation
import SwiftUI
extension CharacterSet {
static let accountNumberSet = CharacterSet.letters.union(CharacterSet(charactersIn: " "))
}
struct TitledInputField: View {
let title: String
@damodarnamala
damodarnamala / Decimaltextfield.swift
Last active March 24, 2022 14:47
SwiftUI Custom textfield for placeholder and manager currency
//
// ContentView.swift
// Amount
//
// Created by Damodar Namala on 25/02/22.
//
import SwiftUI
import Combine
var sides: Sides = .east
struct ContentView: View {
@State var animate = false
var body: some View {
VStack {
Text("Hi")
}.onAppear {
sides.apply { side in
side = .north
@damodarnamala
damodarnamala / SequenceExtention.swift
Last active April 8, 2022 07:02
Sequence Extension
extension Sequence {
public func inspect(_ body: (Element) throws -> Void) rethrows -> Self {
for element in self {
try body(element)
}
return self
}
}
extension Sequence {
@damodarnamala
damodarnamala / Designsystem.swift
Created April 8, 2022 12:21
DesignSystem Example
struct ContentView: View {
var body: some View {
HStack {
Rectangle()
.frame(width: 200, height: 200, alignment: .center)
}.card()
}
}
@damodarnamala
damodarnamala / Features.swift
Created April 11, 2022 06:58
Example for features
protocol Feature {
static func load()
}
class LoginFeature: Feature {
static func load() {
print("loging in with")
}
}
typealias Effect<A> = (A) -> A
var effect: Effect<String> = { str in
return str
}
// Ussage:
print(effect("Damodar"))
@damodarnamala
damodarnamala / ListComposingWithFilters.swift
Last active April 12, 2022 14:49
Composing List with sorting options
struct Country: Comparable, Identifiable {
static func < (lhs: Country, rhs: Country) -> Bool {
return lhs.name < rhs.name && lhs.code < rhs.code
}
var code: String
var name: String
var id = UUID()
}
let countries = [