Platform selector in gallery. (#6390)
This commit is contained in:
@@ -7,6 +7,8 @@ import 'dart:io' show Platform;
|
||||
import 'assertions.dart';
|
||||
|
||||
/// The platform that user interaction should adapt to target.
|
||||
///
|
||||
/// The [defaultTargetPlatform] getter returns the current platform.
|
||||
enum TargetPlatform {
|
||||
/// Android: <https://www.android.com/>
|
||||
android,
|
||||
@@ -25,7 +27,7 @@ enum TargetPlatform {
|
||||
/// regardless of the host platform. (Android was chosen because the tests were
|
||||
/// originally written assuming Android-like behavior, and we added platform
|
||||
/// adaptations for iOS later). Tests can check iOS behavior by using the
|
||||
/// platform override APIs (like in [ThemeData.platform] in the material
|
||||
/// platform override APIs (such as [ThemeData.platform] in the material
|
||||
/// library).
|
||||
TargetPlatform get defaultTargetPlatform {
|
||||
TargetPlatform result;
|
||||
|
||||
@@ -332,6 +332,66 @@ class ThemeData {
|
||||
/// Defaults to the current platform.
|
||||
final TargetPlatform platform;
|
||||
|
||||
/// Creates a copy of this theme but with the given fields replaced with the new values.
|
||||
ThemeData copyWith({
|
||||
Brightness brightness,
|
||||
Map<int, Color> primarySwatch,
|
||||
Color primaryColor,
|
||||
Brightness primaryColorBrightness,
|
||||
Color accentColor,
|
||||
Brightness accentColorBrightness,
|
||||
Color canvasColor,
|
||||
Color cardColor,
|
||||
Color dividerColor,
|
||||
Color highlightColor,
|
||||
Color splashColor,
|
||||
Color selectedRowColor,
|
||||
Color unselectedWidgetColor,
|
||||
Color disabledColor,
|
||||
Color buttonColor,
|
||||
Color secondaryHeaderColor,
|
||||
Color textSelectionColor,
|
||||
Color textSelectionHandleColor,
|
||||
Color backgroundColor,
|
||||
Color indicatorColor,
|
||||
Color hintColor,
|
||||
Color errorColor,
|
||||
TextTheme textTheme,
|
||||
TextTheme primaryTextTheme,
|
||||
IconThemeData iconTheme,
|
||||
IconThemeData primaryIconTheme,
|
||||
TargetPlatform platform,
|
||||
}) {
|
||||
return new ThemeData(
|
||||
brightness: brightness ?? this.brightness,
|
||||
primaryColor: primaryColor ?? this.primaryColor,
|
||||
primaryColorBrightness: primaryColorBrightness ?? this.primaryColorBrightness,
|
||||
accentColor: accentColor ?? this.accentColor,
|
||||
accentColorBrightness: accentColorBrightness ?? this.accentColorBrightness,
|
||||
canvasColor: canvasColor ?? this.canvasColor,
|
||||
cardColor: cardColor ?? this.cardColor,
|
||||
dividerColor: dividerColor ?? this.dividerColor,
|
||||
highlightColor: highlightColor ?? this.highlightColor,
|
||||
splashColor: splashColor ?? this.splashColor,
|
||||
selectedRowColor: selectedRowColor ?? this.selectedRowColor,
|
||||
unselectedWidgetColor: unselectedWidgetColor ?? this.unselectedWidgetColor,
|
||||
disabledColor: disabledColor ?? this.disabledColor,
|
||||
buttonColor: buttonColor ?? this.buttonColor,
|
||||
secondaryHeaderColor: secondaryHeaderColor ?? this.secondaryHeaderColor,
|
||||
textSelectionColor: textSelectionColor ?? this.textSelectionColor,
|
||||
textSelectionHandleColor: textSelectionHandleColor ?? this.textSelectionHandleColor,
|
||||
backgroundColor: backgroundColor ?? this.backgroundColor,
|
||||
indicatorColor: indicatorColor ?? this.indicatorColor,
|
||||
hintColor: hintColor ?? this.hintColor,
|
||||
errorColor: errorColor ?? this.errorColor,
|
||||
textTheme: textTheme ?? this.textTheme,
|
||||
primaryTextTheme: primaryTextTheme ?? this.primaryTextTheme,
|
||||
iconTheme: iconTheme ?? this.iconTheme,
|
||||
primaryIconTheme: primaryIconTheme ?? this.primaryIconTheme,
|
||||
platform: platform ?? this.platform,
|
||||
);
|
||||
}
|
||||
|
||||
/// Linearly interpolate between two themes.
|
||||
static ThemeData lerp(ThemeData begin, ThemeData end, double t) {
|
||||
return new ThemeData.raw(
|
||||
@@ -393,7 +453,8 @@ class ThemeData {
|
||||
(otherData.textTheme == textTheme) &&
|
||||
(otherData.primaryTextTheme == primaryTextTheme) &&
|
||||
(otherData.iconTheme == iconTheme) &&
|
||||
(otherData.primaryIconTheme == primaryIconTheme);
|
||||
(otherData.primaryIconTheme == primaryIconTheme) &&
|
||||
(otherData.platform == platform);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -417,14 +478,15 @@ class ThemeData {
|
||||
backgroundColor,
|
||||
accentColor,
|
||||
accentColorBrightness,
|
||||
indicatorColor,
|
||||
hashValues( // Too many values.
|
||||
indicatorColor,
|
||||
hintColor,
|
||||
errorColor,
|
||||
textTheme,
|
||||
primaryTextTheme,
|
||||
iconTheme,
|
||||
primaryIconTheme
|
||||
primaryIconTheme,
|
||||
platform,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user