Make the login view into a UIMenu

This commit is contained in:
doregon committed 2021-08-09 17:07:22 -04:00
1 parent a0582d0f26
commit 0029d27175
1 file changed
+31 -13
+31 -13
View File
@@ -138,6 +138,20 @@ void loginAccountInput(UINavigationController *controller, int type, const char*
button_login.layer.cornerRadius = 5;
[button_login setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[button_login addTarget:self action:@selector(accountType:) forControlEvents:UIControlEventTouchUpInside];
if(@available (iOS 14.0, *)) {
UIAction *option1 = [UIAction actionWithTitle:@"Microsoft account" image:nil identifier:nil
handler:^(__kindof UIAction * _Nonnull action) {[self loginMicrosoft];}];
UIAction *option2 = [UIAction actionWithTitle:@"Mojang account" image:nil identifier:nil
handler:^(__kindof UIAction * _Nonnull action) {[self loginUsername:TYPE_MOJANG];}];
UIAction *option3 = [UIAction actionWithTitle:@"Demo account" image:nil identifier:nil
handler:^(__kindof UIAction * _Nonnull action) {[self loginDemo:button_login];}];
UIAction *option4 = [UIAction actionWithTitle:@"Local account" image:nil identifier:nil
handler:^(__kindof UIAction * _Nonnull action) {[self loginOffline:button_login];}];
UIMenu *menu = [UIMenu menuWithTitle:@"" image:nil identifier:nil
options:UIMenuOptionsDisplayInline children:@[option4, option3, option2, option1]];
button_login.menu = menu;
button_login.showsMenuAsPrimaryAction = YES;
}
if(@available (iOS 13.0, *)) {
button_login.imageView.image = [[UIImage systemImageNamed:@"person.crop.circle.fill.badge.plus"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[button_login setTintColor:[UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0]];
@@ -171,19 +185,23 @@ void loginAccountInput(UINavigationController *controller, int type, const char*
}
- (void)accountType:(UIButton *)sender {
UIAlertController *fullAlert = [UIAlertController alertControllerWithTitle:@"Let's get you signed in." message:@"What account do you use to log into Minecraft?"preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *mojang = [UIAlertAction actionWithTitle:@"Mojang account" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self loginUsername:TYPE_MOJANG];}];
UIAlertAction *microsoft = [UIAlertAction actionWithTitle:@"Microsoft account" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self loginMicrosoft];}];
UIAlertAction *offline = [UIAlertAction actionWithTitle:@"Local account" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self loginOffline:sender];}];
UIAlertAction *demo = [UIAlertAction actionWithTitle:@"Demo account" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self loginDemo:sender];}];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];
[self setPopoverProperties:fullAlert.popoverPresentationController sender:sender];
[self presentViewController:fullAlert animated:YES completion:nil];
[fullAlert addAction:microsoft];
[fullAlert addAction:mojang];
[fullAlert addAction:demo];
[fullAlert addAction:offline];
[fullAlert addAction:cancel];
if(@available (iOS 14.0, *)) {
// UIMenu
} else {
UIAlertController *fullAlert = [UIAlertController alertControllerWithTitle:@"Let's get you signed in." message:@"What account do you use to log into Minecraft?"preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *mojang = [UIAlertAction actionWithTitle:@"Mojang account" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self loginUsername:TYPE_MOJANG];}];
UIAlertAction *microsoft = [UIAlertAction actionWithTitle:@"Microsoft account" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self loginMicrosoft];}];
UIAlertAction *offline = [UIAlertAction actionWithTitle:@"Local account" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self loginOffline:sender];}];
UIAlertAction *demo = [UIAlertAction actionWithTitle:@"Demo account" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[self loginDemo:sender];}];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];
[self setPopoverProperties:fullAlert.popoverPresentationController sender:sender];
[self presentViewController:fullAlert animated:YES completion:nil];
[fullAlert addAction:microsoft];
[fullAlert addAction:mojang];
[fullAlert addAction:demo];
[fullAlert addAction:offline];
[fullAlert addAction:cancel];
}
}
- (void)loginUsername:(int)type {