Skip to content

Commit

Permalink
Update to version 1.0.1
Browse files Browse the repository at this point in the history
added fallback version for iOS < 15 (also useable on iOS15+
  • Loading branch information
mbender74 committed Oct 11, 2021
1 parent c58d3b6 commit 155385f
Show file tree
Hide file tree
Showing 25 changed files with 2,060 additions and 259 deletions.
73 changes: 54 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@

## Methods

### `createBottomSheet({properties}) `
### MODULE -> `createBottomSheet({properties}) `
returns the **bottomSheetObject**

## bottomSheetObject Methods
### `show({animated:bool}) `
### `hide({animated:bool}) `
manually hide the controller, per exaple if to did any action in the content view
### `selectedDetentIdentifier` return STRING - selectedDetentIdentifier (medium,large or none)
### `selectedDetentIdentifier`
return STRING - selectedDetentIdentifier (medium,large or none)
### `changeCurrentDetent(STRING)`
change the selectedDetentIdentifier animated ('large' or 'medium') **on 'nonSystemSheet:true' only**


## Events

Expand All @@ -21,33 +28,52 @@ manually hide the controller, per exaple if to did any action in the content vie

## Properties

### `detents:{large:bool,medium:bool}`
#### The object of heights where a sheet can rest.
### `detents:{large:bool,medium:bool,small:bool}`
The object of heights where a sheet can rest.
*if not set, default to 'medium' only*

### `preferredCornerRadius:integer`
#### The corner radius that the sheet attempts to present with.
The corner radius that the sheet attempts to present with.
*if not set default to iOS default radius*

### `prefersEdgeAttachedInCompactHeight:bool`
#### A Boolean value that determines whether the sheet attaches to the bottom edge of the screen in a compact-height size class.
A Boolean value that determines whether the sheet attaches to the bottom edge of the screen in a compact-height size class.

### `prefersScrollingExpandsWhenScrolledToEdge:bool`
#### A Boolean value that determines whether scrolling expands the sheet to a larger detent.
A Boolean value that determines whether scrolling expands the sheet to a larger detent.

### `widthFollowsPreferredContentSizeWhenEdgeAttached:bool`
#### A Boolean value that determines whether the sheet's width matches its view controller's preferred content size.
A Boolean value that determines whether the sheet's width matches its view controller's preferred content size.

### `prefersGrabberVisible:bool`
#### A Boolean value that determines whether the sheet shows a grabber at the top.
A Boolean value that determines whether the sheet shows a grabber at the top.

### `nonModal:bool`
has effect ONLY when "nonSystemSheet:false" on iOS >= 15


### `largestUndimmedDetentIdentifier:string`
#### medium or large - if not set, it is full dimmed depending on activated detents - The largest detent that doesn’t dim the view underneath the sheet.
medium or large - if not set, it is full dimmed depending on activated detents - The largest detent that doesn’t dim the view underneath the sheet.
***If not set, defaults to full dimmed***

### `contentView:TiUIView,TiUIWindow or TiUINavigationWindow`
#### View (any kind), Window or NavigationWindow
View (any kind), Window or NavigationWindow

### `closeButton:TiUIView`
View or Button

### `backgroundColor:Hex or String`

### `nonSystemSheet:bool`
A Boolean value that determines whether the sheet is iOS15 or fallback version - if "false" and device is non iOS15 it also fallbacks - **if NOT SET -> defaults to "true"**

### `nonSystemSheetTopShadow:bool`
topShadow visible or not visible

### `nonSystemSheetShouldScroll:bool`
when your contentView is not a scrollable view, then this activates scrolling if the contentView is larger then the bottomSheet

**ATTENTION**: when you put a tableView, scrollView or listView inside your contentView this property disables scrolling in the contentView in favour of the bottomSheetScrollView


## Example
Expand Down Expand Up @@ -113,14 +139,23 @@ bottomView.setData(tableRows,{animated:false});


var bottomSheetController = TiBottomSheetControllerModule.createBottomSheet({
detents:{large:true,medium:true}, // The object of heights where a sheet can rest.
preferredCornerRadius:20, // The corner radius that the sheet attempts to present with.
prefersEdgeAttachedInCompactHeight:false, // A Boolean value that determines whether the sheet attaches to the bottom edge of the screen in a compact-height size class.
prefersScrollingExpandsWhenScrolledToEdge:false, // A Boolean value that determines whether scrolling expands the sheet to a larger detent.
widthFollowsPreferredContentSizeWhenEdgeAttached:false, // A Boolean value that determines whether the sheet's width matches its view controller's preferred content size.
prefersGrabberVisible:true, // A Boolean value that determines whether the sheet shows a grabber at the top.
largestUndimmedDetentIdentifier:'medium', // medium or large - if not set, it is full dimmed depending on activated detents - The largest detent that doesn’t dim the view underneath the sheet.
contentView: bottomView. // View (any kind), Window or NavigationWindow
detents:{large:true,medium:true,small:false}, // "small" has effect only when "nonSystemSheet:true"
startDetent:'medium', // medium or large - when "nonSystemSheet:true" also "small" is possible -- when startDetent is "small" and detents:{small:false} is defaults to "medium" and so on...
preferredCornerRadius:20,
prefersEdgeAttachedInCompactHeight:false, // has effect only when "nonSystemSheet:false"
prefersScrollingExpandsWhenScrolledToEdge:false, // has effect only when "nonSystemSheet:false"
widthFollowsPreferredContentSizeWhenEdgeAttached:true, // has effect only when "nonSystemSheet:false"
prefersGrabberVisible:true, // bottomSheet grabberHandle visible true / false
nonModal:false, // has effect ONLY when "nonSystemSheet:false" on iOS >= 15
largestUndimmedDetentIdentifier:'small', // medium or large (also "small" available when "nonSystemSheet:true") - if not set, it is full dimmed depending on activated detents when "nonSystemSheet:true" the property also allow to interact with the view in the background of the bottomSheet - when not dimmed, when dimmed interaction is not possible with the view in the background
contentView: bottomView,
closeButton:YOUR_CLOSEBUTTON_VIEW_FOR_THE_SHEET, // add a closeButtonView to the bottomSheet
backgroundColor:'#eeeeee',

nonSystemSheet:false, // defaults to "true" if not set - non iOS 15 SheetController (backwards compatible to non iOS15) when "true" - iOS15+ SheetController when "false" - if non iOS15 and set to "false" it also defaults to "true"
nonSystemSheetTopShadow:true, // has effect only on "nonSystemSheet:true"
nonSystemSheetShouldScroll:true, // when your contentView is not a scrollable view, then this activates scrolling if the contentView is larger then the bottomSheet
// ATTENTION: when you put a tableView, scrollView or listView inside your contentView this property disables scrolling in the contentView in favour of the bottomSheetScrollView
});

bottomSheetController.addEventListener('dismissing', function() {
Expand Down
Empty file modified demo.gif
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions ios/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
21 changes: 21 additions & 0 deletions ios/Assets.xcassets/cancel.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "cancel.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file added ios/Assets.xcassets/cancel.imageset/cancel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 0 additions & 17 deletions ios/Classes/BottomSheetVC.h

This file was deleted.

63 changes: 0 additions & 63 deletions ios/Classes/BottomSheetVC.m

This file was deleted.

72 changes: 72 additions & 0 deletions ios/Classes/BottomSheetViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//
// BottomSheetViewController.h
// navi-lite
//
// Created by Phineas.Huang on 2020/5/29.
// Copyright © 2020 Garmin. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

typedef enum Director {
up,
down,
}Director;

typedef enum State {
partial,
expanded,
full,
dismiss
}State;
static State maxState = full;
static CGFloat maxPosition = 0;
static State minState = partial;
static CGFloat minPosition = 0;
static UIEdgeInsets insets;
static bool panEnabled = YES;
static bool panInit = NO;
static bool panFromScrollView = NO;

static bool fullPositon = YES;
static bool mediumPosition = YES;
static bool smallPosition = YES;
static CGFloat lastScrollViewOffsetY = 0;
static CGFloat newSrollViewOffsetY = 0;
static CGFloat lastTranslation = 0;


static NSDictionary *userDetents;
static CGFloat fullViewYPosition = 0;
static CGFloat partialViewYPosition = 0;
static CGFloat expandedViewYPosition = 0;
static bool dismissModeOfSheet = NO;
static bool backgroundViewHidden = NO;
static UIColor *viewBackgroundColor = nil;
static UIColor *dimmedViewBackgroundColor = nil;
static NSString *largestUndimmedDetent = nil;
static NSString *startDetent = nil;
static NSString *detentString = nil;
@interface BottomSheetViewController : UIViewController
@property (assign, nonatomic) State lastStatus;
@property (assign, nonatomic) NSString *selectedDetentIdentifier;

- (id)proxyOfBottomSheetController;
- (void)setProxyOfBottomSheetController:(id)args;
- (void)moveViewWithGesture:(UIPanGestureRecognizer *)recognizer;
- (void)panGesture:(UIPanGestureRecognizer *)recognizer;
- (void)moveView:(State)state;
- (State)state;
- (void)panRecognizerEnabled:(bool)enabled;
- (bool)panRecognizerState;
- (UIPanGestureRecognizer *)panRecognizer;
- (void)panRecognizerInit:(bool)enabled;
- (void)panFromScrollView:(bool)enabled;

- (void)scrollView:(UIScrollView*)scrollview;
- (void)lastContentOffsetY:(CGFloat)contentOffsetY;
@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit 155385f

Please sign in to comment.