Giter Club home page Giter Club logo

ragismoothlist's Introduction

RagiSmoothList

Introduction

標準のリストコンポーネントで機能不足やパフォーマンス問題に遭遇した。
それらの問題を標準コンポーネントの使い方だけで解決するのは非常に困難だったので、
UICollectionView の力を借りて代替となるコンポーネントを作成した。

できること

  • Smooth Scroll
  • Pull to Refresh (refreshable)
  • Pagenation (load more)
  • Search UI (searchable)
MEMO
  • List の内部で使われているものについては Instruments で確認した
    • iOS SDK 16 and iOS 16 -> UICollectionView
    • iOS SDK 16 and iOS 15 -> UITableView
    • iOS SDK 15 and iOS 16 -> UITableView
    • iOS SDK 15 and iOS 15 -> UITableView
  • パフォーマンスの重大な問題
    • List or List + ForEach or ScrollView + LazyVStack + ForEach
      • Button を大量に並べただけで、まともにスクロールできない
        • Text に変更するだけで滑らかにスクロールできる...
        • 特に顕著なのは iPad mini 4th gen
        • iPhone 12 Pro でも、10,000件中 1,000 件を超えた辺りからスクロールが低速になる
    • List をうまく使うことでなんとか解決できないかと頑張ったが、どうにもならなかった
  • 機能不足の問題
    • Pull to Refresh
      • List and iOS 15 未満だと refreshable が使えない
    • Load More
      • スクロール領域の終端に到達した際の追加ロードの仕組みがない
      • ※ UIKit にも無い
    • セパレータのデザイン変更
      • List and iOS 15 未満だと listRowSeparator が使えない
      • List and iOS 15 未満だと listRowSeparatorTint が使えない

Requirements

  • iOS 14+
  • Xcode 14.x

Installation

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/ragingo/RagiSmoothList.git")
]

Usage

RagiSmoothList(
    data: $shops,
    listConfiguration: .init(
        separator: .init(isVisible: true, insets: .init(), color: .red),
        edit: .init(
            deleteButtonBackgroundColor: .yellow,
            deleteButtonImage: .remove
        ),
        animation: .init(mode: .fade)
    ),
    sectionHeaderContent: { section, items in
        Text("section header")
    },
    sectionFooterContent: { section, items in
        Text("section footer")
    },
    cellContent: { shop in
        Text(shop.name)
    }
)
.ragiSmoothListStyle(.insetGrouped)
.refreshable {
    refresh()
}
.searchable(text: $searchText, placeholder: "...")
.onLoadMore {
    loadMore()
}

Examples

このリポジトリにある RagiSmoothListExampleApp を参照してください

ragismoothlist's People

Contributors

ragingo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

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.