git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

iOS/GBCheckableAlertController.m

      1 #import "GBCheckableAlertController.h"
      2 
      3 /* Private API */
      4 @interface UIAlertAction()
      5 - (bool)_isChecked;
      6 - (void)_setChecked:(bool)checked;
      7 @end
      8 
      9 @implementation GBCheckableAlertController
     10 {
     11     bool _addedChecks;
     12 }
     13 
     14 - (void)viewWillAppear:(BOOL)animated
     15 {
     16     if (@available(iOS 13.0, *)) {
     17         if (!_addedChecks && _selectedAction) {
     18             _addedChecks = true;
     19             NSMutableSet *set = [NSMutableSet setWithObject:self.view];
     20             while (set.count) {
     21                 UIView *view = [set anyObject];
     22                 [set removeObject:view];
     23                 if ([view.debugDescription containsString:_selectedAction.debugDescription]) {
     24                     UIImageView *checkImage = [[UIImageView alloc] initWithImage:[UIImage systemImageNamed:@"checkmark"]];
     25                     CGRect bounds = view.bounds;
     26                     CGRect frame = checkImage.frame;
     27                     frame.origin.x = bounds.size.width - frame.size.width - 12;
     28                     frame.origin.y = round((bounds.size.height - frame.size.height) / 2);
     29                     checkImage.frame = frame;
     30                     [view addSubview:checkImage];
     31                     break;
     32                 }
     33                 [set addObjectsFromArray:view.subviews];
     34             }
     35         }
     36     }
     37     else {
     38         [_selectedAction _setChecked:true];
     39     }
     40     [super viewWillAppear:animated];
     41 }
     42 
     43 @end

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.