BottomSheetView 1.0.2

dotnet add package BottomSheetView --version 1.0.2
                    
NuGet\Install-Package BottomSheetView -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BottomSheetView" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BottomSheetView" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="BottomSheetView" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BottomSheetView --version 1.0.2
                    
#r "nuget: BottomSheetView, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=BottomSheetView&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=BottomSheetView&version=1.0.2
                    
Install as a Cake Tool

BottomSheetView

Bottom sheets for iOS

Minimum requirement:

iOSVersion

About

This project is to enable easily presenting view controllers in a bottom sheet that supports scrollviews and multiple sizes. Contributions and feedback are very welcome.

The bottom sheet tries to be smart about the height it takes. If the view controller is smaller than the sizes specified, it will only grow as large as the intrensic height of the presented view controller. If it is larger, it will stop at each height specified in the initializer or SetSizes function.

Fixed Height Dynamic Height
Fixed Height Dynamic Height

Usage

Using a BottomSheetView is simple.

The constructor is new BottomSheetViewController(controller, sizes). Sizes is optional, but if specified, the first size in the array will determine the initial size of the sheet, and the others sizes will be all the sizes that the component can take.

Using default settings with fixed height

var controller = UIStoryboard.FromName("Main", null).InstantiateViewController("ChildViewController");

var bottomSheetController = new BottomSheetViewController(controller)

this.PresentModalViewController(bottomSheetController, false);
//It is important to set animated to false or it behaves weird currently

Customizing settings

var controller = UIStoryboard.FromName("Main", null).InstantiateViewController("ChildViewController");

SheetSize[] sheetSizes = { SheetSize.Fixed(300f), SheetSize.FullScreen };

var bottomSheetController = new BottomSheetViewController(controller)
bottomSheetController.DismissOnBackgroundTap = false;
bottomSheetController.RoundTopCorner = false;

this.PresentModalViewController(bottomSheetController, false);

Settings

// The color of the overlay above the sheet.
public UIColor OverlayColor => UIColor.FromRGBA(0, 0, 0, (int)70  *  255);
// Sets the heights, the sheets will try to stick to. It will not resize the current size, but will affect all future resizing of the sheet.
public void SetSizes(SheetSize[]  sizes, bool animated = true)
/// This should be called by any child view controller that expects the sheet to use be able to expand/collapse when the scroll view is at the top.
public void HandleScrollView(UIScrollView scrollView)

There is an extension on UIViewController that gives you a BottomSheetViewController that attempts to find the current SheetViewController so you can attach like this:

public override void ViewDidLoad() {

base.ViewDidLoad()
this.bottomSheetViewController?.HandleScrollView(this.scrollView) // or tableView/collectionView/etc

}

Nuget

NuGet

PM> Install-Package BottomSheetView -Version 1.0.1
Product Compatible and additional computed target framework versions.
Xamarin.iOS xamarinios10 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • Xamarin.iOS 1.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 882 3/12/2019
1.0.1 686 3/5/2019