`SimpleExpandableView` is a SwiftUI view which can collapse and expand the content

Overview

SimpleExpandableView

Banner

中文说明

Demo

ExpandableView structure

Structure

Example

ExpandableView(
    headerSize: CGSize(width: 250.0, height: 50.0),
    cardSize: CGSize(width: 250.0, height: 250.0), header: {
        Text("Hello world")
            .foregroundColor(.white)
            .frame(maxWidth: .infinity, maxHeight: .infinity)
            .background(LinearGradient(colors: [.blue, .cyan], startPoint: .top, endPoint: .bottom))
    }, content: {
        VStack {
            Image(systemName: "heart.fill")
                .resizable()
                .frame(width: 180, height: 180)
            Text("Hi")
                .font(.title2)
        }
        .foregroundColor(.white)
    })
.cardBackgroundColor(.cyan)
.shadow(shadowRadius: 0.0)
.listRowSeparator(.hidden)
.frame(maxWidth: .infinity) // align center
.padding(.vertical, 5.0)

To run the example project, clone the repo, and run pod install from the Example directory first.

ExpandableView Interfaces

Initialization

init(
    headerSize: CGSize,
    cardSize: CGSize,
    @ViewBuilder header: () -> Header,
    @ViewBuilder content: () -> Content,
    onTapped action: (() -> ())? = nil // action to do when the header view is tapped
)

Methods

// Change the background color of header view
func headerBackgroundColor(_ color: Color)

// Change the background color of the card view
func cardBackgroundColor(_ color: Color)

// Change the corner radius of the header view
func headerCornerRadius(_ radius: CGFloat)

// Change the corner radius of the card view
func cardCornerRadius(_ radius: CGFloat)

// Change the shadow of the whole view (both header view and card view will render shadow)
func shadow(shadowRadius: CGFloat = 6.0, color: Color = .gray, x: CGFloat = 0.0, y: CGFloat = 0.0)

// Determine the height of the card view by the `contentView` you passed instead of a fixed height
func dynamicCardHeight()

ExpandableViewsGroup Interfaces

Initialization

// Share the same `headerView`
init<Header>(
    headerSize: CGSize,
    cardSize: CGSize,
    headerView:  () -> Header,
    contentViews: () -> [AnyView]
) where Header : View

// Using generics
init<Header, Content>(
    headerSize: CGSize,
    cardSize: CGSize,
    headerViews:  () -> [Header],
    contentViews: () -> [Content]
)  where Header : View, Content : View

// Using AnyView array
init(
    headerSize: CGSize,
    cardSize: CGSize,
    headerViews:  () -> [AnyView],
    contentViews: () -> [AnyView]
)

// Using variadic parameters
init(
    headerSize: CGSize,
    cardSize: CGSize,
    headerViews:  AnyView...,
    contentViews: AnyView...
)

Methods

// Set the vertical spacing between two `ExpandableView`
func verticalSpacing(_ spacing: CGFloat)

// Change the background color of the group
func backgroundColor(_ color: Color)

// Change the background color of all header views
func headersBackgroundColor(_ color: Color)

// Change the background color of all card views
func cardBackgroundColor(_ color: Color)

// Change the corner radius of all header views
func headerCornerRadius(_ radius: CGFloat)

// Change the corner radius of all card views
func cardCornerRadius(_ radius: CGFloat)

// Change the shadow of all views in the group (header views and card views included)
func shadow(shadowRadius: CGFloat = 6.0, color: Color = .gray, x: CGFloat = 0.0, y: CGFloat = 0.0)

// Set all `ExpandableView` in the group with `.dynamicCardHeight()`
func dynamicCardHeight()

Execute Xcode's Product > Build Documentation and go to SimpleExpandableView's documentation for more details.

Requirements

Swift >= 5.0

Installation

SimpleExpandableView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SimpleExpandableView'

# Note that if cocoapods cannot find `SimpleExpandableView`, please try the command below
# pod `SimpleExpandableView`, :git => 'https://github.com/Tomortec/SimpleExpandableView.git'

Author

Tomortec, [email protected]

License

SimpleExpandableView is available under the MIT license. See the LICENSE file for more info.

You might also like...
ExpandableText 😎 (SwiftUI) Expand the text with the
ExpandableText 😎 (SwiftUI) Expand the text with the "more" button

ExpandableText 😎 (SwiftUI) Expand the text with the "more" button Get Started import SwiftUI import ExpandableText struct ExpandableText_Test: View

Appstore card animation transition. UICollectionView and UITableView card expand animated transition
Appstore card animation transition. UICollectionView and UITableView card expand animated transition

Appstore card animation transition. UICollectionView and UITableView card expand animated transition. This library tries to add the appstore transition to your own app. The goal is to be as simple as possible to integrate in an app while keeping the flexibility and customization alive.

Multiliner - An Xcode source extension to expand lengthy lines
Multiliner - An Xcode source extension to expand lengthy lines

Multiliner An Xcode source extension to expand lengthy lines. Super lightweight, 1 file. It expands long lines. That's it! Works with: Initializers Fu

An easy-to-use UITableViewCell subclass that implements a swippable content view which exposes utility buttons (similar to iOS 7 Mail Application)
An easy-to-use UITableViewCell subclass that implements a swippable content view which exposes utility buttons (similar to iOS 7 Mail Application)

