A SwiftUI Library for creating resizable partitions for View Content.

Overview

Partition Kit

partition kit logo

Recently Featured In Top 10 Trending Android and iOS Libraries in October and in 5 iOS libraries to enhance your app!

grid

What is PartitionKit?

  • It is the solution to the need for composable and dynamically sized user interface content in SwiftUI.
  • also the first piece of software I have ever made into a library so please be gentle(both with use cases and with my heart).

What PartitionKit is not ?

  • PartitionKit is not a means to work with an form of stored data, this is not for partitioning hard drives or any other type of formattable data drive.

Requirements

PartitionKit as a default requires the SwiftUI Framework to be operational, as such only these platforms are supported:

  • macOS 10.15 or Greater
  • iOS 13 or Greater
  • tvOS 13 or Greater
  • watchOS 6 or Greater

How To Add To Your Project

  1. Snag that URL from the github repo
  2. In Xcode -> File -> Swift Packages -> Add Package Dependencies
  3. Paste the URL Into the box
  4. Specify the minimum version number (This is new so 1.0.0 and greater will work).

Less Than 2 Minute Tutorial Video

Tutorial Video: How To Use PartitionKit

How To Use

Vertical Partition

  1. Decide on what view you would like to have on Top, which you would like to have on the Bottom and optionally a Handle to be used to drag the partitions to different sizes.
  2. Do This
VPart(top: {
    MyTopView()
    }, bottom: {
    MyBottomView()
    }) {
    MyHandle()
}

Horizontal Partition

  1. Decide on what view you would like to have on Left, which you would like to have on the Right and optionally a Handle to be used to drag the partitions to different sizes.
  2. Do This
HPart(left: {
    MyLeftView()
    }, right: {
    MyRightView()
    }) {
    MyHandle()
}

GridPartition

  1. Decide on what Views will go in each corner TopLeft, TopRight, BottomLeft, BottomRight and optionally a Handle for the user to drag and resize the views with.
  2. Do this
    GridPart(topLeft: {
        MyTopLeftView()
        }, topRight: {
        MyTopRightView()
        }, bottomLeft: {
        MyBottomLeftView()
        }, bottomRight: {
        MyBottomRightView()
        }) {
        MyHandle()
}

Examples

Copy and Paste this I have added Named pictures for how the views should look, Im using dark mode so light mode colors may look different.

HPart VPart GridPart NestGrids Mixed
HPart VPart GridPart Nested Grid Mixed
import SwiftUI
import PartitionKit



struct ContentView: View {
    var vExample: some View {
        VPart(top: {
            RoundedRectangle(cornerRadius: 25).foregroundColor(.purple)
        }) {
            Circle().foregroundColor(.yellow)
        }
    }
    
    var hExample: some View {
        HPart(left: {
            RoundedRectangle(cornerRadius: 10).foregroundColor(.blue)
        }) {
            Circle().foregroundColor(.orange)
        }
    }
    
    var nestedExample: some View {
        VPart(top: {
            hExample
        }) {
            vExample
        }
    }
    
    var gridExample: some View {
        GridPart(topLeft: {
            RoundedRectangle(cornerRadius: 25).foregroundColor(.purple)
        }, topRight: {
            Circle().foregroundColor(.yellow)
        }, bottomLeft: {
            Circle().foregroundColor(.green)
        }) {
            RoundedRectangle(cornerRadius: 25).foregroundColor(.blue)
        }
    }
    
    var nestedGridsExample: some View {
        GridPart(topLeft: {
            gridExample
        }, topRight: {
            gridExample
        }, bottomLeft: {
            gridExample
        }) {
            gridExample
        }
    }
    
    var body: some View {
        nestedExample
        
    }
}


struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Todo

  • Add in constraints so that partitions will not cause negative frame values that invert the views when the handle is dragged beyond the frame of the container
  • Add more customizability to initial layouts
  • Add a List Style grid collection layout that can be initiated with a list of Identifiable data elements.
  • General cleanup, some stuff was not meant to be left in, i will find it at some point.
