Skip to content

Commit df9d8f0

Browse files
committed
Merge commit 'f58a65003cb3650e7c85e7bc4907454d03bf68a3' into custom-lg
* commit 'f58a65003cb3650e7c85e7bc4907454d03bf68a3': chewie, version 1.8.3. Adds PR fluttercommunity#828. Updated workflows so that they now run tests as a result of this PR. format add small test for verification add fix for cupertino & desktop recreate ios project to make it runnable again Update material_controls.dart fix: isFinished is true only if initialized else false # Conflicts: # example/ios/Runner.xcodeproj/project.pbxproj
2 parents 4af7f27 + f58a650 commit df9d8f0

28 files changed

+414
-68
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
steps:
2020
- name: Checkout code
21-
uses: actions/checkout@v2
21+
uses: actions/checkout@v4
2222
- name: Flutter Action
2323
uses: subosito/flutter-action@v2
2424
- name: Check format
@@ -30,7 +30,7 @@ jobs:
3030

3131
steps:
3232
- name: Checkout code
33-
uses: actions/checkout@v2
33+
uses: actions/checkout@v4
3434
- name: Flutter Action
3535
uses: subosito/flutter-action@v2
3636
- name: Install Package Dependencies
@@ -41,15 +41,16 @@ jobs:
4141
- name: Lint using flutter analyze
4242
run: flutter analyze .
4343

44-
# test:
45-
# name: Test2
46-
# runs-on: ubuntu-latest
44+
test:
45+
name: Run tests.
46+
runs-on: ubuntu-latest
4747

