Unverified Commit 4d788b10 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Reduce animations further when --no-cli-animations is set. (#133598)

parent d8c98c11
...@@ -124,13 +124,16 @@ Future<void> main(List<String> args) async { ...@@ -124,13 +124,16 @@ Future<void> main(List<String> args) async {
windows: globals.platform.isWindows, windows: globals.platform.isWindows,
); );
}, },
Terminal: () { AnsiTerminal: () {
return AnsiTerminal( return AnsiTerminal(
stdio: globals.stdio, stdio: globals.stdio,
platform: globals.platform, platform: globals.platform,
now: DateTime.now(), now: DateTime.now(),
isCliAnimationEnabled: featureFlags.isCliAnimationEnabled, // So that we don't animate anything before calling applyFeatureFlags, default
// the animations to disabled in real apps.
defaultCliAnimationEnabled: false,
); );
// runner.run calls "terminal.applyFeatureFlags()"
}, },
PreRunValidator: () => PreRunValidator(fileSystem: globals.fs), PreRunValidator: () => PreRunValidator(fileSystem: globals.fs),
}, },
......
...@@ -18,6 +18,7 @@ import 'src/base/logger.dart'; ...@@ -18,6 +18,7 @@ import 'src/base/logger.dart';
import 'src/base/process.dart'; import 'src/base/process.dart';
import 'src/context_runner.dart'; import 'src/context_runner.dart';
import 'src/doctor.dart'; import 'src/doctor.dart';
import 'src/features.dart';
import 'src/globals.dart' as globals; import 'src/globals.dart' as globals;
import 'src/reporting/crash_reporting.dart'; import 'src/reporting/crash_reporting.dart';
import 'src/reporting/reporting.dart'; import 'src/reporting/reporting.dart';
...@@ -44,6 +45,8 @@ Future<int> run( ...@@ -44,6 +45,8 @@ Future<int> run(
} }
return runInContext<int>(() async { return runInContext<int>(() async {
globals.terminal.applyFeatureFlags(featureFlags);
reportCrashes ??= !await globals.isRunningOnBot; reportCrashes ??= !await globals.isRunningOnBot;
final FlutterCommandRunner runner = FlutterCommandRunner(verboseHelp: verboseHelp); final FlutterCommandRunner runner = FlutterCommandRunner(verboseHelp: verboseHelp);
commands().forEach(runner.addCommand); commands().forEach(runner.addCommand);
......
...@@ -7,6 +7,9 @@ import 'dart:collection'; ...@@ -7,6 +7,9 @@ import 'dart:collection';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
// TODO(ianh): We should remove AppContext's mechanism and replace it with
// passing dependencies directly in constructors, methods, etc.
/// Generates an [AppContext] value. /// Generates an [AppContext] value.
/// ///
/// Generators are allowed to return `null`, in which case the context will /// Generators are allowed to return `null`, in which case the context will
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
import '../convert.dart'; import '../convert.dart';
import '../features.dart';
import 'io.dart' as io; import 'io.dart' as io;
import 'logger.dart'; import 'logger.dart';
import 'platform.dart'; import 'platform.dart';
...@@ -69,6 +70,7 @@ class OutputPreferences { ...@@ -69,6 +70,7 @@ class OutputPreferences {
} }
/// The command line terminal, if available. /// The command line terminal, if available.
// TODO(ianh): merge this with AnsiTerminal, the abstraction isn't giving us anything.
abstract class Terminal { abstract class Terminal {
/// Create a new test [Terminal]. /// Create a new test [Terminal].
/// ///
...@@ -81,9 +83,12 @@ abstract class Terminal { ...@@ -81,9 +83,12 @@ abstract class Terminal {
/// to perform animations. /// to perform animations.
bool get supportsColor; bool get supportsColor;
/// Whether to show animations on this terminal. /// Whether animations should be used in the output.
bool get isCliAnimationEnabled; bool get isCliAnimationEnabled;
/// Configures isCliAnimationEnabled based on a [FeatureFlags] object.
void applyFeatureFlags(FeatureFlags flags);
/// Whether the current terminal can display emoji. /// Whether the current terminal can display emoji.
bool get supportsEmoji; bool get supportsEmoji;
...@@ -158,11 +163,12 @@ class AnsiTerminal implements Terminal { ...@@ -158,11 +163,12 @@ class AnsiTerminal implements Terminal {
required io.Stdio stdio, required io.Stdio stdio,
required Platform platform, required Platform platform,
DateTime? now, // Time used to determine preferredStyle. Defaults to 0001-01-01 00:00. DateTime? now, // Time used to determine preferredStyle. Defaults to 0001-01-01 00:00.
this.isCliAnimationEnabled = true, bool defaultCliAnimationEnabled = true,
}) })
: _stdio = stdio, : _stdio = stdio,
_platform = platform, _platform = platform,
_now = now ?? DateTime(1); _now = now ?? DateTime(1),
_isCliAnimationEnabled = defaultCliAnimationEnabled;
final io.Stdio _stdio; final io.Stdio _stdio;
final Platform _platform; final Platform _platform;
...@@ -207,7 +213,14 @@ class AnsiTerminal implements Terminal { ...@@ -207,7 +213,14 @@ class AnsiTerminal implements Terminal {
bool get supportsColor => _platform.stdoutSupportsAnsi; bool get supportsColor => _platform.stdoutSupportsAnsi;
@override @override
final bool isCliAnimationEnabled; bool get isCliAnimationEnabled => _isCliAnimationEnabled;
bool _isCliAnimationEnabled;
@override
void applyFeatureFlags(FeatureFlags flags) {
_isCliAnimationEnabled = flags.isCliAnimationEnabled;
}
// Assume unicode emojis are supported when not on Windows. // Assume unicode emojis are supported when not on Windows.
// If we are on Windows, unicode emojis are supported in Windows Terminal, // If we are on Windows, unicode emojis are supported in Windows Terminal,
...@@ -419,7 +432,14 @@ class _TestTerminal implements Terminal { ...@@ -419,7 +432,14 @@ class _TestTerminal implements Terminal {
final bool supportsColor; final bool supportsColor;
@override @override
bool get isCliAnimationEnabled => supportsColor; bool get isCliAnimationEnabled => supportsColor && _isCliAnimationEnabled;
bool _isCliAnimationEnabled = true;
@override
void applyFeatureFlags(FeatureFlags flags) {
_isCliAnimationEnabled = flags.isCliAnimationEnabled;
}
@override @override
final bool supportsEmoji; final bool supportsEmoji;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'package:process/process.dart'; import 'package:process/process.dart';
...@@ -84,6 +82,8 @@ Future<T> runInContext<T>( ...@@ -84,6 +82,8 @@ Future<T> runInContext<T>(
return runner(); return runner();
} }
// TODO(ianh): We should split this into two, one for tests (which should be
// in test/), and one for production (which should be in executable.dart).
return context.run<T>( return context.run<T>(
name: 'global fallbacks', name: 'global fallbacks',
body: runnerWrapper, body: runnerWrapper,
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
import 'base/context.dart'; import 'base/context.dart';
/// The current [FeatureFlags] implementation. /// The current [FeatureFlags] implementation.
///
/// If not injected, a default implementation is provided.
FeatureFlags get featureFlags => context.get<FeatureFlags>()!; FeatureFlags get featureFlags => context.get<FeatureFlags>()!;
/// The interface used to determine if a particular [Feature] is enabled. /// The interface used to determine if a particular [Feature] is enabled.
......
...@@ -49,6 +49,9 @@ import 'runner/flutter_command.dart'; ...@@ -49,6 +49,9 @@ import 'runner/flutter_command.dart';
import 'runner/local_engine.dart'; import 'runner/local_engine.dart';
import 'version.dart'; import 'version.dart';
// TODO(ianh): We should remove all the global variables and replace them with
// arguments (to constructors, methods, etc, as appropriate).
Artifacts? get artifacts => context.get<Artifacts>(); Artifacts? get artifacts => context.get<Artifacts>();
BuildSystem get buildSystem => context.get<BuildSystem>()!; BuildSystem get buildSystem => context.get<BuildSystem>()!;
Cache get cache => context.get<Cache>()!; Cache get cache => context.get<Cache>()!;
......
...@@ -20,6 +20,7 @@ import 'package:flutter_tools/src/cache.dart'; ...@@ -20,6 +20,7 @@ import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/custom_devices.dart'; import 'package:flutter_tools/src/commands/custom_devices.dart';
import 'package:flutter_tools/src/custom_devices/custom_device_config.dart'; import 'package:flutter_tools/src/custom_devices/custom_device_config.dart';
import 'package:flutter_tools/src/custom_devices/custom_devices_config.dart'; import 'package:flutter_tools/src/custom_devices/custom_devices_config.dart';
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/runner/flutter_command_runner.dart'; import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
import '../../src/common.dart'; import '../../src/common.dart';
...@@ -241,6 +242,11 @@ class FakeTerminal implements Terminal { ...@@ -241,6 +242,11 @@ class FakeTerminal implements Terminal {
@override @override
bool get isCliAnimationEnabled => terminal.isCliAnimationEnabled; bool get isCliAnimationEnabled => terminal.isCliAnimationEnabled;
@override
void applyFeatureFlags(FeatureFlags flags) {
// ignored
}
@override @override
bool get supportsEmoji => terminal.supportsEmoji; bool get supportsEmoji => terminal.supportsEmoji;
......
...@@ -1292,7 +1292,7 @@ void main() { ...@@ -1292,7 +1292,7 @@ void main() {
terminal: AnsiTerminal( terminal: AnsiTerminal(
stdio: fakeStdio, stdio: fakeStdio,
platform: _kNoAnsiPlatform, platform: _kNoAnsiPlatform,
isCliAnimationEnabled: false, defaultCliAnimationEnabled: false,
), ),
stdio: fakeStdio, stdio: fakeStdio,
stopwatchFactory: FakeStopwatchFactory(stopwatch: FakeStopwatch()), stopwatchFactory: FakeStopwatchFactory(stopwatch: FakeStopwatch()),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment