Skip to content

Instantly share code, notes, and snippets.

Avatar

Ihwan IhwanID

View GitHub Profile
@pitt500
pitt500 / TCA_CounterDemo.swift
Created September 17, 2022 22:00
More context about this demo here: https://youtu.be/SfFDj6qT-xg
View TCA_CounterDemo.swift
import SwiftUI
import ComposableArchitecture
struct State: Equatable {
var counter = 0
}
enum Action: Equatable {
case increaseCounter
@JSerZANP
JSerZANP / ContentView.swift
Created March 4, 2021 14:01
communication between native(swiftUI) and wkwebview
View ContentView.swift
import SwiftUI
import WebKit
struct WebView: UIViewRepresentable {
class Coordinator: NSObject, WKNavigationDelegate, WKScriptMessageHandler {
var webView: WKWebView?
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
self.webView = webView
}
@nicnocquee
nicnocquee / pokemon-fetch-combine.swift
Created February 5, 2021 17:41
sample of fetching list of pokemon using swift combine
View pokemon-fetch-combine.swift
import UIKit
import Combine
struct PokemonResponse: Codable{
let results: [Pokemon]
}
struct Pokemon: Codable{
let name: String
View DatePickerTextField.swift
import SwiftUI
import UIKit
final class DatePickerTextField: UITextField {
@Binding var date: Date?
private let datePicker = UIDatePicker()
init(date: Binding<Date?>, frame: CGRect) {
self._date = date
super.init(frame: frame)
@JohnSundell
JohnSundell / StarPlane.swift
Created July 8, 2020 22:41
A simple game written in SwiftUI. Note that this is just a fun little hack, the code is not meant to be taken seriously, and only works on iPhones in portrait mode.
View StarPlane.swift
// A fun little game written in SwiftUI
// Copyright (c) John Sundell 2020, MIT license.
// This is a hacky implementation written just for fun.
// It's only verified to work on iPhones in portrait mode.
import SwiftUI
final class GameController: ObservableObject {
@Published var plane = GameObject.plane()
@Published private(set) var clouds = [GameObject]()
@jordansinger
jordansinger / LockScreen.swift
Created May 11, 2020 23:24
Let’s recreate the iPhone lock screen using SwiftUI and Swift Playgrounds on iPad
View LockScreen.swift
import SwiftUI
import PlaygroundSupport
struct Screen: View {
var body: some View {
ScrollView {
VStack {
Text("5:45").font(.system(size: 64, weight: .thin))
Text("Monday, May 11").font(.system(size: 24))
}.padding(.vertical, 32)
@mecid
mecid / Calendar.swift
Last active February 2, 2023 07:18
SwiftUI Calendar view using LazyVGrid
View Calendar.swift
import SwiftUI
extension Calendar {
func generateDates(
inside interval: DateInterval,
matching components: DateComponents
) -> [Date] {
var dates: [Date] = []
dates.append(interval.start)
@ihrankouski
ihrankouski / example.dart
Created April 21, 2020 21:52
Chewie: "autoFullScreenOnLandscape" + "autoLandscapeOnFullScreen"
View example.dart
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:video_player/video_player.dart';
import 'package:orientation/orientation.dart';
import 'package:chewie/chewie.dart';
@shial4
shial4 / DateField.swift
Last active June 4, 2021 14:55
SwiftUI text field with date picker as keyboard accessory view and toolbar with done button
View DateField.swift
//
// DateField.swift
//
// Created by Szymon Lorenz on 22/2/20.
// Copyright © 2020 Szymon Lorenz. All rights reserved.
//
import SwiftUI
struct DateTextField: UIViewRepresentable {
@ampersanda
ampersanda / how_to_use_in_sliver.dart
Last active January 20, 2020 09:47
delegate of SliverPersistentHeader
View how_to_use_in_sliver.dart
SliverPersistentHeader(
delegate: SliverAppBarDelegate((context, _, __, progress) => HistoryPersistentHeaderTile(),
collapsedHeight: Dimensions.fixedHeaderHeight,
expandedHeight: Dimensions.fixedHeaderHeight),
pinned: true),