Swiftpack.co - avdyushin/SplitView as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by avdyushin.
avdyushin/SplitView 1.0.3
SplitView SwiftUI component
⭐️ 30
🕓 3 years ago
iOS macOS
.package(url: "https://github.com/avdyushin/SplitView.git", from: "1.0.3")

SplitView

Split View component for SwiftUI that allows to have two manually resizable views.

How to use?

Create SliderControlViewModel with middle position as protortion of full height and range for maximum and minumum expand.

let viewModel = SliderControlViewModel(
    middle: 0.5, // 50%
    range: 0.2...0.8 // 20%...80%
)

This view model has middle postion at half of full height of container.

Minimum position is 20% of height and maximum is 80% of height.

Create SplitView with viewModel and this three views:

  1. controlView is content view of the slider itself;
  2. topView is content view of the top view;
  3. bottomView is content view of the bottom view.
let view = SplitView(
    viewModel: viewModel,
    controlView: {
        Group {
            ZStack {
                RoundedRectangle(cornerRadius: 6)
                    .fill()
                    .frame(width: 24, height: 6)
            }
        }
        .foregroundColor(Color.green)
        .frame(minWidth: 0, maxWidth: .infinity)
    },
    topView: { Text("Top View") },
    bottomView: { Text("Bottom View") }
)

How to add it to Xcode project?

  1. In Xcode select File ⭢ Swift Packages ⭢ Add Package Dependency...
  2. Copy-paste repository URL: https://github.com/avdyushin/SplitView
  3. Hit Next two times, under Add to Target select your build target.
  4. Hit Finish

GitHub

link
Stars: 30
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics