This repository has been archived by the owner on Jun 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tweak] ditch the on-banner controls, use an embedded widget!
- Loading branch information
Showing
6 changed files
with
148 additions
and
60 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
@import NotificationCenter; | ||
|
||
@class WGWidgetHostingViewController; | ||
|
||
@protocol WGWidgetHostingViewControllerDelegate <NSObject> | ||
|
||
@required | ||
|
||
- (CGSize)maxSizeForWidget:(WGWidgetHostingViewController *)widgetViewController forDisplayMode:(NCWidgetDisplayMode)displayMode; | ||
|
||
@optional | ||
|
||
- (void)remoteViewControllerDidConnectForWidget:(WGWidgetHostingViewController *)widgetViewController; | ||
- (void)remoteViewControllerDidDisconnectForWidget:(WGWidgetHostingViewController *)widgetViewController; | ||
- (void)remoteViewControllerViewDidAppearForWidget:(WGWidgetHostingViewController *)widgetViewController; | ||
- (void)remoteViewControllerViewDidHideForWidget:(WGWidgetHostingViewController *)widgetViewController; | ||
- (void)brokenViewDidAppearForWidget:(WGWidgetHostingViewController *)widgetViewController; | ||
- (void)contentAvailabilityDidChangeForWidget:(WGWidgetHostingViewController *)widgetViewController; | ||
|
||
- (NCWidgetDisplayMode)activeLayoutModeForWidget:(WGWidgetHostingViewController *)widgetViewController; | ||
- (UIEdgeInsets)marginInsetsForWidget:(WGWidgetHostingViewController *)widgetViewController; | ||
|
||
- (void)widget:(WGWidgetHostingViewController *)widgetViewController didChangeLargestSupportedDisplayMode:(NCWidgetDisplayMode)largestDisplayMode; | ||
- (id)widget:(WGWidgetHostingViewController *)widgetViewController didUpdatePreferredHeight:(CGFloat)preferredHeight completion:(id)completion; | ||
|
||
- (BOOL)shouldRequestWidgetRemoteViewControllers; | ||
|
||
@end | ||
|
||
@interface WGWidgetHostingViewController : UIViewController | ||
|
||
@end | ||
|
||
@class WGWidgetDiscoveryController; | ||
|
||
@protocol WGWidgetDiscoveryControllerDelegate <NSObject> | ||
|
||
@optional | ||
|
||
- (BOOL)widgetDiscoveryControllerShouldIncludeInternalWidgets:(WGWidgetDiscoveryController *)discoveryController; | ||
|
||
- (BOOL)widgetDiscoveryController:(WGWidgetDiscoveryController *)discoveryController shouldPurgeArchivedSnapshotsForWidgetWithBundleIdentifier:(NSString *)bundleIdentifier; | ||
- (void)widgetDiscoveryController:(WGWidgetDiscoveryController *)discoveryController widgetWithBundleIdentifier:(NSString *)bundleIdentifier didEncounterProblematicSnapshotAtURL:(NSURL *)snapshotURL; | ||
|
||
- (UIViewController *)widgetDiscoveryController:(WGWidgetDiscoveryController *)discoveryController preferredViewControllerForPresentingFromViewController:(UIViewController *)viewController; | ||
- (void)widgetDiscoveryController:(WGWidgetDiscoveryController *)discoveryController requestUnlockWithCompletion:(id)completion; | ||
|
||
- (id)whiteStatusBarAssertionForWidgetDiscoveryController:(WGWidgetDiscoveryController *)discoveryController; | ||
- (void)widgetDiscoveryController:(WGWidgetDiscoveryController *)discoveryController didEndUsingStatusBarAssertion:(id)statusBarAssertion; | ||
|
||
@end | ||
|
||
@interface WGWidgetDiscoveryController : NSObject | ||
|
||
- (instancetype)initWithColumnModes:(NSUInteger)columnModes; | ||
|
||
@property (nonatomic, weak) id <WGWidgetDiscoveryControllerDelegate> delegate; | ||
|
||
- (void)beginDiscovery; | ||
|
||
- (WGWidgetHostingViewController *)widgetWithIdentifier:(NSString *)identifier delegate:(id<WGWidgetHostingViewControllerDelegate>)delegate forRequesterWithIdentifier:(NSString *)requesterIdentifier; | ||
|
||
@end | ||
|
||
//////// | ||
|
||
@interface HBCZNotificationWidgetViewController : UIViewController <WGWidgetDiscoveryControllerDelegate, WGWidgetHostingViewControllerDelegate> | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#import "HBCZNotificationWidgetViewController.h" | ||
#import <version.h> | ||
|
||
%subclass HBCZNotificationWidgetViewController : UIViewController | ||
|
||
- (void)loadView { | ||
%orig; | ||
|
||
WGWidgetDiscoveryController *discoverer = [[%c(WGWidgetDiscoveryController) alloc] initWithColumnModes:0]; | ||
[discoverer beginDiscovery]; | ||
|
||
WGWidgetHostingViewController *viewController = [discoverer widgetWithIdentifier:@"ws.hbang.canzone.app.nowplayingwidget" delegate:self forRequesterWithIdentifier:@"ws.hbang.canzone.app"]; | ||
|
||
[viewController willMoveToParentViewController:self]; | ||
viewController.view.frame = self.view.bounds; | ||
viewController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | ||
[self.view addSubview:viewController.view]; | ||
} | ||
|
||
#pragma mark - Widget hosting | ||
|
||
%new - (CGSize)maxSizeForWidget:(WGWidgetHostingViewController *)widgetViewController forDisplayMode:(NCWidgetDisplayMode)displayMode { | ||
return CGSizeMake(self.view.frame.size.width, 65); | ||
} | ||
|
||
%new - (NCWidgetDisplayMode)activeLayoutModeForWidget:(WGWidgetHostingViewController *)widgetViewController { | ||
return NCWidgetDisplayModeCompact; | ||
} | ||
|
||
%new - (UIEdgeInsets)marginInsetsForWidget:(WGWidgetHostingViewController *)widgetViewController { | ||
return UIEdgeInsetsZero; | ||
} | ||
|
||
%end | ||
|
||
%ctor { | ||
if (IS_IOS_OR_NEWER(iOS_10_0)) { | ||
%init; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters