Browse Source

version bump and added some more code commentary on how search is working on tvOS

Kevin Bradley 3 years ago
parent
commit
aacc02fc08

+ 9 - 5
Classes/Core/Controllers/FLEXTableViewController.m

@@ -95,6 +95,15 @@ CGFloat const kFLEXDebounceForExpensiveIO = 0.5;
     return (id)self.view.window;
 }
 
+/**
+ 
+ search is handled a bit differently on tvOS and i couldnt get its pardigm to cooperate, thankfully the UISearchController never needs to be visible to actually work its magic.
+ since 3D snapshot viewing doesn't exist on tvOS the leftBarButtonItem is the perfect spot to add a 'search' button. this search button will present a new text entry controller
+ the alpha on this viewController is decreased to 0.6 to make it possible to view the filtering changes underneath in realtime. The zero rect textfield associated with
+ the search button acts as a proxy to transfer the text to our search bar as necessary
+ 
+ */
+
 - (void)setShowsSearchBar:(BOOL)showsSearchBar {
     if (_showsSearchBar == showsSearchBar) return;
     _showsSearchBar = showsSearchBar;
@@ -509,11 +518,6 @@ CGFloat const kFLEXDebounceForExpensiveIO = 0.5;
 
 - (void)removeSearchController:(UISearchController *)controller {
     #if TARGET_OS_TV
-    /*
-    [self.searchContainer willMoveToParentViewController:nil];
-    [self.searchContainer.view removeFromSuperview];
-    [self.searchContainer removeFromParentViewController];
-     */
     self.navigationItem.leftBarButtonItem = nil;
     #else
     if (@available(iOS 11.0, *)) {

+ 34 - 1
Classes/tvOS/fakes.h

@@ -6,16 +6,47 @@
 //  Copyright © 2020 Flipboard. All rights reserved.
 //
 
+/*
+ 
+ Feel like this class requires some documentation / commentary.
+ 
+ there are a variaty of classes that are either forbidden or non-existant on tvOS. Initially to get things building
+ to find out what i needed to fix outside of missing classes i figured i'd be easiet to stub out "fake' versions
+ of the classes that responded to the bare minimum for API complaince to have them appear as empty elements
+ rather than preventing building or creating crashes.
+ 
+ */
+
 #import <UIKit/UIKit.h>
 #import "FLEXMacros.h"
 #import "KBSlider.h"
 #import "KBDatePickerView.h"
 
+/**
+ 
+ PREFACE:
+ 
+ Doing UISearchController integration on tvOS is a nightmare. as is ANY integration with the keyboard or having it presented to the end user.
+ I made an attempt to get a more native UI/UX to tvOS for this part but couldn't wrap my head around a way to get it to work in a reasonable amount of time
+ so i came up with this kludge to get search working in a reasonable sense as quickly as possible for tvOS.
+
+ IMPLEMENTATION:
+ 
+ This UIButton is added as the view of a UITabBarButtonItem as the left bar button item & there is a zero rect text field embedded in this button,
+ this is the chicnary necessary to get a keyboard to appear reliably when the text field becomes the first responder.
+ the drawback to this approach is the view appears in a mostly opaque and newly minted UISystemInputViewController with a UIKeyboard on it.
+ to make this approach workable I wait for 0.1 seconds and then decrease the alpha value of the 'topViewController' which happens to be
+ our UISystemInputViewController. this allows the user to see the changes update underneath the view while the search is executed!
+ 
+ */
+
 @interface KBSearchButton: UIButton <UITextFieldDelegate>
+@property UISearchBar * _Nullable searchBar; //keep a reference to the search bar to add our text value to the search bar field immediately.
 - (void)triggerSearchField;
-@property UISearchBar *searchBar;
 @end
 
+//UIFakeSwitch is actually just a UIButton that says TRUE/FALSE and responds to UISwitch API calls.
+
 @interface UIFakeSwitch : UIButton <NSCoding>
 @property(nullable, nonatomic, strong) UIColor *onTintColor;
 @property(nullable, nonatomic, strong) UIColor *thumbTintColor;
@@ -28,6 +59,8 @@
 + (id _Nonnull )newSwitch;
 @end
 
+//Stub slider, any instances that still use this are only in the snapshot baesd views which dont work yet, this will be pruned once that update is made.
+
 @interface UIFakeSlider: UIControl <NSCoding>
 @property(nonatomic) float value;
 @property(nonatomic) float minimumValue;

+ 2 - 3
Classes/tvOS/fakes.m

@@ -12,12 +12,11 @@
 +(UIImage *)symbolImageNamed:(NSString *)symbolName;
 @end
 @interface KBSearchButton()
-@property UITextField *searchField;
+@property UITextField *searchField; //helps us get a keyboard onscreen and acts as a proxy to move text to our UISearchBar
 @end
 
 @implementation KBSearchButton
 
-
 + (instancetype)buttonWithType:(UIButtonType)buttonType {
     KBSearchButton *button = [super buttonWithType:buttonType];
     [button setImage:[UIImage symbolImageNamed:@"magnifyingglass"] forState:UIControlStateNormal];
@@ -48,6 +47,7 @@
     self.searchField.text = self.searchBar.text;
     //[self.searchBar becomeFirstResponder];
     [self.searchField becomeFirstResponder];
+    //wait for 0.1 seconds and then decrease the opacity of UISystemInputViewController presenting our UIKeyboard
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
         UIViewController *vc = [self topViewController];
         vc.view.alpha = 0.6;
@@ -98,7 +98,6 @@
 }
 
 - (instancetype)initWithCoder:(id)coder {
-    LOG_SELF;
     return [super initWithCoder:coder];
 }
 

+ 1 - 1
layout/DEBIAN/control

@@ -2,7 +2,7 @@ Package: libflex
 Section: Development
 Maintainer: Kevin Bradley
 Architecture: appletvos-arm64
-Version: 4.3.0-1
+Version: 4.3.0-2
 Depends: firmware (>= 9.0), mobilesubstrate
 Description: A library for Flipboard Explorer on tvOS
 Name: libFLEX