Skip to content

Instantly share code, notes, and snippets.

View ljbatwh's full-sized avatar

jianbing li ljbatwh

View GitHub Profile
@ljbatwh
ljbatwh / SwiftUI do not sport multiple alerts on same View.md
Created September 16, 2020 19:44
SwiftUI do not sport multiple alerts on same View

SwiftUI do not sport .alert on same View, even not on the children of View for example

  1. on same view can ont work View.alert().alert()
  2. on the children of View also don't work HStack{ View.alert() }.alert()

Workaround

@ljbatwh
ljbatwh / SwiftUI Previews pasued by some rebuild.md
Created September 11, 2020 07:53
SwiftUI Previews pasued by some rebuild
  1. enable new build system if you use Legacy Build System.

File -> Project Settings (or Workspace Settings) -> Build System -> Choose "New Build System(Default).

  1. skip script in build pharse by check checkbox "Run script only when installing" or
if [ $ENABLE_PREVIEWS == "NO" ]
   then
  # your code to execute here
else
@ljbatwh
ljbatwh / PagerManager.swift
Created August 9, 2020 22:47
swiftui page controller
import SwiftUI
struct PagerManager<Content: View>: View {
let pageCount: Int
@Binding var currentIndex: Int
let content: Content
//Set the initial values for the variables
init(pageCount: Int, currentIndex: Binding<Int>, @ViewBuilder content: () -> Content) {
self.pageCount = pageCount
@ljbatwh
ljbatwh / composing-software.md
Created May 27, 2020 02:35 — forked from Geoff-Ford/composing-software.md
Eric Elliott's Composing Software Series

Eric Elliott's "Composing Software" Series

A collection of links to the excellent "Composing Software" series of medium stories by Eric Elliott.

Edit: I see that each post in the series now has index, previous and next links. However, they don't follow a linear flow through all the articles with some pointing back to previous posts effectively locking you in a loop.

@ljbatwh
ljbatwh / createMatrix
Last active May 13, 2020 21:39
create a matrix in javascript
function matrix(r,c,initialValue){
Array(r).fill(initialValue).map(()=>Array(c).fill(initialValue))
}