This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[webview_flutter] Support for loading progress tracking #2151
Merged
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
2375fa7
Added support for loading progress tracking (iOS & Android)
jeremie-movify 704cc75
Updated changelog, bumped plugin version & fixed Dart analyzer
jeremie-movify 90b47c1
Fixed formatting
jeremie-movify a795c90
Fixed formatting for FlutterWebView & FlutterWebViewClient
jeremie-movify a618831
One more formatting pass
jeremie-movify e201d3c
One more formatting pass
jeremie-movify 1fe7ef4
Merge branch 'master' into progress-tracking
jeremie-movify 03a6307
Merge branch 'master' into progress-tracking
jeremie-movify b1052b4
Merge branch 'master' into progress-tracking
jeremie-movify 5cd61b2
Update FLTWKNavigationDelegate.h
jeremie-movify f153499
Update pubspec.yaml
jeremie-movify 19d697e
Added missing null return
jeremie-movify 9ceea3c
Merge branch 'master' into progress-tracking
jeremie-movify a5906b3
Merge branch 'master' into progress-tracking
jeremie-movify a357555
Merge branch 'flutter-origin-master' into progress-tracking
jeremie-movify eb809fc
Merge branch 'master' into progress-tracking
jeremie-movify 636ad6f
Merge branch 'master' into progress-tracking
jeremie-movify 677bad9
Trigger checks
jeremie-movify 25af806
Merge branch 'master' into progress-tracking
jeremie-movify a020da2
Merge branch 'master' into progress-tracking
jeremie-movify 07ab322
Improvements based on @cyanglaz's feedback
jeremie-movify f3de98b
Only observe newValues on webView's 'estimatedProgress' keyPath
jeremie-movify 76e2d76
Fixed formatting
jeremie-movify a778bf3
Updated keyPath constant name to FLTWKEstimatedProgressKeyPath
jeremie-movify 0090288
Fixed formatting
jeremie-movify a6f2b53
Merge branch 'flutter-origin-master' into progress-tracking
jeremie-movify a706d3e
Fixed formatting
jeremie-movify 2897586
Merge branch 'flutter-origin-master' into progress-tracking
jeremie-movify 24c77c2
Merge branch 'flutter-origin-master' into progress-tracking
jeremie-movify 069af29
Fixed hasProgressTracking nullability
jeremie-movify 6fa576d
Nullability fixes
jeremie-movify 7d7c400
One more
jeremie-movify 11e6ade
Fixed imports
jeremie-movify 1747608
Merge branch 'flutter-origin-master' into progress-tracking
jeremie-movify 16c7d33
Trigger checks
jeremie-movify 73d09be
Imported androidx.annotation.NonNull to fix apk build on cirrus
jeremie-movify a9bcf56
Merge branch 'master' into progress-tracking
jeremie-movify d9438f1
Merge branch 'flutter-origin-master' into progress-tracking
jeremie-movify 6cc00fc
PR remarks: Android: improved progress tracking setup & reused existi…
jeremie-movify File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/webview_flutter/ios/Classes/FLTWKProgressionDelegate.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#import <Flutter/Flutter.h> | ||
#import <Foundation/Foundation.h> | ||
#import <WebKit/WebKit.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface FLTWKProgressionDelegate : NSObject | ||
|
||
- (instancetype)initWithWebView:(WKWebView *)webView channel:(FlutterMethodChannel *)channel; | ||
|
||
- (void)stopObservingProgress:(WKWebView *)webView; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
42 changes: 42 additions & 0 deletions
42
packages/webview_flutter/ios/Classes/FLTWKProgressionDelegate.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#import "FLTWKProgressionDelegate.h" | ||
|
||
NSString *const FLTWKEstimatedProgressKeyPath = @"estimatedProgress"; | ||
|
||
@implementation FLTWKProgressionDelegate { | ||
FlutterMethodChannel *_methodChannel; | ||
} | ||
|
||
- (instancetype)initWithWebView:(WKWebView *)webView channel:(FlutterMethodChannel *)channel { | ||
self = [super init]; | ||
if (self) { | ||
_methodChannel = channel; | ||
[webView addObserver:self | ||
forKeyPath:FLTWKEstimatedProgressKeyPath | ||
options:NSKeyValueObservingOptionNew | ||
context:nil]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)stopObservingProgress:(WKWebView *)webView { | ||
[webView removeObserver:self forKeyPath:FLTWKEstimatedProgressKeyPath]; | ||
} | ||
|
||
- (void)observeValueForKeyPath:(NSString *)keyPath | ||
ofObject:(id)object | ||
change:(NSDictionary<NSKeyValueChangeKey, id> *)change | ||
context:(void *)context { | ||
if ([keyPath isEqualToString:FLTWKEstimatedProgressKeyPath]) { | ||
NSNumber *newValue = | ||
change[NSKeyValueChangeNewKey] ?: 0; // newValue is anywhere between 0.0 and 1.0 | ||
int newValueAsInt = [newValue floatValue] * 100; // Anywhere between 0 and 100 | ||
[_methodChannel invokeMethod:@"onProgress" | ||
arguments:@{@"progress" : [NSNumber numberWithInt:newValueAsInt]}]; | ||
} | ||
} | ||
|
||
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.