Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7f9c045
iOS: Migrate FlutterViewController to ARC
cbracken Oct 4, 2024
60ea3e5
Migrate _engine to property
cbracken Oct 4, 2024
7e46ed2
Migrate _flutterView to property
cbracken Oct 4, 2024
b20610c
Migrate _flutterViewRenderedCallback to property
cbracken Oct 4, 2024
385e7c7
Migrate _statusBarStyle to property
cbracken Oct 4, 2024
e702f44
Migrate _initialized, _viewOpaque, _engineNeedsLaunch to properties
cbracken Oct 4, 2024
e9b7438
Migrate _ongoingTouches to property
cbracken Oct 4, 2024
4245120
Migrate _scrollView to property
cbracken Oct 4, 2024
a451b9f
Migrate _keyboardAnimationView to property
cbracken Oct 4, 2024
b4f201e
Migrate _keyboardSpringAnimation to property
cbracken Oct 4, 2024
cbb8426
Migrate scrollInertiaEvent ivars to properties
cbracken Oct 4, 2024
2606754
Make a couple more references to self weak
cbracken Oct 4, 2024
950ef83
Avoid capturing self via super
cbracken Oct 4, 2024
65129c2
Eliminate use of scoped_nsobject
cbracken Oct 4, 2024
b5b4978
Update TODO
cbracken Oct 4, 2024
f274f24
Fix typo
cbracken Oct 4, 2024
134e6d3
ivar stuff
cbracken Oct 4, 2024
03ec71b
Moar property syntax
cbracken Oct 4, 2024
258e7e6
Add engine non-nil asserts
cbracken Oct 4, 2024
5c9923b
Set explicit type for my own sanity
cbracken Oct 4, 2024
445202b
One more property
cbracken Oct 4, 2024
bd4af67
err YES, not true. NO, not false.
cbracken Oct 4, 2024
e4d6308
Let's maybe assert ARC
cbracken Oct 4, 2024
e7360f4
retain to strong
cbracken Oct 5, 2024
be400a2
Fix self capture
cbracken Oct 5, 2024
25a6263
Revert to previous setup local then assign
cbracken Oct 5, 2024
496e4f5
Remove NSAsserts on self.engine -- though we probably do want em even…
cbracken Oct 5, 2024
f757a08
review feedback: comments and todos
cbracken Oct 18, 2024
f3c808e
review feedback: moar strongSelf
cbracken Oct 18, 2024
c492fcc
Extract keyboardAnimationCallback helper
cbracken Oct 18, 2024
861d6a0
Extract onFirstFrameRendered
cbracken Oct 18, 2024
be71895
Format
cbracken Oct 18, 2024
18781e1
review feedback: method name
cbracken Oct 18, 2024
49800bb
Hangs head in shame
cbracken Oct 22, 2024
4f9cf85
Weak engine is strong
cbracken Oct 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Migrate _scrollView to property
  • Loading branch information
cbracken committed Oct 26, 2024
commit 42451200217e278d4a3e1018734ab50928e7b5a1
31 changes: 15 additions & 16 deletions shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ @interface FlutterViewController () <FlutterBinaryMessenger, UIScrollViewDelegat
@property(nonatomic, assign) BOOL isPresentingViewControllerAnimating;

@property(nonatomic, strong) NSMutableSet<NSNumber*>* ongoingTouches;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be copy?

// This scroll view is a workaround to accommodate iOS 13 and higher. There isn't a way to get
// touches on the status bar to trigger scrolling to the top of a scroll view. We place a
// UIScrollView with height zero and a content offset so we can get those events. See also:
// https://github.com/flutter/flutter/issues/35050
@property(nonatomic, strong) UIScrollView* scrollView;
/**
* Whether we should ignore viewport metrics updates during rotation transition.
*/
Expand Down Expand Up @@ -134,11 +139,6 @@ @implementation FlutterViewController {
std::unique_ptr<fml::WeakNSObjectFactory<FlutterViewController>> _weakFactory;

flutter::ViewportMetrics _viewportMetrics;
// This scroll view is a workaround to accommodate iOS 13 and higher. There isn't a way to get
// touches on the status bar to trigger scrolling to the top of a scroll view. We place a
// UIScrollView with height zero and a content offset so we can get those events. See also:
// https://github.com/flutter/flutter/issues/35050
fml::scoped_nsobject<UIScrollView> _scrollView;
fml::scoped_nsobject<UIView> _keyboardAnimationView;
fml::scoped_nsobject<SpringAnimation> _keyboardSpringAnimation;
MouseState _mouseState;
Expand Down Expand Up @@ -497,17 +497,16 @@ - (void)loadView {
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

[self installSplashScreenViewIfNecessary];
UIScrollView* scrollView = [[UIScrollView alloc] init];
scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.scrollView = [[UIScrollView alloc] init];
self.scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
// The color shouldn't matter since it is offscreen.
scrollView.backgroundColor = UIColor.whiteColor;
scrollView.delegate = self;
self.scrollView.backgroundColor = UIColor.whiteColor;
self.scrollView.delegate = self;
// This is an arbitrary small size.
scrollView.contentSize = CGSizeMake(kScrollViewContentSize, kScrollViewContentSize);
self.scrollView.contentSize = CGSizeMake(kScrollViewContentSize, kScrollViewContentSize);
// This is an arbitrary offset that is not CGPointZero.
scrollView.contentOffset = CGPointMake(kScrollViewContentSize, kScrollViewContentSize);
[self.view addSubview:scrollView];
_scrollView.reset(scrollView);
self.scrollView.contentOffset = CGPointMake(kScrollViewContentSize, kScrollViewContentSize);
[self.view addSubview:self.scrollView];
}

- (flutter::PointerData)generatePointerDataForFake {
Expand Down Expand Up @@ -971,7 +970,7 @@ - (void)dealloc {

// TODO(cbracken): https://github.com/flutter/flutter/issues/156222
// Ensure all delegates are weak and remove this.
_scrollView.get().delegate = nil;
_scrollView.delegate = nil;
_hoverGestureRecognizer.delegate = nil;
_discreteScrollingPanGestureRecognizer.delegate = nil;
_continuousScrollingPanGestureRecognizer.delegate = nil;
Expand Down Expand Up @@ -1376,8 +1375,8 @@ - (void)viewDidLayoutSubviews {
CGFloat scale = self.flutterScreenIfViewLoaded.scale;

// Purposefully place this not visible.
_scrollView.get().frame = CGRectMake(0.0, 0.0, viewBounds.size.width, 0.0);
_scrollView.get().contentOffset = CGPointMake(kScrollViewContentSize, kScrollViewContentSize);
self.scrollView.frame = CGRectMake(0.0, 0.0, viewBounds.size.width, 0.0);
self.scrollView.contentOffset = CGPointMake(kScrollViewContentSize, kScrollViewContentSize);

// First time since creation that the dimensions of its view is known.
bool firstViewBoundsUpdate = !_viewportMetrics.physical_width;
Expand Down