This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
let collums = [ | |
/// define number of caullum here | |
GridItem(.flexible()), | |
GridItem(.flexible()) | |
] | |
var body: some View { | |
ScrollView(.vertical) { //set .horizontal to scroll horizontally | |
LazyVGrid(columns: collums) { // use HGrid to layout horizontally | |
ForEach(0...50, id: \.self) { i in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct Row { | |
var value: Int | |
init(value: Int) { | |
print("INIT: \(value)") // see init calls with scroll in case of lazy loading | |
self.value = value | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct Chips: View { | |
let systemImage: String //pass system image | |
let titleKey: LocalizedStringKey //text or localisation value | |
@State var isSelected: Bool | |
var body: some View { | |
HStack { | |
Image.init(systemName: systemImage).font(.title3) | |
Text(titleKey).font(.title3).lineLimit(1) | |
}.padding(.all, 10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ChipsContent: View { | |
@ObservedObject var viewModel = ChipsViewModel() | |
var body: some View { | |
var width = CGFloat.zero | |
var height = CGFloat.zero | |
return GeometryReader { geo in | |
ZStack(alignment: .topLeading, content: { | |
ForEach(viewModel.dataObject) { chipsData in //loop to render all chips | |
Chips(systemImage: chipsData.systemImage, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// ios14-demo | |
// | |
// Created by Prafulla Singh on 23/6/20. | |
// | |
import SwiftUI | |
struct ChipsDataModel: Identifiable { | |
let id = UUID() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Created by Prafulla Singh on 23/6/20. | |
// | |
import SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
ScrollView { | |
LazyHStack { | |
PageView() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Created by Prafulla Singh on 29/6/20. | |
// | |
import SwiftUI | |
struct FamilyTree: Identifiable { | |
let id = UUID() | |
let name: String | |
let childrens: [FamilyTree]? | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct StickyLayoutGrid: View { | |
let columns: [GridItem] = Array(repeating: .init(.flexible()), count: 3) | |
var body: some View { | |
NavigationView { | |
ScrollView(.vertical) { //set .horizontal to scroll horizontally | |
///pinnedViews: [.sectionHeaders] => set header or footer you want to pin. if do not want to pin leave empty, sectionFooters => for sticky footer | |
LazyVGrid(columns: columns, spacing: 10, pinnedViews: [.sectionHeaders]) { | |
Section(header: headerView(type: "Grid")) { | |
ForEach(0..<10) { i in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import os | |
@main | |
struct ios14DemoApp: App { | |
@StateObject var notificationCenter = NotificationCenter() | |
@UIApplicationDelegateAdaptor private var appDelegate: AppDelegate | |
var body: some Scene { | |
WindowGroup { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct PhotoPicker: UIViewControllerRepresentable { | |
func makeUIViewController(context: Context) -> PHPickerViewController { | |
//init PHPickerViewController here | |
} | |
func updateUIViewController(_ uiViewController: PHPickerViewController, context: Context) { | |
} | |