diff options
Diffstat (limited to 'src/ios.m')
-rw-r--r-- | src/ios.m | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -163,7 +163,8 @@ API_AVAILABLE(ios(13.0)) | |||
163 | 163 | ||
164 | /*----------------------------------------------------------------------------------------------*/ | 164 | /*----------------------------------------------------------------------------------------------*/ |
165 | 165 | ||
166 | @interface AppState : NSObject<UIDocumentPickerDelegate, UITextFieldDelegate, UITextViewDelegate> { | 166 | @interface AppState : NSObject<UIDocumentPickerDelegate, UITextFieldDelegate, UITextViewDelegate, |
167 | UIScrollViewDelegate> { | ||
167 | iString *fileBeingSaved; | 168 | iString *fileBeingSaved; |
168 | iString *pickFileCommand; | 169 | iString *pickFileCommand; |
169 | iSystemTextInput *sysCtrl; | 170 | iSystemTextInput *sysCtrl; |
@@ -173,6 +174,7 @@ API_AVAILABLE(ios(13.0)) | |||
173 | @end | 174 | @end |
174 | 175 | ||
175 | static AppState *appState_; | 176 | static AppState *appState_; |
177 | static UIScrollView *statusBarTapper_; /* dummy scroll view just for getting notified of taps */ | ||
176 | 178 | ||
177 | @implementation AppState | 179 | @implementation AppState |
178 | 180 | ||
@@ -310,6 +312,11 @@ replacementString:(NSString *)string { | |||
310 | notifyChange_SystemTextInput_(sysCtrl); | 312 | notifyChange_SystemTextInput_(sysCtrl); |
311 | } | 313 | } |
312 | 314 | ||
315 | - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView { | ||
316 | postCommand_App("scroll.top smooth:1"); | ||
317 | return NO; | ||
318 | } | ||
319 | |||
313 | @end | 320 | @end |
314 | 321 | ||
315 | /*----------------------------------------------------------------------------------------------*/ | 322 | /*----------------------------------------------------------------------------------------------*/ |
@@ -428,6 +435,19 @@ void setupWindow_iOS(iWindow *window) { | |||
428 | UIViewController *ctl = viewController_(window); | 435 | UIViewController *ctl = viewController_(window); |
429 | isSystemDarkMode_ = isDarkMode_(window); | 436 | isSystemDarkMode_ = isDarkMode_(window); |
430 | postCommandf_App("~os.theme.changed dark:%d contrast:1", isSystemDarkMode_ ? 1 : 0); | 437 | postCommandf_App("~os.theme.changed dark:%d contrast:1", isSystemDarkMode_ ? 1 : 0); |
438 | /* A hack to get notified on status bar taps. We create a thin dummy UIScrollView | ||
439 | that occupies the top of the screen where the status bar is located. */ { | ||
440 | CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame; | ||
441 | statusBarTapper_ = [[UIScrollView alloc] initWithFrame:statusBarFrame]; | ||
442 | // [statusBarTapper_ setBackgroundColor:[UIColor greenColor]]; /* to see where it is */ | ||
443 | [statusBarTapper_ setShowsVerticalScrollIndicator:NO]; | ||
444 | [statusBarTapper_ setShowsHorizontalScrollIndicator:NO]; | ||
445 | [statusBarTapper_ setContentSize:(CGSize){ 10000, 10000 }]; | ||
446 | [statusBarTapper_ setContentOffset:(CGPoint){ 0, 1000 }]; | ||
447 | [statusBarTapper_ setScrollsToTop:YES]; | ||
448 | [statusBarTapper_ setDelegate:appState_]; | ||
449 | [ctl.view addSubview:statusBarTapper_]; | ||
450 | } | ||
431 | } | 451 | } |
432 | 452 | ||
433 | void playHapticEffect_iOS(enum iHapticEffect effect) { | 453 | void playHapticEffect_iOS(enum iHapticEffect effect) { |
@@ -445,6 +465,14 @@ void playHapticEffect_iOS(enum iHapticEffect effect) { | |||
445 | } | 465 | } |
446 | 466 | ||
447 | iBool processEvent_iOS(const SDL_Event *ev) { | 467 | iBool processEvent_iOS(const SDL_Event *ev) { |
468 | if (ev->type == SDL_DISPLAYEVENT) { | ||
469 | if (deviceType_App() == phone_AppDeviceType) { | ||
470 | [statusBarTapper_ setHidden:(ev->display.data1 == SDL_ORIENTATION_LANDSCAPE || | ||
471 | ev->display.data1 == SDL_ORIENTATION_LANDSCAPE_FLIPPED)]; | ||
472 | } | ||
473 | [statusBarTapper_ setFrame:[UIApplication sharedApplication].statusBarFrame]; | ||
474 | return iFalse; | ||
475 | } | ||
448 | if (ev->type == SDL_WINDOWEVENT) { | 476 | if (ev->type == SDL_WINDOWEVENT) { |
449 | if (ev->window.event == SDL_WINDOWEVENT_RESTORED) { | 477 | if (ev->window.event == SDL_WINDOWEVENT_RESTORED) { |
450 | const iBool isDark = isDarkMode_(get_Window()); | 478 | const iBool isDark = isDarkMode_(get_Window()); |