Skip to content

Instantly share code, notes, and snippets.

View SwiftyAlex's full-sized avatar

Alex Logan SwiftyAlex

View GitHub Profile
@propertyWrapper
class Title {
var wrappedValue: UILabel
init(text: String) {
self.wrappedValue = UILabel()
wrappedValue.text = text
configureLabel()
}
import UIKit
@propertyWrapper class Card {
var wrappedValue: UIView
init(wrappedValue: UIView) {
self.wrappedValue = wrappedValue
applyCornerRadius()
applyCardShadow()
}
import Combine
import UIKit
@propertyWrapper
class ImageDownloading {
var wrappedValue: UIImageView
private var cancellable: AnyCancellable?
init(wrappedValue: UIImageView, url: URL?, urlSession: URLSession) {
self.wrappedValue = wrappedValue
struct HomeView: View {
let featuredPodcasts: [Podcast]
let popularPodcasts: [Podcast]
let yourPodcasts: [Podcast]
var body: some View {
NavigationView {
VStack(alignment: .leading) {
Text("Welcome to SwiftUI")
// New View
struct PodcastScrollView: View {
var content: [Podcast]
var body: some View {
ScrollView(.horizontal) {
HStack {
ForEach(content, id: \.self) { _ in
RoundedRectangle(cornerRadius: 22, style: .continuous)
.foregroundColor(Color.blue)
// Container View
struct SomeView: View {
var body: some View {
VStack {
Text("Welcome to our SwiftUI app")
.font(.custom("Montserrat-Bold", size: 16))
.foregroundColor(.textBlack)
.padding()
FeaturedContentView()
ArticlesScrollView()
// Container View
struct SomeView: View {
var body: some View {
VStack {
Text("Welcome to our SwiftUI app")
.modifier(CompanyHeaderLabel())
FeaturedContentView()
ArticlesScrollView()
FooterView()
}
// Container View
struct SomeView: View {
var body: some View {
VStack {
Text("Welcome to our SwiftUI app")
.companyStyled()
FeaturedContentView()
ArticlesScrollView()
FooterView()
}
@SwiftyAlex
SwiftyAlex / WelcomeView.swift
Created August 30, 2020 11:29
SwiftUI Welcome View
//
// WelcomeView.swift
// iOS
//
// Created by Alex Logan on 30/08/2020.
//
import SwiftUI
struct WelcomeView: View {
@SwiftyAlex
SwiftyAlex / AsyncBrew.swift
Created June 7, 2021 22:14
Async brew fetching.
struct Coffee: Hashable {
let name: String
}
class CoffeeStore: ObservableObject {
func getCoffee() async -> [Coffee] {
Thread.sleep(forTimeInterval: 2)
return [
Coffee(name: "Cortado"),
Coffee(name: "Flat White")