48-
# steps:
49-
# - name: Checkout code
50-
# uses: actions/checkout@v2
51-
# - uses: subosito/flutter-action@v1
52-
# with:
53-
# channel: beta
54-
# - name: Test
55-
# run: flutter test
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@v4
51+
- name: Flutter Action
52+
uses: subosito/flutter-action@v2
53+
- name: Run flutter test
54+
run: |
55+
flutter pub get
56+
flutter test

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## [1.8.3]
2+
* 🛠️ [#828](https://github.com/fluttercommunity/chewie/pull/828): Fix the logic of the Center Play Button icon selection. Thanks [EmreDET](https://github.com/EmreDET).
3+
14
## 1.8.2
25
* ⬆️ [#842](https://github.com/fluttercommunity/chewie/pull/842): package upgrades. Thanks [vaishnavi-2301](https://github.com/vaishnavi-2301).
36

example/.metadata

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,27 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: ab4506cad2a860e1cb6186c0957eeb86024a7c6b
8-
channel: dev
7+
revision: "b0850beeb25f6d5b10426284f506557f66181b36"
8+
channel: "stable"
9+
10+
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: b0850beeb25f6d5b10426284f506557f66181b36
17+
base_revision: b0850beeb25f6d5b10426284f506557f66181b36
18+
- platform: ios
19+
create_revision: b0850beeb25f6d5b10426284f506557f66181b36
20+
base_revision: b0850beeb25f6d5b10426284f506557f66181b36
21+
22+
# User provided section
23+
24+
# List of Local paths (relative to this file) that should be
25+
# ignored by the migrate tool.
26+
#
27+
# Files that are not part of the templates will be ignored by default.
28+
unmanaged_files:
29+
- 'lib/main.dart'
30+
- 'ios/Runner.xcodeproj/project.pbxproj'

example/ios/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
**/dgph
12
*.mode1v3
23
*.mode2v3
34
*.moved-aside

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 218 additions & 40 deletions
Large diffs are not rendered by default.

example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
30-
<Testables>
31-
</Testables>
3230
<MacroExpansion>
3331
<BuildableReference
3432
BuildableIdentifier = "primary"
@@ -38,8 +36,19 @@
3836
ReferencedContainer = "container:Runner.xcodeproj">
3937
</BuildableReference>
4038
</MacroExpansion>
41-
<AdditionalOptions>
42-
</AdditionalOptions>
39+
<Testables>
40+
<TestableReference
41+
skipped = "NO"
42+
parallelizable = "YES">
43+
<BuildableReference
44+
BuildableIdentifier = "primary"
45+
BlueprintIdentifier = "331C8080294A63A400263BE5"
46+
BuildableName = "RunnerTests.xctest"
47+
BlueprintName = "RunnerTests"
48+
ReferencedContainer = "container:Runner.xcodeproj">
49+
</BuildableReference>
50+
</TestableReference>
51+
</Testables>
4352
</TestAction>
4453
<LaunchAction
4554
buildConfiguration = "Debug"
@@ -61,8 +70,6 @@
6170
ReferencedContainer = "container:Runner.xcodeproj">
6271
</BuildableReference>
6372
</BuildableProductRunnable>
64-
<AdditionalOptions>
65-
</AdditionalOptions>
6673
</LaunchAction>
6774
<ProfileAction
6875
buildConfiguration = "Profile"

example/ios/Runner/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import UIKit
21
import Flutter
2+
import UIKit
33

44
@UIApplicationMain
55
@objc class AppDelegate: FlutterAppDelegate {
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

example/ios/Runner/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<dict>
55
<key>CFBundleDevelopmentRegion</key>
66
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>Example</string>
79
<key>CFBundleExecutable</key>
810
<string>$(EXECUTABLE_NAME)</string>
911
<key>CFBundleIdentifier</key>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Flutter
2+
import UIKit
3+
import XCTest
4+
5+
class RunnerTests: XCTestCase {
6+
7+
func testExample() {
8+
// If you add code to the Runner application, consider adding tests here.
9+
// See https://developer.apple.com/documentation/xctest for more information about using XCTest.
10+
}
11+
12+
}

lib/src/cupertino/cupertino_controls.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,8 @@ class _CupertinoControlsState extends State<CupertinoControls>
346346
}
347347

348348
Widget _buildHitArea() {
349-
final bool isFinished = _latestValue.position >= _latestValue.duration;
349+
final bool isFinished = (_latestValue.position >= _latestValue.duration) &&
350+
_latestValue.duration.inSeconds > 0;
350351
final bool showPlayButton =
351352
widget.showPlayButton && !_latestValue.isPlaying && !_dragging;
352353

@@ -726,7 +727,8 @@ class _CupertinoControlsState extends State<CupertinoControls>
726727
}
727728

728729
void _playPause() {
729-
final isFinished = _latestValue.position >= _latestValue.duration;
730+
final isFinished = _latestValue.position >= _latestValue.duration &&
731+
_latestValue.duration.inSeconds > 0;
730732

731733
setState(() {
732734
if (controller.value.isPlaying) {

lib/src/material/material_controls.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ class _MaterialControlsState extends State<MaterialControls>
364364
}
365365

366366
Widget _buildHitArea() {
367-
final bool isFinished = _latestValue.position >= _latestValue.duration;
367+
final bool isFinished = (_latestValue.position >= _latestValue.duration) &&
368+
_latestValue.duration.inSeconds > 0;
368369
final bool showPlayButton =
369370
widget.showPlayButton && !_dragging && !notifier.hideStuff;
370371

@@ -519,7 +520,8 @@ class _MaterialControlsState extends State<MaterialControls>
519520
}
520521

521522
void _playPause() {
522-
final isFinished = _latestValue.position >= _latestValue.duration;
523+
final bool isFinished = (_latestValue.position >= _latestValue.duration) &&
524+
_latestValue.duration.inSeconds > 0;
523525

524526
setState(() {
525527
if (controller.value.isPlaying) {

lib/src/material/material_desktop_controls.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
327327
}
328328

329329
Widget _buildHitArea() {
330-
final bool isFinished = _latestValue.position >= _latestValue.duration;
330+
final bool isFinished = _latestValue.position >= _latestValue.duration &&
331+
_latestValue.duration.inSeconds > 0;
331332
final bool showPlayButton =
332333
widget.showPlayButton && !_dragging && !notifier.hideStuff;
333334

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: chewie
22
description: A video player for Flutter with Cupertino and Material play controls
3-
version: 1.8.2
3+
version: 1.8.3
44
homepage: https://github.com/fluttercommunity/chewie
55

66
environment:
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import 'package:chewie/chewie.dart';
2+
import 'package:chewie/src/center_play_button.dart';
3+
import 'package:flutter/material.dart';
4+
import 'package:flutter_test/flutter_test.dart';
5+
import 'package:video_player/video_player.dart';
6+
7+
List<String> srcs = [
8+
"https://assets.mixkit.co/videos/preview/mixkit-spinning-around-the-earth-29351-large.mp4",
9+
"https://assets.mixkit.co/videos/preview/mixkit-daytime-city-traffic-aerial-view-56-large.mp4",
10+
"https://assets.mixkit.co/videos/preview/mixkit-a-girl-blowing-a-bubble-gum-at-an-amusement-park-1226-large.mp4"
11+
];
12+
13+
main() {
14+
testWidgets("MaterialControls state test", (WidgetTester tester) async {
15+
// Build our app and trigger a frame.
16+
var videoPlayerController = VideoPlayerController.networkUrl(
17+
Uri.parse(srcs[0]),
18+
);
19+
var materialControlsKey = GlobalKey();
20+
var chewieController = ChewieController(
21+
videoPlayerController: videoPlayerController,
22+
autoPlay: false,
23+
looping: false,
24+
customControls: MaterialControls(
25+
key: materialControlsKey,
26+
),
27+
);
28+
await tester.pumpWidget(
29+
MaterialApp(
30+
home: Scaffold(
31+
body: Chewie(
32+
controller: chewieController,
33+
),
34+
),
35+
),
36+
);
37+
38+
await tester.pump();
39+
40+
var playButton = find.byType(CenterPlayButton);
41+
expect(playButton, findsOneWidget);
42+
var btn = playButton.first;
43+
var playButtonWidget = tester.widget<CenterPlayButton>(btn);
44+
expect(playButtonWidget.isFinished, false);
45+
});
46+
47+
testWidgets("CupertinoControls state test", (WidgetTester tester) async {
48+
// Build our app and trigger a frame.
49+
var videoPlayerController = VideoPlayerController.networkUrl(
50+
Uri.parse(srcs[0]),
51+
);
52+
var materialControlsKey = GlobalKey();
53+
var chewieController = ChewieController(
54+
videoPlayerController: videoPlayerController,
55+
autoPlay: false,
56+
looping: false,
57+
customControls: CupertinoControls(
58+
key: materialControlsKey,
59+
backgroundColor: Colors.black,
60+
iconColor: Colors.white,
61+
),
62+
);
63+
await tester.pumpWidget(
64+
MaterialApp(
65+
home: Scaffold(
66+
body: Chewie(
67+
controller: chewieController,
68+
),
69+
),
70+
),
71+
);
72+
73+
await tester.pump();
74+
75+
var playButton = find.byType(CenterPlayButton);
76+
expect(playButton, findsOneWidget);
77+
var btn = playButton.first;
78+
var playButtonWidget = tester.widget<CenterPlayButton>(btn);
79+
expect(playButtonWidget.isFinished, false);
80+
});
81+
82+
testWidgets("MaterialDesktopControls state test",
83+
(WidgetTester tester) async {
84+
// Build our app and trigger a frame.
85+
var videoPlayerController = VideoPlayerController.networkUrl(
86+
Uri.parse(srcs[0]),
87+
);
88+
var materialControlsKey = GlobalKey();
89+
var chewieController = ChewieController(
90+
videoPlayerController: videoPlayerController,
91+
autoPlay: false,
92+
looping: false,
93+
customControls: MaterialDesktopControls(
94+
key: materialControlsKey,
95+
),
96+
);
97+
await tester.pumpWidget(
98+
MaterialApp(
99+
home: Scaffold(
100+
body: Chewie(
101+
controller: chewieController,
102+
),
103+
),
104+
),
105+
);
106+
107+
await tester.pump();
108+
109+
var playButton = find.byType(CenterPlayButton);
110+
expect(playButton, findsOneWidget);
111+
var btn = playButton.first;
112+
var playButtonWidget = tester.widget<CenterPlayButton>(btn);
113+
expect(playButtonWidget.isFinished, false);
114+
});
115+
}

0 commit comments

Comments
 (0)