Giter VIP home page Giter VIP logo

refresh's Introduction

Hi there 👋

  • 🇨🇳 I’m an iOS developer in Beijing
  • 💻 Focusing on Swift & iOS
  • 🌟 Github is amazing, I hope to create more useful things here

My SwiftUI Frameworks:

  • SwiftUI-WeChat: 🇨🇳 Learn how to make WeChat with SwiftUI. 微信 7.0 🟢
  • VideoPlayer: 📽 A video player for SwiftUI, support for caching, preload and custom control view.
  • Refresh: 🎈 Great SwiftUI drop-down refresh and scroll up to load more. 下拉刷新、上拉加载
  • TabBar: 🚥 TabBar for SwiftUI - Make custom TabView possible.

My UIKit Frameworks:

  • SwiftTheme: 🎨 Powerful theme/skin manager for iOS 9+ 主题/换肤, 暗色模式
  • GSMessages: A simple style messages/notifications, in Swift.
  • GSImageViewerController: An image viewer controller with zoom transition, in Swift.
  • GSPlayer: ⏯ Video player, support for caching, preload, fullscreen transition and custom control view.
  • GSRefresh: Fully customizable drop-down refresh and load more. 下拉刷新、上拉加载
  • GSCaptchaButton: 为普通按钮增加验证码倒计时功能,不影响按钮样式
  • GSChange: Automatically synchronize changes, such as likes, follow, etc.
  • GSVerificationCode: 验证码控件,支持设置输入长度、自定义外观等
  • GSAlert: [deprecated] UIAlertController support iOS 7+ and written in swift.
  • GSPhotos: [deprecated] PhotosKit+ALAssetsLibrary, support iOS 7+ and written in swift.
  • POP-SnapKit: [deprecated] Use SnapKit with the Facebook Pop animation framework.

refresh's People

Contributors

markgravity avatar wxxsw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

refresh's Issues

Refresh and loadmore

@wxxsw When I refresh, the method of loading more will also run at the same time. When I enter the page for the first time, I have to refresh once to perform loading more, otherwise my loading more can only be performed once. nomore is set to false

Cannot use with lazygrid

