Skip to content

Commit

Permalink
update to version 1.0.6
Browse files Browse the repository at this point in the history
fixed a bug with windows as contentView (tanks to Jason Miller David - https://github.com/designbymind)
  • Loading branch information
mbender74 committed Jan 16, 2022
1 parent 295ac66 commit 4f80b09
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 48 deletions.
24 changes: 0 additions & 24 deletions ios/Classes/TiPopoverModuleAssets.m

This file was deleted.

2 changes: 1 addition & 1 deletion ios/Classes/TiPopoverProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//The iPadPopoverProxy should be seen more as like a window or such, because
//The popover controller will contain the viewController, which has the view.
//If the view had the logic, you get some nasty dependency loops.
@interface TiPopoverProxy : TiViewProxy <UIPopoverControllerDelegate, UIPopoverPresentationControllerDelegate, TiProxyObserver> {
@interface TiPopoverProxy : TiProxy <UIPopoverControllerDelegate, UIPopoverPresentationControllerDelegate, TiProxyObserver> {
@private
UIViewController *viewController;
TiViewProxy *contentViewProxy;
Expand Down
70 changes: 51 additions & 19 deletions ios/Classes/TiPopoverProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,11 @@ - (void)show:(id)args
[tiPopOverCondition unlock];
popoverInitialized = YES;

//TiThreadPerformOnMainThread(
// ^{
TiThreadPerformOnMainThread(
^{
[self initAndShowPopOver];
// },
// NO);
},
YES);
}

- (void)hide:(id)args
Expand Down Expand Up @@ -353,14 +353,32 @@ - (void)initAndShowPopOver
[(TiWindowProxy *)contentViewProxy setIsManaged:YES];
[(TiWindowProxy *)contentViewProxy open:nil];
[(TiWindowProxy *)contentViewProxy gainFocus];
[self updatePopoverNow];
[contentViewProxy windowDidOpen];

TiThreadPerformOnMainThread(
^{
[self updateContentSize];
},
NO);

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self updatePopoverNow];
[contentViewProxy windowDidOpen];
});

} else {
[contentViewProxy windowWillOpen];
[contentViewProxy reposition];
[self updatePopoverNow];
[contentViewProxy windowDidOpen];

TiThreadPerformOnMainThread(
^{
[self updateContentSize];
},
NO);

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self updatePopoverNow];
[contentViewProxy windowDidOpen];
});
}
}

Expand Down Expand Up @@ -431,16 +449,15 @@ - (void)updatePopoverNow
return;
}
[closingCondition unlock];
[self updateContentSize];


[contentViewProxy view].alpha = 0.0;


UIViewController *theController = [self viewController];
[theController setModalPresentationStyle:UIModalPresentationPopover];
theController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[theController setPreferredContentSize:[contentViewProxy view].frame.size];
theController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
// [theController setPreferredContentSize:[contentViewProxy view].frame.size];
//
[theController popoverPresentationController].permittedArrowDirections = [self arrowDirection];
[theController popoverPresentationController].delegate = self;

Expand All @@ -453,15 +470,15 @@ - (void)updatePopoverNow

if (animated){
if (popoverBlurEffectView != nil){
[UIView animateWithDuration:0.2 delay: 0.0 options: UIViewAnimationOptionCurveEaseInOut
[UIView animateWithDuration:0.2 delay: 0.0 options: UIViewAnimationOptionCurveEaseIn
animations:^{
popoverBlurEffectView.alpha = 1.0;
}
completion:nil];
}
if (popoverDarkenBackgroundView != nil){

[UIView animateWithDuration:0.2 delay: 0.0 options: UIViewAnimationOptionCurveEaseInOut
[UIView animateWithDuration:0.2 delay: 0.0 options: UIViewAnimationOptionCurveEaseIn
animations:^{
popoverDarkenBackgroundView.alpha = 1.0;
}
Expand All @@ -478,13 +495,14 @@ - (void)updatePopoverNow
}


[[TiApp app] showModalController:theController animated:animated];

// [[TiApp app] showModalController:theController animated:animated];
[[[TiApp app] controller] presentViewController:theController animated:animated completion:^{
}];

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

if (animated){
[UIView animateWithDuration:0.01 delay: 0.0 options: UIViewAnimationOptionCurveEaseInOut
[UIView animateWithDuration:0.001 delay: 0.0 options: UIViewAnimationOptionCurveEaseIn
animations:^{
[contentViewProxy view].alpha = 1.0;
}
Expand Down Expand Up @@ -536,19 +554,33 @@ - (void)updateContentViewWithSafeAreaInsets:(NSValue *)insetsValue

#pragma mark Delegate methods


- (void)proxyDidRelayout:(id)sender
{
if (sender == contentViewProxy) {
if (viewController != nil) {
CGSize newSize = [self contentSize];
if (!CGSizeEqualToSize([viewController preferredContentSize], newSize)) {
[self updateContentSize];

// NSLog(@"proxyDidRelayout %f %f ",newSize.width,newSize.height);

if (!CGSizeEqualToSize([viewController preferredContentSize], newSize)) {
[self updateContentSize];
}

if (TiPopoverContentSize.width != newSize.width || TiPopoverContentSize.height != newSize.height){
if (!CGSizeEqualToSize([viewController preferredContentSize], newSize)) {


[self updateContentSize];
}
}
}
}
}




- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController: (UIPresentationController *)controller
{
return UIModalPresentationNone;
Expand Down
2 changes: 1 addition & 1 deletion ios/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 1.0.5
version: 1.0.6
apiversion: 2
architectures: arm64 x86_64
mac: true
Expand Down
1 change: 0 additions & 1 deletion ios/metadata.json

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<key>Build &amp; Test.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
<key>ti.popover.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
Expand Down

0 comments on commit 4f80b09

Please sign in to comment.