Skip to content

Commit

Permalink
Use modals for presenting view controllers from Settings view
Browse files Browse the repository at this point in the history
Also change "Minecraft game directory" to just "Game directory". Reduce output of reloadVersionList to just localized description.
This does require the modals to have dismissModalViewController() defined in their classes, not really an issue since all view controllers will be custom classes anyway.
  • Loading branch information
crystall1nedev committed Mar 15, 2023
1 parent c310be5 commit de2b184
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
3 changes: 1 addition & 2 deletions Natives/LauncherNavigationController.m
Expand Up @@ -224,8 +224,7 @@ - (void)reloadVersionList:(int)type

reloadCompletion();
} failure:^(NSURLSessionTask *operation, NSError *error) {
NSLog(@"Warning: Unable to fetch version list: %@", error);
reloadCompletion();
NSDebugLog(@"[VersionList] Warning: Unable to fetch version list: %@", error.localizedDescription);
}];
}

Expand Down
11 changes: 10 additions & 1 deletion Natives/LauncherPrefGameDirViewController.m
Expand Up @@ -5,6 +5,8 @@
#import "ios_uikit_bridge.h"
#import "utils.h"

#define contentNavigationController (LauncherNavigationController *)UIApplication.sharedApplication.keyWindow.rootViewController.splitViewController.viewControllers[1]

@interface LauncherPrefGameDirViewController ()<UITextFieldDelegate>
@property(nonatomic) NSMutableArray *array;
@end
Expand Down Expand Up @@ -34,6 +36,9 @@ - (void)viewDidLoad
[self.array addObject:file];
}
}

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissModalViewController)];

}

- (void)changeSelectionTo:(NSString *)name {
Expand All @@ -43,7 +48,7 @@ - (void)changeSelectionTo:(NSString *)name {
[NSFileManager.defaultManager removeItemAtPath:lasmPath error:nil];
[NSFileManager.defaultManager createSymbolicLinkAtPath:lasmPath withDestinationPath:multidirPath error:nil];
if ([getPreference(@"selected_version_type") intValue] == 0) {
[(LauncherNavigationController *)self.navigationController reloadVersionList:0];
[(LauncherNavigationController *)contentNavigationController reloadVersionList:0];
}
}

Expand Down Expand Up @@ -247,6 +252,10 @@ - (void)actionDeleteAtIndexPath:(NSIndexPath *)indexPath
[self presentViewController:confirmAlert animated:YES completion:nil];
}

- (void) dismissModalViewController {
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark UITextField

- (void)textFieldDidEndEditing:(UITextField *)sender {
Expand Down
5 changes: 3 additions & 2 deletions Natives/LauncherPreferencesViewController.m
Expand Up @@ -700,8 +700,9 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath

- (void)tableView:(UITableView *)tableView openChildPaneAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *item = self.prefContents[indexPath.section][indexPath.row];
UIViewController *vc = [[item[@"class"] alloc] init];
[self.navigationController pushViewController:vc animated:YES];
UINavigationController *vc = [[UINavigationController alloc] initWithRootViewController:[[item[@"class"] alloc] init]];
vc.navigationBar.prefersLargeTitles = YES;
[self.navigationController presentViewController:vc animated:YES completion:nil];
}

- (void)tableView:(UITableView *)tableView openPickerAtIndexPath:(NSIndexPath *)indexPath {
Expand Down
2 changes: 1 addition & 1 deletion Natives/en.lproj/Localizable.strings
Expand Up @@ -133,7 +133,7 @@

"preference.title.confirm" = "Are you sure?";

"preference.title.game_directory" = "Minecraft game directory";
"preference.title.game_directory" = "Game directory";
"preference.title.confirm.delete_game_directory" = "The instance %@ will be deleted forever and cannot be restored.";
"preference.multidir.add_directory" = "add game directory";

Expand Down
Binary file modified Natives/resources/Assets.car
Binary file not shown.

0 comments on commit de2b184

Please sign in to comment.