Comments
  • Feature Request: Expose it as a swift package

    Feature Request: Expose it as a swift package

    With the advent of Swift Package Manager (SPM) included in XCode 11, it would be amazing to have this code as a package/framework to easily include it in your project.

    Description on how to set it up is available here

    opened by rodrigoelp 3
  • License?

    License?

    Please think of adding a license so that this can be used by others.

    Quoting opensource.org:

    Can I call my program "Open Source" even if I don't use an approved license? Please don't do that. If you call it "Open Source" without using an approved license, you will confuse people. This is not merely a theoretical concern — we have seen this confusion happen in the past, and it's part of the reason we have a formal license approval process. See also our page on license proliferation for why this is a problem.

    opened by kaishin 2
  • Define a version on this package to properly use as Swift Package

    Define a version on this package to properly use as Swift Package

    I'm having problems using your package as version range in Xcode, checking the repo I'm observing that you don't have define any tag on the repo, and XCode use this as version identifier.

    I'm asking you to define a version number (0.0.0) to mark the initial release (for development) and permit us to use it in Xcode as Version Range. Thanks

    opened by rafaga 1
  • Could not find the Package kieranb662/Interact

    Could not find the Package kieranb662/Interact

    Hey,

    I love your all packages. Too much to learn from your code.

    I was in need to implement something like your package Interact. When I came to this source kieranb662/Interact, I was not able to find it. Can you update me on this please!

    opened by iasad 0
  • Fix position of other lines and collision avoidance

    Fix position of other lines and collision avoidance

    ( I found this library while researching this: https://stackoverflow.com/questions/67403140/drag-separators-in-swiftui )

    Is there a way to keep the other lines from moving, so that only the line being moved with handle (or the two lines being moved with crosshair) moves?

    Also, is there a way to stop handle lines overlapping other areas, so each section has a minimum size (10 pixels square, for example)? So that the Console doesn't spit out this: PartitionKitExample[34446:1101291] [SwiftUI] Invalid frame dimension (negative or non-finite).

    opened by cannyboy 0
  • undocumented bahavior of layers in partitions

    undocumented bahavior of layers in partitions

    Hey there,

    I am playing with the DragGesture in VPart and encountered in undefined behavior of partition layers. For example, when I drag a rectangle from the top partition to the bottom one using offset, it appears beneath the bottom's partition rectangle. I am looking for the way to implement the opposite behavior but as of now I cannot understand what influences it.

    here's the example VPart: @GestureState var isLongPressed = false @State private var offset: CGSize = .zero var body: some View {

      VPart(top: {
           HStack {
    
                Rectangle()
                .fill(Color.green)
                .cornerRadius(10)
                .frame(minWidth: 20, maxWidth: 200, minHeight: 20, maxHeight: 200)
                .offset(offset)
                .gesture(DragGesture()
                .onChanged { self.offset = $0.translation }
                .onEnded { _ in self.offset = .zero }
                )`
            }
            }, bottom: {
            Rectangle()
                .fill(Color.red)
                .cornerRadius(10)
                .frame(minWidth: 20, maxWidth: 200, minHeight: 20, maxHeight: 200)
            })
    }
    
    opened by shengchalover 0
Releases(1.0.2)
Owner
Kieran Brown
Proficient in physics, chemistry, biology, partial differential equations, and Swift.
Kieran Brown
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

Kacper Rączy 365 Dec 29, 2022
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

Daniel Klöck 19 Dec 28, 2022
Creating a simple selectable tag view in SwiftUI is quite a challenge. here is a simple & elegant example of it.

SwiftUI TagView Creating a simple selectable tag view in SwiftUI is quite a challenge. here is a simple & elegant example of it. Usage: Just copy the

Ahmadreza 16 Dec 28, 2022
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

Putra Z. 43 Feb 4, 2022
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

Seed 867 Dec 27, 2022
Placeholder views based on content, loading, error or empty states

StatefulViewController A protocol to enable UIViewControllers or UIViews to present placeholder views based on content, loading, error or empty states

Alexander Schuch 2.1k Dec 8, 2022
AGCircularPicker is helpful component for creating a controller aimed to manage any calculated parameter

We are pleased to offer you our new free lightweight plugin named AGCircularPicker. AGCircularPicker is helpful for creating a controller aimed to man

Agilie Team 617 Dec 19, 2022
Material, a UI/UX framework for creating beautiful iOS applications

Material Welcome to Material, a UI/UX framework for creating beautiful applications. Material's animation system has been completely reworked to take

Cosmicmind 12k Jan 2, 2023
Creating a blurred window background in Mac Catalyst

TransparentChrome In response to a developer question, I looked for the easiest way to provide a translucent full-window chrome with a blurred backgro

Steven Troughton-Smith 37 Dec 2, 2022
DesafioMobile2You - This project consists of creating a replica of a TodoMovies screen

DesafioMobile2You Swift IOS Este projeto consiste na criação da réplica de uma t

Leonardo P M 0 Feb 3, 2022
A paging scroll view for SwiftUI, using internal SwiftUI components

PagingView A paging scroll view for SwiftUI, using internal SwiftUI components. This is basically the same as TabView in the paging mode with the inde

Eric Lewis 18 Dec 25, 2022
SwiftUI-Margin adds a margin() viewModifier to a SwiftUI view.

SwiftUI-Margin adds a margin() viewModifier to a SwiftUI view. You will be able to layout the margins in a CSS/Flutter-like.

Masaaki Kakimoto(柿本匡章) 2 Jul 14, 2022
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.

BadgeHub A way to quickly add a notification badge icon to any view. Demo/Example For demo: $ pod try BadgeHub To run the example project, clone the r

Jogendra 772 Dec 28, 2022
Confetti View lets you create a magnificent confetti view in your app

ConfettiView Confetti View lets you create a magnificent confetti view in your app. This was inspired by House Party app's login screen. Written in Sw

Or Ron 234 Nov 22, 2022
A library, which adds the ability to hide navigation bar when view controller is pushed via hidesNavigationBarWhenPushed flag

HidesNavigationBarWhenPushed A library, which adds the ability to hide navigation bar when view controller is pushed via hidesNavigationBarWhenPushed

Danil Gontovnik 55 Oct 19, 2022
Advanced List View for SwiftUI with pagination & different states

AdvancedList This package provides a wrapper view around the SwiftUI List view which adds pagination (through my ListPagination package) and an empty,

Chris 246 Jan 3, 2023
📖 A lightweight, paging view solution for SwiftUI

Getting Started | Customization | Installation Getting Started Basic usage Using Pages is as easy as: import Pages struct WelcomeView: View { @S

Nacho Navarro 411 Dec 29, 2022
🚀 Elegant Pager View fully written in pure SwiftUI.

PagerTabStripView Made with ❤️ by Xmartlabs team. XLPagerTabStrip for SwiftUI! Introduction PagerTabStripView is the first pager view built in pure Sw

xmartlabs 482 Jan 9, 2023