Skip to main content
Version: Next

OCAccordionList

Introduction

'OCAccordionList' is a list of accordion items that conform to 'OCAccordionStyle' protocol.

Features

  • Supports 4 different styles of content for each item.
  • Each item can be enabled and disabled.
  • Supports accessibility features for improved user experience.

OCAccordionList

'OCAccordionList' is custom view item that is built using 'List'. It can be configured to show different styles of accordions. 'OCAccordionList' constructor takes 3 parameters

  1. accordionList, list of accordion items
  2. initiallyOpenAccordionIndex, index can be specified for initially open accordion
  3. onOpenAccordionClick, completion for notifying the item click

Integration

import SwiftUI

struct ContentView: View {

/// List of configurations of accordion
var configurationList: [OCAccordionStyle] {
[
OCAccordionConfiguration(accordionState: .enabled,
title: "Title 1",
contentType: .text("Title description")),
OCAccordionConfiguration(accordionState: .disabled,
title: "Title 2",
contentType: .text("qwerty")),
OCAccordionConfiguration(accordionState: .enabled,
title: "Title 3",
contentType: .textWithButton(detail: "Dies ist ein Typoblindtext. An ihm kann man sehen, ob alle Buchstaben da sind und wie sie aussehen. Manchmal benutzt man Worte wie Hamburgefonts, Rafgenduks oder Handgloves, um Schriften zu testen.",
buttonTitle: "Click",
buttonOnClick: {
debugPrint("Clicked 3rd accordion content button")
}))]
}

var body: some View {
OCAccordionList(accordionList: configurationList,
initiallyOpenAccordionIndex: 2) { item in
debugPrint(item.title)
}
}

}