SWTableViewCell An easy-to-use UITableViewCell subclass that implements a swipeable content view which exposes utility buttons (similar to iOS 7 Mail

A framework that provides CurtainController. CurtainController is a container view controller that implements a content-curtain interface. You can find a similar implementation in applications like Apple Maps, Find My, Stocks, etc. Someone calls it Media view which subclasses UIImageView, and can display & load images, videos, GIFs, and audio and from the web, and has functionality to minimize from fullscreen, as well as show GIF previews for videos.
Media view which subclasses UIImageView, and can display & load images, videos, GIFs, and audio and from the web, and has functionality to minimize from fullscreen, as well as show GIF previews for videos.

I've built out the Swift version of this library! Screenshots Description ABMediaView can display images, videos, as well as now GIFs and Audio! It su

MrCode is a simple GitHub iPhone App that can cache Markdown content (include images in HTML) for read it later.
MrCode is a simple GitHub iPhone App that can cache Markdown content (include images in HTML) for read it later.

MrCode is a simple GitHub iPhone App that can cache Markdown content (include images in HTML) for read it later.

SwiftUI view enabling navigation between pages of content, imitating the behaviour of UIPageViewController for iOS and watchOS
SwiftUI view enabling navigation between pages of content, imitating the behaviour of UIPageViewController for iOS and watchOS

PageView SwiftUI view enabling page-based navigation, imitating the behaviour of UIPageViewController in iOS. Why SwiftUI doesn't have any kind of pag

A SwiftUI view for dynamically rendering content based upon "loading", "error", and "completed" data loading states.

SwiftUIAsyncContentView A SwiftUI view for dynamically rendering content based upon "loading", "error", and "completed" data loading states.. Installa

A SwiftUI Library for creating resizable partitions for View Content.
A SwiftUI Library for creating resizable partitions for View Content.

Partition Kit Recently Featured In Top 10 Trending Android and iOS Libraries in October and in 5 iOS libraries to enhance your app! What is PartitionK

A SwiftUI ScrollView that only scrolls if the content doesn't fit in the View

ScrollViewIfNeeded A SwiftUI ScrollView that only scrolls if the content doesn't fit in the View Installation Requirements iOS 13+ Swift Package Manag

Simple Alert View written in Swift, which can be used as a UIAlertController. (AlertController/AlertView/ActionSheet)
Simple Alert View written in Swift, which can be used as a UIAlertController. (AlertController/AlertView/ActionSheet)

DOAlertController Simple Alert View written in Swift, which can be used as a UIAlertController replacement. It supports from iOS7! It is simple and ea

A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView and iPhone X safe area support for content reloading. Built for iOS 10 and later.

Arale A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView support for reloading your content. Built f

A controller that uses a UIStackView and view controller composition to display content in a list
A controller that uses a UIStackView and view controller composition to display content in a list

StackViewController Overview StackViewController is a Swift framework that simplifies the process of building forms and other static content using UIS

A Splash view that animates and reveals its content, inspired by Twitter splash
A Splash view that animates and reveals its content, inspired by Twitter splash

RevealingSplashView A Splash view that animates and reveals its content, inspired by the Twitter splash. ⭐ Features Customizable reveal icon image. Cu

The ultimate spinning wheel view that supports dynamic content and rich customization.
The ultimate spinning wheel view that supports dynamic content and rich customization.

The ultimate spinning wheel control that supports dynamic content and rich customization. Main Features 🏵 Dynamic content, supports texts, images, an

A Splash view that animates and reveals its content, inspired by Twitter splash
A Splash view that animates and reveals its content, inspired by Twitter splash

RevealingSplashView A Splash view that animates and reveals its content, inspired by the Twitter splash. ⭐ Features Customizable reveal icon image. Cu

Audio player demo based on Swift and SwiftUI, which can play local or network audio.
Audio player demo based on Swift and SwiftUI, which can play local or network audio.

SwiftAudioDemo Audio player demo based on Swift and SwiftUI, which can play local or network audio. In this demo, I have made a radio player to play n

Owner
Tomortec
An innovation team whose members include @LMLAZ @TomortecAlbert
Tomortec
📃 FoldingCell is an expanding content cell with animation made by @Ramotion

FOLDING CELL Expanding content cell with animation inspired by folding paper card material design. We specialize in the designing and coding of custom

Ramotion 10.1k Jan 2, 2023
Three Level Accordian View for IOS

ThreeLevelAccordian ThreeLevelAccordian is a three level accordian for IOS. It owes its base code to SwiftyAccordionCells. Most of the design is custo

Amrata Baghel 44 Sep 23, 2022
Savory is swift accrodion view implementation

Savory Savory is a swift accordion view implementation. Requirements Xcode 8.0 Swift 3.0 iOS 8 Installation Using CocoaPods: pod 'Savory', :git => 'ht

Nandin Borjigin 4 May 30, 2019
Make your table view expandable just by implementing one method.

ExpyTableView About ExpyTableView is a re-write based on SLExpandableTableView. Takes some ideas, concepts and codes and regenerates them in Swift. Le

Okhan Okbay 359 Dec 27, 2022
Swift library to support collapsible sections in a table view.

CollapsibleTableSectionViewController A Swift library that helps you collapse table view sections. Features Support collapsible sections in a table vi

Su 349 Dec 18, 2022
Collapse and expand UICollectionView sections with one method call.

This library provides a custom UICollectionView that allows to expand and collapse sections. Provides a simple API to manage collection view appearanc

Touchlane 172 Dec 26, 2022
Simple and lightweight UITableViewController with accordion effect (expand / collapse cells)

AEAccordion UITableViewController with accordion effect (expand / collapse cells) Simple and lightweight solution for making accordion effect in table

Marko Tadić 211 Apr 18, 2022
INTUZ is presenting an interesting a Multilevel Expand/Collapse UITableView App Control to integrate inside your native iOS-based application

INTUZ is presenting an interesting a Multilevel Expand/Collapse UITableView App Control to integrate inside your native iOS-based application. MultilevelTableView is a simple component, which lets you use the tableview with multilevel tree view in your project.

INTUZ 3 Oct 3, 2022
A nice iOS View Capture Swift Library which can capture all content.

SwViewCapture A nice iOS View Capture Library which can capture all content. SwViewCapture could convert all content of UIWebView to a UIImage. 一个用起来还

Xing Chen 597 Nov 22, 2022
A SwiftUI bottom-up controller, like in the Maps app. Drag to expand or minimize.

SwiftUI Drawer A SwiftUI bottom-up controller, like in the Maps app. Drag to expand or minimize. Contents Add the Package Basic Usage Examples Credits

Michael Verges 695 Jan 3, 2023