Files
PojavLauncher_iOS/Natives/LauncherViewController.m
64f7e82c1e Merge main into backend-virgl (#316)
* Fix Duy's deploy and install stuffs

* Fix Makefile error and move external_include to external/zink

* Bug fix: version ordering when types are disabled

This commit fixes #293

* Update README.md

* Add option to disable symlink to /var/mobile/Documents/.pojavlauncher (off by default)

* Reset preferences option, switch to POJAV_HOME

* Update bug_report.yml

Update pojavlauncher directory location

* Mitigation for the Apache Log4j RCE in 1.8.x-1.18

* Experimental things

* Multitouch handling, allows one of these actions below to work with
moving camera at the same time.
- Switching hotbar slot; might not work properly
- Destroying block (left mouse button) with another finger
long-pressed (without pressing the PRI button)
- Right mouse trigger with another finger tapped onto the screen
(without pressing the SEC button); not working properly yet
* Sub-pixel cursor support; not yet checked

* Completely fix Log4J RCE (1.7-1.16.5) (not yet tested)

TODO: checker with SHA1

* Log4J RCE patch config: disable XML format output

This applies for Minecraft 1.12+
Disable XML formatting for now until we have a log viewer.

* Create newsfeed.html

* Update newsfeed.html

* Delete newsfeed.html

* WIP Demo mode stuff

Sign in with a Microsoft account that doesn't own the game, demo_user will be made. This is very much WIP as my iPhone 7 doesn't feel like launching PojavLauncher.

* New toggle option: Restart before launching game

This option allows the launcher to restart itself before launching the
game, therefore all changes are applied such as JVM Arguments and Java
version. The restart mechanism doesn't always work, so a toggle is
here for now.

* A few UI changes

Disable the Play button until version list finished loading
Disable ability to go back while a version is downloading
Display loading alert while logging in

* Possible fix for broken Mojang login

* Fix a NullPointerException when launching ≤ 1.6.4

* Bug fix: NPE when setting inherited fields

Unable to insert id=null
java.lang.NoSuchFieldException: id
	at java.lang.Class.getDeclaredField(Class.java:2070)
	at net.kdt.pojavlaunch.Tools.insertSafety(Tools.java:544)
	at net.kdt.pojavlaunch.Tools.getVersionInfo(Tools.java:466)
	at net.kdt.pojavlaunch.PLaunchApp.launchMinecraft(PLaunchApp.java:61)
	at
net.kdt.pojavlaunch.uikit.UIKit.callback_SurfaceViewController_launchMi
necraft(UIKit.java:104)
	at net.kdt.pojavlaunch.uikit.UIKit.launchUI(Native Method)
	at net.kdt.pojavlaunch.PLaunchApp.main(PLaunchApp.java:40)

* Keyboard + Mouse input handling; some cleanups
* Keyboard input: KeyboardInput.m
- Requires iOS 13.4. Used pressesBegan and pressesEnded.
- Not all keys are handled, these will be handled later.

* Mouse input
- Requires iOS 13.0 for hovering. Used UIHoverGestureRecognizer.
- Requires iOS 14.0 for L/R mouse buttons and scroll handling. Used GCMouse for now. We will use iOS 13.4(?)'s API later.
- Pointer lock is not yet handled.

These above apply to iPadOS aswell, not sure about tvOS. iPhone users need to disable "Perform Touch Gestures" in the AssistiveTouch Accessibility settings in order to get the pointer hovering to work.

* Cleanups
- Use asprintf instead of sprintf when possible
- CallbackBridge functions: removed unnecessary JNI fields.
- Condition cleanup (managing virtual mouse position).

* Use the old jvm arguments parser back for now

There’s no handling for backslash yet, or ignoring spaces inside delimiters.

* Remove duplicated code

* Support for input cursor movement from keyboard
New class: TrackedTextField. This class keeps track of the pointer in the text field. The hidden text field now has 40 placeholder spaces and the pointer is placed at the middle. When typing, placeholder spaces won't get removed as before. Autocorrect seem to be broken a bit for now.

Additional changes:
- Added missing GLFW functions (array version of other functions)
- Hotbar handling: doubled barWidth and barHeight

Bug fix:
- Touching onto the hotbar breaks the handling of on-screen tap/long-press gestures

* Bug fix: inputStringLength is not set back to 40

This caused a bug that clears the text when pressing backspace after
the keyboard is displayed again.

* Consolidate some code

* Fix undeclared identifier

* Consolidate some more code, fix my dumb mistake

* Added VGPU renderer

Commit:
https://github.com/PojavLauncherTeam/VGPU/commit/9f4ded5934b24c62368d70
1647855c9c9077d903

* Update LauncherPreferencesViewController.m

This line was mistakenly removed

* Various bug fixes
- Input cursor movement seems too fast, attempt to reduce it by setting larger font size in the hidden text field.
- latestlog.txt doesn't log in 1.12+ since Log4j patch. Fixed by adding some config lines.
- Makefile: building is broken when run make from a path with space(s). Fixed by handling spaces with backslashes.
- text2speech is not overridden properly. Fixed by excluding it from download list and adding launcher.jar itself to the classpath.
- XML log output in < 1.12 since Log4j patch. Fixed by using our own configuration file.

Some more changes:
- Commented out a debug line in LWJGLX
- Fix a typo.
- JavaLauncher: use (ObjC)BOOL instead of (std)bool.

* Better click handling

* Finish make ipa

Still requires proper codesigning afterwards, and until I figure out the depends folder you'll need to download a copy of the Azul JDK artifact on our android-openjdk-build-multiarch repository and extract it to depends/jre. Tested and working on my MacBook Pro, although I need to find out why libjsig.dylib is defined twice (this issue doesn't hinder the build though, install_name_tool just doesn't apply changes).

* Added readable MSA errors

* Merge unjailbroken changes with main (#313)

* fix that lol

* IPABuilder moment

* typo moment

* Hooking changes
Now hook only dladdr and realpath, JRE works now. However, need to obtain libffi.

* Sole more changes

Add RPATH to libraries
Hook dlopen since loading libawt_headless somehow point to Frameworks
directory.

* Update development.yml

* Update development.yml

Co-authored-by: Duy Tran Khanh <[email protected]>
Co-authored-by: Duy Tran Khanh <[email protected]>

* Fix issue with text alignment

* Makefile: multi-jobs building native code

* Bump to Xcode 13.2.1

* Bump to Xcode 13.2.1 pt 2

* use gnproc and nproc (for procursus on macos)

on the road development is bumpy

* oops

* [Custom controls] Added color picker for iOS < 14

Might aswell add an option to optionally use this instead of the system
color picker on iOS 14+. Used library: Alderis

Other changes
- [Custom controls] The editor is now fullscreen due to the
presentation of the color picker.
- Fixes scroll wheel input is always int

* I’m too tired of getting dpkg exits, so it’s here

* Fix broken share log

* Bug fix: Fabric 1.17+ crash at startup(fixes #304)

Microsoft account now set accountType to msa.
Minor change in custom control view controller.

* Add Arc capes

* Minor bug fix for Arc capes switch

* Change how the login progress is displayed

Login progress now displays on the title bar instead of a dialog. This
will prevent infinite loading in case a connection error occurs.
Closes #315

* Bug fix: Arc DNS injector breaks on Java 16+

This is caused by a missing function in our class loader.

Error:
System class loader does not define the
appendToClassPathForInstrumentation method
Unable to add
/Applications/PojavLauncher.app/libs/arc_dns_injector.jar to system
class path - the system class loader does not define the
appendToClassPathForInstrumentation method or the method failed
FATAL ERROR in native method: processing of -javaagent failed,
appending to system class path failed

* Why did I add set -e

* Add changelog for 2.1 release

* FAQ changes

* Workflow changes and typo fix

* Workflow changes part 2

* Fixes swipeable button state handling

* Update informational.yml

* Add A7 warning

* Remove codesign from Alderis + thin lib

* Only load Alderis.framework when needed

* CC editor: view controller now follow bounds(#326)

* Update README.md (#324)

* Update LauncherPreferencesViewController.m

Co-authored-by: Duy Tran Khanh <[email protected]>
Co-authored-by: Duy Tran Khanh <[email protected]>
Co-authored-by: Silly Sock <[email protected]>
2022-02-14 09:13:58 -05:00

358 lines
17 KiB
Objective-C

#import "CustomControlsViewController.h"
#import "JavaGUIViewController.h"
#import "LauncherPreferences.h"
#import "LauncherPreferencesViewController.h"
#import "LauncherViewController.h"
#include "utils.h"
@interface LauncherViewController () <UIDocumentPickerDelegate, UIPickerViewDataSource, UIPickerViewDelegate, UIPopoverPresentationControllerDelegate> {
}
// - (void)method
@end
@implementation LauncherViewController
NSArray* versionList;
UIPickerView* versionPickerView;
UITextField* versionTextField;
int versionSelectedAt = 0;
- (void)viewDidLoad
{
[super viewDidLoad];
viewController = self;
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
[self setNeedsUpdateOfScreenEdgesDeferringSystemGestures];
[self setNeedsUpdateOfHomeIndicatorAutoHidden];
[self setTitle:@"PojavLauncher"];
CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale];
int width = (int) roundf(screenBounds.size.width);
int height = (int) roundf(screenBounds.size.height) - self.navigationController.navigationBar.frame.size.height;
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
[self.view addSubview:scrollView];
scrollView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
// Update color mode once
if(@available(iOS 13.0, *)) {
[self traitCollectionDidChange:nil];
} else {
self.view.backgroundColor = [UIColor whiteColor];
}
UILabel *versionTextView = [[UILabel alloc] initWithFrame:CGRectMake(4.0, 4.0, 0.0, 0.0)];
versionTextView.text = @"Minecraft version: ";
versionTextView.numberOfLines = 0;
[versionTextView sizeToFit];
[scrollView addSubview:versionTextView];
versionTextField = [[UITextField alloc] initWithFrame:CGRectMake(versionTextView.bounds.size.width + 4.0, 4.0, width - versionTextView.bounds.size.width - 8.0, height - 58.0)];
[versionTextField addTarget:versionTextField action:@selector(resignFirstResponder) forControlEvents:UIControlEventEditingDidEndOnExit];
versionTextField.placeholder = @"Specify version...";
versionTextField.text = (NSString *) getPreference(@"selected_version");
versionTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;
versionTextField.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[LauncherViewController fetchVersionList];
versionPickerView = [[UIPickerView alloc] init];
versionPickerView.delegate = self;
versionPickerView.dataSource = self;
UIToolbar *versionPickToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, 44.0)];
UIBarButtonItem *versionFlexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
UIBarButtonItem *versionDoneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(versionClosePicker)];
versionPickToolbar.items = @[versionFlexibleSpace, versionDoneButton];
versionTextField.inputAccessoryView = versionPickToolbar;
versionTextField.inputView = versionPickerView;
[scrollView addSubview:versionTextField];
if (@available(iOS 14.0, *)) {
// use UIMenu
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage systemImageNamed:@"ellipsis.circle"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] style:UIBarButtonItemStyleDone target:self action:@selector(displayOptions:)];
UIAction *option1 = [UIAction actionWithTitle:@"Launch a mod installer" image:[[UIImage systemImageNamed:@"internaldrive"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] identifier:nil
handler:^(__kindof UIAction * _Nonnull action) {[self enterModInstaller:self.navigationItem.rightBarButtonItem];}];
UIAction *option2 = [UIAction actionWithTitle:@"Custom controls" image:[[UIImage systemImageNamed:@"dpad.right.fill"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] identifier:nil
handler:^(__kindof UIAction * _Nonnull action) {[self enterCustomControls];}];
UIAction *option3 = [UIAction actionWithTitle:@"Preferences" image:[[UIImage systemImageNamed:@"wrench.and.screwdriver"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] identifier:nil
handler:^(__kindof UIAction * _Nonnull action) {[self enterPreferences];}];
UIMenu *menu = [UIMenu menuWithTitle:@"" image:nil identifier:nil
options:UIMenuOptionsDisplayInline children:@[option1, option2, option3]];
self.navigationItem.rightBarButtonItem.action = nil;
self.navigationItem.rightBarButtonItem.primaryAction = nil;
self.navigationItem.rightBarButtonItem.menu = menu;
} else {
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Options" style:UIBarButtonItemStyleDone target:self action:@selector(displayOptions:)];
}
install_progress_bar = [[UIProgressView alloc] initWithFrame:CGRectMake(4.0, height - 58.0, width - 8.0, 6.0)];
[scrollView addSubview:install_progress_bar];
install_button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
install_button.enabled = NO;
[install_button setTitle:@"Play" forState:UIControlStateNormal];
install_button.frame = CGRectMake(10.0, height - 54.0, 100.0, 50.0);
[install_button addTarget:self action:@selector(launchMinecraft:) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:install_button];
install_progress_text = [[UILabel alloc] initWithFrame:CGRectMake(120.0, height - 54.0, width - 124.0, 50.0)];
[scrollView addSubview:install_progress_text];
}
+ (BOOL)isVersionInstalled:(NSString *)versionId
{
NSString *localPath = [NSString stringWithFormat:@"%s/versions/%@", getenv("POJAV_GAME_DIR"), versionId];
BOOL isDirectory;
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager fileExistsAtPath:localPath isDirectory:&isDirectory];
return isDirectory;
}
+ (void)fetchLocalVersionList:(NSMutableArray *)finalVersionList withPreviousIndex:(int)index
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *versionPath = [NSString stringWithFormat:@"%s/versions/", getenv("POJAV_GAME_DIR")];
NSArray *localVersionList = [fileManager contentsOfDirectoryAtPath:versionPath error:Nil];
for (NSString *versionId in localVersionList) {
if ([self isVersionInstalled:versionId]) {
BOOL shouldAdd = YES;
for (NSObject *object in finalVersionList) {
if (![object isKindOfClass:[NSDictionary class]]) continue;
NSDictionary *versionInfo = (NSDictionary *)object;
NSString *prevVersionId = [versionInfo valueForKey:@"id"];
if ([versionId isEqualToString:prevVersionId]) {
shouldAdd = NO;
}
}
if (shouldAdd && ![finalVersionList containsObject:versionId]) {
[finalVersionList addObject:versionId];
if ([versionTextField.text isEqualToString:versionId]) {
versionSelectedAt = index;
}
index++;
}
}
}
}
+ (void)fetchVersionList
{
NSURLSession *session = [NSURLSession sharedSession];
NSMutableURLRequest *request =
[[NSMutableURLRequest alloc] initWithURL:[NSURL
URLWithString:@"https://launchermeta.mojang.com/mc/game/version_manifest.json"]];
[request setCachePolicy:NSURLRequestReloadRevalidatingCacheData];
[request setHTTPMethod:@"GET"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSURLSessionDataTask *getDataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
long statusCode = (long)[httpResponse statusCode];
NSError *jsonError = nil;
NSDictionary *jsonArray = (data == nil) ? nil : [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
if (jsonError != nil) {
NSLog(@"Warning: Error parsing version list JSON: %@", jsonError);
} else if (statusCode == 200) {
NSArray *remoteVersionList = [jsonArray valueForKey:@"versions"];
assert(remoteVersionList != nil);
dispatch_async(dispatch_get_main_queue(), ^{
NSMutableArray *finalVersionList = [[NSMutableArray alloc] init];
int i = 0;
for (NSDictionary *versionInfo in remoteVersionList) {
NSString *versionId = [versionInfo valueForKey:@"id"];
NSString *versionType = [versionInfo valueForKey:@"type"];
if (([versionType containsString:@"release"] && [getPreference(@"vertype_release") boolValue]) ||
([versionType containsString:@"snapshot"] && [getPreference(@"vertype_snapshot") boolValue]) ||
([versionType containsString:@"old_beta"] && [getPreference(@"vertype_oldbeta") boolValue]) ||
([versionType containsString:@"old_alpha"] && [getPreference(@"vertype_oldalpha") boolValue]) ||
[versionType containsString:@"modified"] ||
[self isVersionInstalled:versionId]) {
[finalVersionList addObject:versionInfo];
if ([versionTextField.text isEqualToString:versionId]) {
versionSelectedAt = i;
}
i++;
}
}
[self fetchLocalVersionList:finalVersionList withPreviousIndex:i];
versionList = [finalVersionList copy];
[versionPickerView reloadAllComponents];
[versionPickerView selectRow:versionSelectedAt inComponent:0 animated:NO];
});
} else {
NSString *err_title = [jsonArray valueForKey:@"error"];
NSString *err_msg = [jsonArray valueForKey:@"errorMessage"];
NSLog(@"Warning: Error %ld fetching version list: %@: %@", statusCode, err_title, err_msg);
}
dispatch_async(dispatch_get_main_queue(), ^{
if (versionList == nil) { // no internet connection
NSMutableArray *finalVersionList = [[NSMutableArray alloc] init];
[self fetchLocalVersionList:finalVersionList withPreviousIndex:0];
versionList = [finalVersionList copy];
[versionPickerView reloadAllComponents];
[versionPickerView selectRow:versionSelectedAt inComponent:0 animated:NO];
}
install_button.enabled = YES;
});
}];
[getDataTask resume];
}
#pragma mark - Button click events
- (void)displayOptions:(UIBarButtonItem*)sender {
if (@available(iOS 14.0, *)) {
// use UIMenu
} else {
// use UIAlertController
UIAlertController *fullAlert = [UIAlertController alertControllerWithTitle:@"Options" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *option1 = [UIAlertAction actionWithTitle:@"Launch a mod installer" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {[self enterModInstaller:self.navigationItem.rightBarButtonItem];}];
UIAlertAction *option2 = [UIAlertAction actionWithTitle:@"Custom controls" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {[self enterCustomControls];}];
UIAlertAction *option3 = [UIAlertAction actionWithTitle:@"Preferences" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {[self enterPreferences];}];
fullAlert.popoverPresentationController.barButtonItem = sender;
[self presentViewController:fullAlert animated:YES completion:nil];
[fullAlert addAction:option1];
[fullAlert addAction:option2];
[fullAlert addAction:option3];
}
}
- (void)enterCustomControls {
if (![getPreference(@"customctrl_warn") boolValue]) {
CustomControlsViewController *vc = [[CustomControlsViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
return;
}
setPreference(@"customctrl_warn", @(NO));
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Warning" message:@"This option is unfinished, some might be incomplete or missing." preferredStyle:UIAlertControllerStyleActionSheet];
if (alert.popoverPresentationController != nil) {
alert.popoverPresentationController.sourceView = self.view;
alert.popoverPresentationController.sourceRect = CGRectMake(self.view.frame.size.width-10.0, 0, 10, 10);
}
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
CustomControlsViewController *vc = [[CustomControlsViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}];
[self presentViewController:alert animated:YES completion:nil];
[alert addAction:ok];
}
- (void)enterModInstaller:(UIBarButtonItem*)sender {
NSString *javaVer = getPreference(@"java_home");
if(![javaVer containsString:(@"java-8-openjdk")] && ![javaVer containsString:(@"jre8")]) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Cannot use the mod installer" message:@"In order to use the mod installer, you need to install Java 8 and specify it in the Preferences menu." preferredStyle:UIAlertControllerStyleActionSheet];
if (alert.popoverPresentationController != nil) {
alert.popoverPresentationController.sourceView = self.view;
alert.popoverPresentationController.sourceRect = CGRectMake(self.view.frame.size.width-10.0, 0, 10, 10);
}
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil];
[self presentViewController:alert animated:YES completion:nil];
[alert addAction:ok];
} else {
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"com.sun.java-archive"]
inMode:UIDocumentPickerModeImport];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:documentPicker animated:YES completion:nil];
}
}
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url {
if (controller.documentPickerMode == UIDocumentPickerModeImport) {
JavaGUIViewController *vc = [[JavaGUIViewController alloc] init];
vc.filepath = url.path;
NSLog(@"ModInstaller: launching %@", vc.filepath);
[self.navigationController pushViewController:vc animated:YES];
}
}
- (void)enterPreferences {
LauncherPreferencesViewController *vc = [[LauncherPreferencesViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
- (void)launchMinecraft:(UIButton *)sender {
sender.enabled = NO;
[self.navigationItem setHidesBackButton:YES animated:YES];
NSObject *object = [versionList objectAtIndex:[versionPickerView selectedRowInComponent:0]];
NSString *result;
if ([object isKindOfClass:[NSString class]]) {
result = (NSString *)object;
} else {
result = [object valueForKey:@"url"];
}
NSAssert(result != nil, @"version should not be null");
callback_LauncherViewController_installMinecraft([result UTF8String]);
}
#pragma mark - UIPopoverPresentationControllerDelegate
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(UITraitCollection *)traitCollection {
return UIModalPresentationNone;
}
#pragma mark - UIPickerView stuff
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
versionTextField.text = [self pickerView:pickerView titleForRow:row forComponent:component];
setPreference(@"selected_version", versionTextField.text);
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return versionList.count;
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
NSObject *object = [versionList objectAtIndex:row];
if ([object isKindOfClass:[NSString class]]) {
return (NSString*) object;
} else {
return [object valueForKey:@"id"];
}
}
- (void)versionClosePicker {
[versionTextField endEditing:YES];
}
#pragma mark - View controller UI mode
- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures {
return UIRectEdgeBottom;
}
- (BOOL)prefersHomeIndicatorAutoHidden {
return NO;
}
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
if(@available(iOS 13.0, *)) {
if (UITraitCollection.currentTraitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
self.view.backgroundColor = [UIColor blackColor];
} else {
self.view.backgroundColor = [UIColor whiteColor];
}
}
}
@end