Skip to main content
Version: 12.10.0

OCDialog

Introduction

OCDialog component can be used to show information/ obtain decision from users. It appears as an overlay to the content it was added to.

OCDialog

OCDialog is developed as a view modifier and can be configured to show 3 types of dialog namely basic, bubbled, illustrative. The actions in dialog can be given using actions view builder. OCDialog init takes 4 parameters,

  1. isPresented, a binding bool to show/ hide the dialog
  2. type, OCDialogType, denotes which type of dialog to be shown
  3. configuration, OCDialogConfigurationProtocol, has all the necessary fonts, colors padding configuration
  4. onCloseClick: Optional completion for close icon click
  5. actions, a view builder that accepts the buttons to be shown for the dialog

Integration

import SwiftUI

struct ContentView: View {
// MARK: - Properties

@State private var isPresented: Bool = false

var primaryButton: OCButton {
OCButton(title: "Some title Primary",
type: .primaryDanger,
maxWidth: .infinity)
}

var secondaryButton: OCButton {
OCButton(title: "Some title Secondary", type: .secondary,
maxWidth: .infinity)

}

var textButton: OCButton {
OCButton(title: "Some title Text",
type: .textButton(hasUnderline: false))
}

var configuration = OCDialogConfiguration(title: "A longer title can extend over multiple lines ",
description: "A longer title can extend over multiple lines")

var body: some View {
Text("Show/hide dialog")
.onTapGesture {
isPresented.toggle()
}
.ocDialog(isPresented: $isPresented,
type: .bubbled(),
configuration: configuration) {
primaryButton
secondaryButton
}
}
}