ScrollView(.vertical) {
                        RefreshHeader(refreshing: $headerRefreshing, action: reload) { _ in
                            if headerRefreshing {
                                ProgressView()
                                    .progressViewStyle(CircularProgressViewStyle())
                            }
                        }
                        
                        
                        LazyVGrid(columns: vRule, spacing: 70) {
                            inCloudFile
                            
                            uploadingView
                        }
                        .padding(.top, 20)
                        .padding(.horizontal)

RefreshHeader 无限刷新

下拉刷新 好像在进行一个死循环操作

请求结束之后将headerRefreshing 设置为 false

不知道是不是 scroll没回跳 导致直接进入刷新状态

When using. enablerefresh()

When using. enablerefresh()
It will cover my entire screen and my custom components will be covered
What should be done? thank you

image

image

上拉加载出现异常

你好
我将FooterRefresh属性添加到ScrollView上,但是View在最底部.
没有上拉到一定高度,切换到其他View的时候,updata函数出现nil错误.

func update(proxy: GeometryProxy, value: Refresh.FooterAnchorKey.Value) {
guard let item = value.first else { return }
guard headerUpdate.progress == 0 else { return }

    let bounds = proxy[item.bounds]

在取得bounds的时候出现nil错误

头部刷新出现刷新两次问题

头部刷新触发了两次,导致接口请求了两次。
我发现是self.refreshing = true这行代码不起作用,打印时refreshing的值依然是false,所以导致触发了两次头部刷新。希望楼主看看是什么情况导致,谢谢!
触发头部刷新refreshing: false

        print("update.refresh:\(update.refresh) refreshing:\(refreshing) update.progress:\(update.progress)")
        if update.refresh, !refreshing, update.progress > 1.01 {
            DispatchQueue.main.async {
                self.refreshing = true
                print("触发头部刷新refreshing: \(refreshing)")
                self.action()
                print("触发头部刷新 end \(refreshing)")
            }
        }

控制台输出日志,如下:

update.refresh:false refreshing:false update.progress:0.7529411764705882
update.refresh:false refreshing:false update.progress:1.3176470588235296
update.refresh:false refreshing:false update.progress:1.7176470588235293
update.refresh:false refreshing:false update.progress:2.0117647058823533
update.refresh:false refreshing:false update.progress:2.0705882352941165
update.refresh:false refreshing:false update.progress:2.1882352941176486
update.refresh:false refreshing:false update.progress:2.800000000000001
update.refresh:false refreshing:false update.progress:3.305882352941175
update.refresh:false refreshing:false update.progress:3.9764705882352933
update.refresh:false refreshing:false update.progress:4.364705882352941
update.refresh:false refreshing:false update.progress:4.552941176470586
update.refresh:false refreshing:false update.progress:4.694117647058822
update.refresh:false refreshing:false update.progress:4.799999999999998
update.refresh:true refreshing:false update.progress:4.341176470588234
触发头部刷新refreshing: false
RefreshHeader
2023-01-17 10:36:02.422401+0800 live[39067:664952] [Debug] [main] [BaseVM.swift:47] onHeaderRefreshing() > 头部刷新 BlackListVM
触发头部刷新 end false
update.refresh:true refreshing:false update.progress:4.341176470588234
update.refresh:true refreshing:false update.progress:1.0
触发头部刷新 false
RefreshHeader
2023-01-17 10:36:02.431328+0800 live[39067:664952] [Debug] [main] [BaseVM.swift:47] onHeaderRefreshing() > 头部刷新 BlackListVM
触发头部刷新 end false
update.refresh:true refreshing:false update.progress:1.0
update.refresh:false refreshing:false update.progress:1.0

加了RefreshHeader后,当刷新数据后,无法跳转界面,如果点其它Tab后,会从其它Tap NavigationLink, 如果不加RefreshHeader,则可以跳转

无法跳转的代码

   NavigationLink {

                        DeviceDetailView()
                            .environmentObject(record)
                            .onAppear {
                                self.srecord = record
                            }

                    } label: {

                        DeviceRow().environmentObject(record)


                    }       

贴完整代码如下 :
VStack{
ScrollView {

        if records.count > 0 {
            
            RefreshHeader(refreshing: $headerRefreshing, action: {
                self.postEleList(refreshType: .refresh)
            }) { progress in
                if self.headerRefreshing {
                    SimpleRefreshingView()
                } else {
                    SimplePullToRefreshView(progress: progress)
                }
            }
            
        }
           
        
        if records.count > 0 {
            
            LazyVStack(spacing: 0) {
                
                ForEach(records,id:\.self) { record in
                    

                    NavigationLink {

                        DeviceDetailView()
                            .environmentObject(record)
                            .onAppear {
                                self.srecord = record
                            }

                    } label: {

                        DeviceRow().environmentObject(record)


                    }
                
                    
                }
                
            }
            .padding(.vertical)

            
        }else {
            DeviceLearnNoDataView()
        }
        
        if records.count > 0 {
            RefreshFooter(refreshing: $footerRefreshing, action: {
                self.postEleList(refreshType: .more)
            }) {
                if self.noMore {
                    Text("已加载完毕")
                        .modifier(WeiXiuLCContentFontModifier())
                        .padding()
                } else {
                    SimpleRefreshingView()
                        .padding()
                }
            }
            .noMore(noMore)
            .preload(offset: 50)
        }
        
    }
    .enableRefresh()
}

func postEleList(refreshType: RequestType){
    UtilsMacroSwift.show()
    let eleN = self.searchModel.eleName
    let eleAdd = self.searchModel.eleAddress
    eleVM.postEleList(refreshType: refreshType, status: status,eleName: eleN,eleAddress: eleAdd) {
        
        self.handRefresh(refreshType: refreshType)
        
    } failure: { str in
        
        self.handRefresh(refreshType: refreshType)
        
        UtilsMacroSwift.makeToast(str)
    }
    
}

func handRefresh(refreshType :RequestType?){
    DispatchQueue.main.async {
        UtilsMacroSwift.HUDDismiss()
        if refreshType == .refresh {
            self.headerRefreshing = false
            
        }
        else if refreshType == .more {
            self.footerRefreshing = false
            
        }
        else {
            self.headerRefreshing = false
            self.footerRefreshing = false
        }
        
        self.noMore = eleVM.isEnd
    }
}

我的工程结构如下 :
NavigationView{

        TabView(selection: $selection) {
            
            TongJiView()
                .tabItem {
                        
                    Label("统计", image: self.selection == .tongJi ? "tab_daiban_selected" : "tab_daiban_default")
                        
                }
                .tag(Tab.tongJi)
            
            DaiBanView()
                .tabItem {
                        
                    Label("待办", image: self.selection == .daiBan ? "tab_daiban_selected" : "tab_daiban_default")
                        
                }
                .tag(Tab.daiBan)
                
            
            
            DianTiView()
                .tabItem {
                    Label("电梯", image: self.selection == .dianTi ? "tab_dianti_selected" : "tab_dianti_default")
                }
                .tag(Tab.dianTi)
            
            
            MineView()
                .tabItem {
                    Label("我的", image: self.selection == .mine ? "tab_mine_selected" : "tab_mine_default")
                }
                .tag(Tab.mine)
            
        }
        .navigationTitle(selection.naviTitle)
        .navigationBarTitleDisplayMode(.inline)
        .navigationBarItems(
            leading:
                
                HStack {
                    if selection == .tongJi, let _ = accountVM.accountLoginModel?.token?.token {
                        HStack {
                           Text(tipStr)
                                .foregroundColor(.white)
                        }
                    }
                    
                },trailing: HStack {
                    if selection == .dianTi || selection == .daiBan {
                        Button(action: {
                           
                            NotificationCenter.default.post(name: .init(rawValue: kSearchNaviBarClickNotifiName), object: selection)
                            
                        }, label: {
   
                            Image("navi_search")
                            
                        })

                    }

                }
                
        )
        
        
    }

RefreshHeader遮挡导航栏部分,导致点击返回按钮无响应

只出现在定义的弹框中,弹框中没有导航栏。出现遮挡顶部的情况。(刷新中是可以正常点击返回,结束头部刷新点击返回无效。目前还没找到解决方法,谢谢)

/// pk记录列表
struct PkRecordListView: View {
    /// pk vm
    @StateObject var pkVm = PkVM()
    
    var body: some View {
        // 列表
        ScrollView {            
            // 头部刷新 坑:头部刷新导致点击返回按钮无响应
            if pkVm.recordList.count > 0 {
                RefreshHeader(refreshing: $pkVm.headerRefreshing, action: {
                    fetchRecordList(.header)
                }) { progress in
                    if pkVm.headerRefreshing {
                        SimpleRefreshingView()
                    } else {
                        SimplePullToRefreshView(progress: progress)
                            .frame(height: 16)
                            .background(.red)
                    }
                }
                //.frame(height: 40)
            }
            
            // 列表
            ForEach(pkVm.recordList, id: \.pk_id) { (item) in
                PkRecordListRow(item: item)
                    .frame(height: 125)
            }
            
            // 尾部刷新
            if pkVm.recordList.count > 0 {
                RefreshFooter(refreshing: $pkVm.footerRefreshing, action: {
                    fetchRecordList(.footer)
                }) {
                    if pkVm.noMore {
                        Text("No more data".localized())
                            .foregroundColor(.secondary)
                            .padding()
                    } else {
                        SimpleRefreshingView()
                            .padding()
                    }
                }
                .noMore(pkVm.noMore)
                .preload(offset: 50)
            }
        }
        // 启动刷新控件
        .enableRefresh()
        .background(.white)
        .overlay(
            VStack {
                if pkVm.recordList.isEmpty == true {
                    if pkVm.isNetError == true {
                        HolderView(image: "zy_emtpy_network", text: HOLDER_NET_ERROR_MSG, top: 0) {
                            fetchRecordList(.header)
                        }
                    } else {
                        HolderView(top: 0)
                    }
                } else {
                    EmptyView()
                }
            }
        )
//        .ignoresSafeArea()
        .onAppear {
            fetchRecordList(.default)
        }
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.