Shiyun Wen
4 年前
当前提交
ae118ebb
共有 41 个文件被更改,包括 5790 次插入 和 1056 次删除
-
2Samples/UIWidgetsSamples_2019_4/.idea/.idea.UIWidgetsSamples_2019_4/.idea/indexLayout.xml
-
405Samples/UIWidgetsSamples_2019_4/.idea/.idea.UIWidgetsSamples_2019_4/.idea/workspace.xml
-
570Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsExample.cs
-
14Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/GalleryMain.cs
-
35Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_text_field_demo.cs
-
319com.unity.uiwidgets/Runtime/cupertino/action_Sheet.cs
-
46com.unity.uiwidgets/Runtime/cupertino/activity_indicator.cs
-
118com.unity.uiwidgets/Runtime/cupertino/app.cs
-
71com.unity.uiwidgets/Runtime/cupertino/button.cs
-
998com.unity.uiwidgets/Runtime/cupertino/date_picker.cs
-
21com.unity.uiwidgets/Runtime/cupertino/dialog.cs
-
5com.unity.uiwidgets/Runtime/cupertino/localization.cs
-
20com.unity.uiwidgets/Runtime/cupertino/nav_bar.cs
-
16com.unity.uiwidgets/Runtime/cupertino/page_scaffold.cs
-
44com.unity.uiwidgets/Runtime/cupertino/route.cs
-
5com.unity.uiwidgets/Runtime/cupertino/scrollbar.cs
-
2com.unity.uiwidgets/Runtime/cupertino/tab_view.cs
-
261com.unity.uiwidgets/Runtime/cupertino/text_theme.cs
-
318com.unity.uiwidgets/Runtime/cupertino/theme.cs
-
2com.unity.uiwidgets/Runtime/cupertino/bottom_tab_bar.cs.meta
-
2com.unity.uiwidgets/Runtime/cupertino/colors.cs.meta
-
14com.unity.uiwidgets/Runtime/ui2/geometry.cs
-
30com.unity.uiwidgets/Runtime/widgets/app.cs
-
3com.unity.uiwidgets/Runtime/widgets/automatic_keep_alive.cs
-
2com.unity.uiwidgets/Runtime/widgets/list_wheel_scroll_view.cs
-
951com.unity.uiwidgets/Runtime/widgets/navigator.cs
-
41com.unity.uiwidgets/Runtime/widgets/routes.cs
-
233com.unity.uiwidgets/Runtime/cupertino/bottom_tab_bar.cs
-
763com.unity.uiwidgets/Runtime/cupertino/colors.cs
-
1001com.unity.uiwidgets/Runtime/cupertino/context_menu.cs
-
11com.unity.uiwidgets/Runtime/cupertino/context_menu.cs.meta
-
151com.unity.uiwidgets/Runtime/cupertino/context_menu_action.cs
-
11com.unity.uiwidgets/Runtime/cupertino/context_menu_action.cs.meta
-
45com.unity.uiwidgets/Runtime/cupertino/icon_theme_data.cs
-
11com.unity.uiwidgets/Runtime/cupertino/icon_theme_data.cs.meta
-
65com.unity.uiwidgets/Runtime/cupertino/interface_level.cs
-
11com.unity.uiwidgets/Runtime/cupertino/interface_level.cs.meta
-
204com.unity.uiwidgets/Runtime/cupertino/bottom_app_bar.cs
-
25com.unity.uiwidgets/Runtime/cupertino/color.cs
-
0/com.unity.uiwidgets/Runtime/cupertino/bottom_tab_bar.cs.meta
-
0/com.unity.uiwidgets/Runtime/cupertino/colors.cs.meta
998
com.unity.uiwidgets/Runtime/cupertino/date_picker.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
951
com.unity.uiwidgets/Runtime/widgets/navigator.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
class BottomAppBarUtils { |
|||
public const float _kTabBarHeight = 50.0f; |
|||
|
|||
public static readonly Color _kDefaultTabBarBorderColor = |
|||
CupertinoDynamicColor.withBrightness( |
|||
color: new Color(0x4C000000), |
|||
darkColor: new Color(0x29000000) |
|||
); |
|||
public static readonly Color _kDefaultTabBarInactiveColor = CupertinoColors.inactiveGray; |
|||
} |
|||
|
|||
|
|||
public class CupertinoTabBar : StatelessWidget{ |
|||
|
|||
public CupertinoTabBar( |
|||
Key key = null, |
|||
List<BottomNavigationBarItem> items = null, |
|||
ValueChanged<int> onTap = null, |
|||
int currentIndex = 0, |
|||
Color backgroundColor = null, |
|||
Color activeColor = null, |
|||
Color inactiveColor = null, |
|||
float iconSize = 30.0f, |
|||
Border border = null |
|||
) : base(key: key) { |
|||
|
|||
D.assert(items != null); |
|||
D.assert(items.Count >= 2, |
|||
() => "Tabs need at least 2 items to conform to Apple's HIG" |
|||
); |
|||
D.assert(0 <= currentIndex && currentIndex < items.Count); |
|||
|
|||
this.items = items; |
|||
this.onTap = onTap; |
|||
this.currentIndex = currentIndex; |
|||
this.backgroundColor = backgroundColor; |
|||
this.activeColor = activeColor; |
|||
this.inactiveColor = inactiveColor ?? BottomAppBarUtils._kDefaultTabBarInactiveColor; |
|||
this.iconSize = iconSize; |
|||
this.border = border ?? new Border( |
|||
top: new BorderSide( |
|||
color: BottomAppBarUtils._kDefaultTabBarBorderColor, |
|||
width: 0.0f, // One physical pixel.
|
|||
style: BorderStyle.solid |
|||
) |
|||
); |
|||
} |
|||
|
|||
public readonly List<BottomNavigationBarItem> items; |
|||
|
|||
public readonly ValueChanged<int> onTap; |
|||
|
|||
public readonly int currentIndex; |
|||
|
|||
public readonly Color backgroundColor; |
|||
|
|||
public readonly Color activeColor; |
|||
|
|||
public readonly Color inactiveColor; |
|||
|
|||
public readonly float iconSize; |
|||
|
|||
public readonly Border border; |
|||
|
|||
public Size preferredSize { |
|||
get { return Size.fromHeight(BottomAppBarUtils._kTabBarHeight); } |
|||
} |
|||
|
|||
public bool opaque(BuildContext context) { |
|||
Color backgroundColor = |
|||
this.backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor; |
|||
return CupertinoDynamicColor.resolve(backgroundColor, context).alpha == 0xFF; |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
float bottomPadding = MediaQuery.of(context).padding.bottom; |
|||
Color backgroundColor = CupertinoDynamicColor.resolve( |
|||
this.backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor, |
|||
context |
|||
); |
|||
BorderSide resolveBorderSide(BorderSide side) { |
|||
return side == BorderSide.none |
|||
? side |
|||
: side.copyWith(color: CupertinoDynamicColor.resolve(side.color, context)); |
|||
} |
|||
Border resolvedBorder = border == null || border.GetType() != typeof(Border) |
|||
? border |
|||
: new Border( |
|||
top: resolveBorderSide(border.top), |
|||
left: resolveBorderSide(border.left), |
|||
bottom: resolveBorderSide(border.bottom), |
|||
right: resolveBorderSide(border.right) |
|||
); |
|||
|
|||
Color inactive = CupertinoDynamicColor.resolve(inactiveColor, context); |
|||
Widget result = new DecoratedBox( |
|||
decoration: new BoxDecoration( |
|||
border: resolvedBorder,//border,
|
|||
color: backgroundColor //?? CupertinoTheme.of(context).barBackgroundColor
|
|||
), |
|||
child: new SizedBox( |
|||
height: BottomAppBarUtils._kTabBarHeight + bottomPadding, |
|||
child: IconTheme.merge( // Default with the inactive state.
|
|||
data: new IconThemeData( |
|||
color: inactiveColor, |
|||
size: iconSize |
|||
), |
|||
child: new DefaultTextStyle( // Default with the inactive state.
|
|||
style: CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(color: inactive), |
|||
//CupertinoTheme.of(context).textTheme.tabLabelTextStyle
|
|||
child: new Padding( |
|||
padding: EdgeInsets.only(bottom: bottomPadding), |
|||
child: new Row( |
|||
crossAxisAlignment: CrossAxisAlignment.end, |
|||
children: _buildTabItems(context) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
); |
|||
|
|||
if (!opaque(context)) { |
|||
result = new ClipRect( |
|||
child: new BackdropFilter( |
|||
filter: ImageFilter.blur(sigmaX: 10.0f, sigmaY: 10.0f), |
|||
child: result |
|||
) |
|||
); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
List<Widget> _buildTabItems(BuildContext context) { |
|||
List<Widget> result = new List<Widget> { }; |
|||
|
|||
for (int index = 0; index < items.Count; index += 1) { |
|||
bool active = index == currentIndex; |
|||
var tabIndex = index; |
|||
result.Add( |
|||
_wrapActiveItem( |
|||
context, |
|||
new Expanded( |
|||
//// ??? semantics tbc ???
|
|||
child: new GestureDetector( |
|||
behavior: HitTestBehavior.opaque, |
|||
onTap: onTap == null ? null : (GestureTapCallback) (() => { onTap(tabIndex); }), |
|||
child: new Padding( |
|||
padding: EdgeInsets.only(bottom: 4.0f), |
|||
child: new Column( |
|||
mainAxisAlignment: MainAxisAlignment.end, |
|||
children: _buildSingleTabItem(items[index], active) |
|||
) |
|||
) |
|||
) |
|||
), |
|||
active: active |
|||
) |
|||
); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
List<Widget> _buildSingleTabItem(BottomNavigationBarItem item, bool active) { |
|||
List<Widget> components = new List<Widget> { |
|||
new Expanded( |
|||
child: new Center(child: active ? item.activeIcon : item.icon) |
|||
) |
|||
}; |
|||
|
|||
if (item.title != null) { |
|||
components.Add(item.title); |
|||
} |
|||
|
|||
return components; |
|||
} |
|||
|
|||
Widget _wrapActiveItem(BuildContext context, Widget item, bool active) { |
|||
if (!active) { |
|||
return item; |
|||
} |
|||
|
|||
//Color activeColor = this.activeColor ?? CupertinoTheme.of(context).primaryColor;
|
|||
Color activeColor = CupertinoDynamicColor.resolve( |
|||
this.activeColor ?? CupertinoTheme.of(context).primaryColor, |
|||
context |
|||
); |
|||
return IconTheme.merge( |
|||
data: new IconThemeData(color: activeColor), |
|||
child: DefaultTextStyle.merge( |
|||
style: new TextStyle(color: activeColor), |
|||
child: item |
|||
) |
|||
); |
|||
} |
|||
|
|||
public CupertinoTabBar copyWith( |
|||
Key key = null, |
|||
List<BottomNavigationBarItem> items = null, |
|||
Color backgroundColor = null, |
|||
Color activeColor = null, |
|||
Color inactiveColor = null, |
|||
float? iconSize = null, |
|||
Border border = null, |
|||
int? currentIndex = null, |
|||
ValueChanged<int> onTap = null |
|||
) { |
|||
return new CupertinoTabBar( |
|||
key: key ?? this.key, |
|||
items: items ?? this.items, |
|||
backgroundColor: backgroundColor ?? this.backgroundColor, |
|||
activeColor: activeColor ?? this.activeColor, |
|||
inactiveColor: inactiveColor ?? this.inactiveColor, |
|||
iconSize: iconSize ?? this.iconSize, |
|||
border: border ?? this.border, |
|||
currentIndex: currentIndex ?? this.currentIndex, |
|||
onTap: onTap ?? this.onTap |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.widgets; |
|||
using Unity.UIWidgets.painting; |
|||
namespace Unity.UIWidgets.cupertino { |
|||
public class CupertinoColors { |
|||
public static CupertinoDynamicColor activeBlue = systemBlue; |
|||
public static CupertinoDynamicColor activeGreen = systemGreen; |
|||
public static CupertinoDynamicColor activeOrange = systemOrange; |
|||
|
|||
public static Color white = new Color(0xFFFFFFFF); |
|||
public static Color black = new Color(0xFF000000); |
|||
public static Color lightBackgroundGray = new Color(0xFFE5E5EA); |
|||
public static Color extraLightBackgroundGray = new Color(0xFFEFEFF4); |
|||
public static Color darkBackgroundGray = new Color(0xFF171717); |
|||
|
|||
public static CupertinoDynamicColor inactiveGray = CupertinoDynamicColor.withBrightness( |
|||
debugLabel: "inactiveGray", |
|||
color: new Color(0xFF999999), |
|||
darkColor: new Color(0xFF757575) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor destructiveRed = systemRed; |
|||
|
|||
public static CupertinoDynamicColor systemBlue = CupertinoDynamicColor.withBrightnessAndContrast( |
|||
debugLabel: "systemBlue", |
|||
color: Color.fromARGB(255, 0, 122, 255), |
|||
darkColor: Color.fromARGB(255, 10, 132, 255), |
|||
highContrastColor: Color.fromARGB(255, 0, 64, 221), |
|||
darkHighContrastColor: Color.fromARGB(255, 64, 156, 255) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor systemGreen = CupertinoDynamicColor.withBrightnessAndContrast( |
|||
debugLabel: "systemGreen", |
|||
color: Color.fromARGB(255, 52, 199, 89), |
|||
darkColor: Color.fromARGB(255, 48, 209, 88), |
|||
highContrastColor: Color.fromARGB(255, 36, 138, 61), |
|||
darkHighContrastColor: Color.fromARGB(255, 48, 219, 91) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor systemIndigo = CupertinoDynamicColor.withBrightnessAndContrast( |
|||
debugLabel: "systemIndigo", |
|||
color: Color.fromARGB(255, 88, 86, 214), |
|||
darkColor: Color.fromARGB(255, 94, 92, 230), |
|||
highContrastColor: Color.fromARGB(255, 54, 52, 163), |
|||
darkHighContrastColor: Color.fromARGB(255, 125, 122, 255) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor systemOrange = CupertinoDynamicColor.withBrightnessAndContrast( |
|||
debugLabel: "systemOrange", |
|||
color: Color.fromARGB(255, 255, 149, 0), |
|||
darkColor: Color.fromARGB(255, 255, 159, 10), |
|||
highContrastColor: Color.fromARGB(255, 201, 52, 0), |
|||
darkHighContrastColor: Color.fromARGB(255, 255, 179, 64) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor systemPink = CupertinoDynamicColor.withBrightnessAndContrast( |
|||
debugLabel: "systemPink", |
|||
color: Color.fromARGB(255, 255, 45, 85), |
|||
darkColor: Color.fromARGB(255, 255, 55, 95), |
|||
highContrastColor: Color.fromARGB(255, 211, 15, 69), |
|||
darkHighContrastColor: Color.fromARGB(255, 255, 100, 130) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor systemPurple = CupertinoDynamicColor.withBrightnessAndContrast( |
|||
debugLabel: "systemPurple", |
|||
color: Color.fromARGB(255, 175, 82, 222), |
|||
darkColor: Color.fromARGB(255, 191, 90, 242), |
|||
highContrastColor: Color.fromARGB(255, 137, 68, 171), |
|||
darkHighContrastColor: Color.fromARGB(255, 218, 143, 255) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor systemRed = CupertinoDynamicColor.withBrightnessAndContrast( |
|||
debugLabel: "systemRed", |
|||
color: Color.fromARGB(255, 255, 59, 48), |
|||
darkColor: Color.fromARGB(255, 255, 69, 58), |
|||
highContrastColor: Color.fromARGB(255, 215, 0, 21), |
|||
darkHighContrastColor: Color.fromARGB(255, 255, 105, 97) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor systemTeal = CupertinoDynamicColor.withBrightnessAndContrast( |
|||
debugLabel: "systemTeal", |
|||
color: Color.fromARGB(255, 90, 200, 250), |
|||
darkColor: Color.fromARGB(255, 100, 210, 255), |
|||
highContrastColor: Color.fromARGB(255, 0, 113, 164), |
|||
darkHighContrastColor: Color.fromARGB(255, 112, 215, 255) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor systemYellow = CupertinoDynamicColor.withBrightnessAndContrast( |
|||
debugLabel: "systemYellow", |
|||
color: Color.fromARGB(255, 255, 204, 0), |
|||
darkColor: Color.fromARGB(255, 255, 214, 10), |
|||
highContrastColor: Color.fromARGB(255, 160, 90, 0), |
|||
darkHighContrastColor: Color.fromARGB(255, 255, 212, 38) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor systemGrey = CupertinoDynamicColor.withBrightnessAndContrast( |
|||
debugLabel: "systemGrey", |
|||
color: Color.fromARGB(255, 142, 142, 147), |
|||
darkColor: Color.fromARGB(255, 142, 142, 147), |
|||
highContrastColor: Color.fromARGB(255, 108, 108, 112), |
|||
darkHighContrastColor: Color.fromARGB(255, 174, 174, 178) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor systemGrey2 = CupertinoDynamicColor.withBrightnessAndContrast( |
|||
debugLabel: "systemGrey2", |
|||
color: Color.fromARGB(255, 174, 174, 178), |
|||
darkColor: Color.fromARGB(255, 99, 99, 102), |
|||
highContrastColor: Color.fromARGB(255, 142, 142, 147), |
|||
darkHighContrastColor: Color.fromARGB(255, 124, 124, 128) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor systemGrey3 = CupertinoDynamicColor.withBrightnessAndContrast( |
|||
debugLabel: "systemGrey3", |
|||
color: Color.fromARGB(255, 199, 199, 204), |
|||
darkColor: Color.fromARGB(255, 72, 72, 74), |
|||
highContrastColor: Color.fromARGB(255, 174, 174, 178), |
|||
darkHighContrastColor: Color.fromARGB(255, 84, 84, 86) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor systemGrey4 = CupertinoDynamicColor.withBrightnessAndContrast( |
|||
debugLabel: "systemGrey4", |
|||
color: Color.fromARGB(255, 209, 209, 214), |
|||
darkColor: Color.fromARGB(255, 58, 58, 60), |
|||
highContrastColor: Color.fromARGB(255, 188, 188, 192), |
|||
darkHighContrastColor: Color.fromARGB(255, 68, 68, 70) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor systemGrey5 = CupertinoDynamicColor.withBrightnessAndContrast( |
|||
debugLabel: "systemGrey5", |
|||
color: Color.fromARGB(255, 229, 229, 234), |
|||
darkColor: Color.fromARGB(255, 44, 44, 46), |
|||
highContrastColor: Color.fromARGB(255, 216, 216, 220), |
|||
darkHighContrastColor: Color.fromARGB(255, 54, 54, 56) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor systemGrey6 = CupertinoDynamicColor.withBrightnessAndContrast( |
|||
debugLabel: "systemGrey6", |
|||
color: Color.fromARGB(255, 242, 242, 247), |
|||
darkColor: Color.fromARGB(255, 28, 28, 30), |
|||
highContrastColor: Color.fromARGB(255, 235, 235, 240), |
|||
darkHighContrastColor: Color.fromARGB(255, 36, 36, 38) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor label = new CupertinoDynamicColor( |
|||
debugLabel: "label", |
|||
color: Color.fromARGB(255, 0, 0, 0), |
|||
darkColor: Color.fromARGB(255, 255, 255, 255), |
|||
highContrastColor: Color.fromARGB(255, 0, 0, 0), |
|||
darkHighContrastColor: Color.fromARGB(255, 255, 255, 255), |
|||
elevatedColor: Color.fromARGB(255, 0, 0, 0), |
|||
darkElevatedColor: Color.fromARGB(255, 255, 255, 255), |
|||
highContrastElevatedColor: Color.fromARGB(255, 0, 0, 0), |
|||
darkHighContrastElevatedColor: Color.fromARGB(255, 255, 255, 255) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor secondaryLabel = new CupertinoDynamicColor( |
|||
debugLabel: "secondaryLabel", |
|||
color: Color.fromARGB(153, 60, 60, 67), |
|||
darkColor: Color.fromARGB(153, 235, 235, 245), |
|||
highContrastColor: Color.fromARGB(173, 60, 60, 67), |
|||
darkHighContrastColor: Color.fromARGB(173, 235, 235, 245), |
|||
elevatedColor: Color.fromARGB(153, 60, 60, 67), |
|||
darkElevatedColor: Color.fromARGB(153, 235, 235, 245), |
|||
highContrastElevatedColor: Color.fromARGB(173, 60, 60, 67), |
|||
darkHighContrastElevatedColor: Color.fromARGB(173, 235, 235, 245) |
|||
); |
|||
|
|||
/// The color for text labels containing tertiary content, equivalent to
|
|||
/// [UIColor.tertiaryLabel](https://developer.apple.com/documentation/uikit/uicolor/3173153-tertiarylabel).
|
|||
public static CupertinoDynamicColor tertiaryLabel = new CupertinoDynamicColor( |
|||
debugLabel: "tertiaryLabel", |
|||
color: Color.fromARGB(76, 60, 60, 67), |
|||
darkColor: Color.fromARGB(76, 235, 235, 245), |
|||
highContrastColor: Color.fromARGB(96, 60, 60, 67), |
|||
darkHighContrastColor: Color.fromARGB(96, 235, 235, 245), |
|||
elevatedColor: Color.fromARGB(76, 60, 60, 67), |
|||
darkElevatedColor: Color.fromARGB(76, 235, 235, 245), |
|||
highContrastElevatedColor: Color.fromARGB(96, 60, 60, 67), |
|||
darkHighContrastElevatedColor: Color.fromARGB(96, 235, 235, 245) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor quaternaryLabel = new CupertinoDynamicColor( |
|||
debugLabel: "quaternaryLabel", |
|||
color: Color.fromARGB(45, 60, 60, 67), |
|||
darkColor: Color.fromARGB(40, 235, 235, 245), |
|||
highContrastColor: Color.fromARGB(66, 60, 60, 67), |
|||
darkHighContrastColor: Color.fromARGB(61, 235, 235, 245), |
|||
elevatedColor: Color.fromARGB(45, 60, 60, 67), |
|||
darkElevatedColor: Color.fromARGB(40, 235, 235, 245), |
|||
highContrastElevatedColor: Color.fromARGB(66, 60, 60, 67), |
|||
darkHighContrastElevatedColor: Color.fromARGB(61, 235, 235, 245) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor systemFill = new CupertinoDynamicColor( |
|||
debugLabel: "systemFill", |
|||
color: Color.fromARGB(51, 120, 120, 128), |
|||
darkColor: Color.fromARGB(91, 120, 120, 128), |
|||
highContrastColor: Color.fromARGB(71, 120, 120, 128), |
|||
darkHighContrastColor: Color.fromARGB(112, 120, 120, 128), |
|||
elevatedColor: Color.fromARGB(51, 120, 120, 128), |
|||
darkElevatedColor: Color.fromARGB(91, 120, 120, 128), |
|||
highContrastElevatedColor: Color.fromARGB(71, 120, 120, 128), |
|||
darkHighContrastElevatedColor: Color.fromARGB(112, 120, 120, 128) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor secondarySystemFill = new CupertinoDynamicColor( |
|||
debugLabel: "secondarySystemFill", |
|||
color: Color.fromARGB(40, 120, 120, 128), |
|||
darkColor: Color.fromARGB(81, 120, 120, 128), |
|||
highContrastColor: Color.fromARGB(61, 120, 120, 128), |
|||
darkHighContrastColor: Color.fromARGB(102, 120, 120, 128), |
|||
elevatedColor: Color.fromARGB(40, 120, 120, 128), |
|||
darkElevatedColor: Color.fromARGB(81, 120, 120, 128), |
|||
highContrastElevatedColor: Color.fromARGB(61, 120, 120, 128), |
|||
darkHighContrastElevatedColor: Color.fromARGB(102, 120, 120, 128) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor tertiarySystemFill = new CupertinoDynamicColor( |
|||
debugLabel: "tertiarySystemFill", |
|||
color: Color.fromARGB(30, 118, 118, 128), |
|||
darkColor: Color.fromARGB(61, 118, 118, 128), |
|||
highContrastColor: Color.fromARGB(51, 118, 118, 128), |
|||
darkHighContrastColor: Color.fromARGB(81, 118, 118, 128), |
|||
elevatedColor: Color.fromARGB(30, 118, 118, 128), |
|||
darkElevatedColor: Color.fromARGB(61, 118, 118, 128), |
|||
highContrastElevatedColor: Color.fromARGB(51, 118, 118, 128), |
|||
darkHighContrastElevatedColor: Color.fromARGB(81, 118, 118, 128) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor quaternarySystemFill = new CupertinoDynamicColor( |
|||
debugLabel: "quaternarySystemFill", |
|||
color: Color.fromARGB(20, 116, 116, 128), |
|||
darkColor: Color.fromARGB(45, 118, 118, 128), |
|||
highContrastColor: Color.fromARGB(40, 116, 116, 128), |
|||
darkHighContrastColor: Color.fromARGB(66, 118, 118, 128), |
|||
elevatedColor: Color.fromARGB(20, 116, 116, 128), |
|||
darkElevatedColor: Color.fromARGB(45, 118, 118, 128), |
|||
highContrastElevatedColor: Color.fromARGB(40, 116, 116, 128), |
|||
darkHighContrastElevatedColor: Color.fromARGB(66, 118, 118, 128) |
|||
); |
|||
|
|||
/// The color for placeholder text in controls or text views, equivalent to
|
|||
/// [UIColor.placeholderText](https://developer.apple.com/documentation/uikit/uicolor/3173134-placeholdertext).
|
|||
public static CupertinoDynamicColor placeholderText = new CupertinoDynamicColor( |
|||
debugLabel: "placeholderText", |
|||
color: Color.fromARGB(76, 60, 60, 67), |
|||
darkColor: Color.fromARGB(76, 235, 235, 245), |
|||
highContrastColor: Color.fromARGB(96, 60, 60, 67), |
|||
darkHighContrastColor: Color.fromARGB(96, 235, 235, 245), |
|||
elevatedColor: Color.fromARGB(76, 60, 60, 67), |
|||
darkElevatedColor: Color.fromARGB(76, 235, 235, 245), |
|||
highContrastElevatedColor: Color.fromARGB(96, 60, 60, 67), |
|||
darkHighContrastElevatedColor: Color.fromARGB(96, 235, 235, 245) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor systemBackground = new CupertinoDynamicColor( |
|||
debugLabel: "systemBackground", |
|||
color: Color.fromARGB(255, 255, 255, 255), |
|||
darkColor: Color.fromARGB(255, 0, 0, 0), |
|||
highContrastColor: Color.fromARGB(255, 255, 255, 255), |
|||
darkHighContrastColor: Color.fromARGB(255, 0, 0, 0), |
|||
elevatedColor: Color.fromARGB(255, 255, 255, 255), |
|||
darkElevatedColor: Color.fromARGB(255, 28, 28, 30), |
|||
highContrastElevatedColor: Color.fromARGB(255, 255, 255, 255), |
|||
darkHighContrastElevatedColor: Color.fromARGB(255, 36, 36, 38) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor secondarySystemBackground = new CupertinoDynamicColor( |
|||
debugLabel: "secondarySystemBackground", |
|||
color: Color.fromARGB(255, 242, 242, 247), |
|||
darkColor: Color.fromARGB(255, 28, 28, 30), |
|||
highContrastColor: Color.fromARGB(255, 235, 235, 240), |
|||
darkHighContrastColor: Color.fromARGB(255, 36, 36, 38), |
|||
elevatedColor: Color.fromARGB(255, 242, 242, 247), |
|||
darkElevatedColor: Color.fromARGB(255, 44, 44, 46), |
|||
highContrastElevatedColor: Color.fromARGB(255, 235, 235, 240), |
|||
darkHighContrastElevatedColor: Color.fromARGB(255, 54, 54, 56) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor tertiarySystemBackground = new CupertinoDynamicColor( |
|||
debugLabel: "tertiarySystemBackground", |
|||
color: Color.fromARGB(255, 255, 255, 255), |
|||
darkColor: Color.fromARGB(255, 44, 44, 46), |
|||
highContrastColor: Color.fromARGB(255, 255, 255, 255), |
|||
darkHighContrastColor: Color.fromARGB(255, 54, 54, 56), |
|||
elevatedColor: Color.fromARGB(255, 255, 255, 255), |
|||
darkElevatedColor: Color.fromARGB(255, 58, 58, 60), |
|||
highContrastElevatedColor: Color.fromARGB(255, 255, 255, 255), |
|||
darkHighContrastElevatedColor: Color.fromARGB(255, 68, 68, 70) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor systemGroupedBackground = new CupertinoDynamicColor( |
|||
debugLabel: "systemGroupedBackground", |
|||
color: Color.fromARGB(255, 242, 242, 247), |
|||
darkColor: Color.fromARGB(255, 0, 0, 0), |
|||
highContrastColor: Color.fromARGB(255, 235, 235, 240), |
|||
darkHighContrastColor: Color.fromARGB(255, 0, 0, 0), |
|||
elevatedColor: Color.fromARGB(255, 242, 242, 247), |
|||
darkElevatedColor: Color.fromARGB(255, 28, 28, 30), |
|||
highContrastElevatedColor: Color.fromARGB(255, 235, 235, 240), |
|||
darkHighContrastElevatedColor: Color.fromARGB(255, 36, 36, 38) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor secondarySystemGroupedBackground = new CupertinoDynamicColor( |
|||
debugLabel: "secondarySystemGroupedBackground", |
|||
color: Color.fromARGB(255, 255, 255, 255), |
|||
darkColor: Color.fromARGB(255, 28, 28, 30), |
|||
highContrastColor: Color.fromARGB(255, 255, 255, 255), |
|||
darkHighContrastColor: Color.fromARGB(255, 36, 36, 38), |
|||
elevatedColor: Color.fromARGB(255, 255, 255, 255), |
|||
darkElevatedColor: Color.fromARGB(255, 44, 44, 46), |
|||
highContrastElevatedColor: Color.fromARGB(255, 255, 255, 255), |
|||
darkHighContrastElevatedColor: Color.fromARGB(255, 54, 54, 56) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor tertiarySystemGroupedBackground = new CupertinoDynamicColor( |
|||
debugLabel: "tertiarySystemGroupedBackground", |
|||
color: Color.fromARGB(255, 242, 242, 247), |
|||
darkColor: Color.fromARGB(255, 44, 44, 46), |
|||
highContrastColor: Color.fromARGB(255, 235, 235, 240), |
|||
darkHighContrastColor: Color.fromARGB(255, 54, 54, 56), |
|||
elevatedColor: Color.fromARGB(255, 242, 242, 247), |
|||
darkElevatedColor: Color.fromARGB(255, 58, 58, 60), |
|||
highContrastElevatedColor: Color.fromARGB(255, 235, 235, 240), |
|||
darkHighContrastElevatedColor: Color.fromARGB(255, 68, 68, 70) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor separator = new CupertinoDynamicColor( |
|||
debugLabel: "separator", |
|||
color: Color.fromARGB(73, 60, 60, 67), |
|||
darkColor: Color.fromARGB(153, 84, 84, 88), |
|||
highContrastColor: Color.fromARGB(94, 60, 60, 67), |
|||
darkHighContrastColor: Color.fromARGB(173, 84, 84, 88), |
|||
elevatedColor: Color.fromARGB(73, 60, 60, 67), |
|||
darkElevatedColor: Color.fromARGB(153, 84, 84, 88), |
|||
highContrastElevatedColor: Color.fromARGB(94, 60, 60, 67), |
|||
darkHighContrastElevatedColor: Color.fromARGB(173, 84, 84, 88) |
|||
); |
|||
|
|||
/// The color for borders or divider lines that hide any underlying content,
|
|||
/// equivalent to [UIColor.opaqueSeparator](https://developer.apple.com/documentation/uikit/uicolor/3173133-opaqueseparator).
|
|||
public static CupertinoDynamicColor opaqueSeparator = new CupertinoDynamicColor( |
|||
debugLabel: "opaqueSeparator", |
|||
color: Color.fromARGB(255, 198, 198, 200), |
|||
darkColor: Color.fromARGB(255, 56, 56, 58), |
|||
highContrastColor: Color.fromARGB(255, 198, 198, 200), |
|||
darkHighContrastColor: Color.fromARGB(255, 56, 56, 58), |
|||
elevatedColor: Color.fromARGB(255, 198, 198, 200), |
|||
darkElevatedColor: Color.fromARGB(255, 56, 56, 58), |
|||
highContrastElevatedColor: Color.fromARGB(255, 198, 198, 200), |
|||
darkHighContrastElevatedColor: Color.fromARGB(255, 56, 56, 58) |
|||
); |
|||
|
|||
public static CupertinoDynamicColor link = |
|||
new CupertinoDynamicColor( |
|||
debugLabel: "link", |
|||
color: Color.fromARGB(255, 0, 122, 255), |
|||
darkColor: Color.fromARGB(255, 9, 132, 255), |
|||
highContrastColor: Color.fromARGB(255, 0, 122, 255), |
|||
darkHighContrastColor: Color.fromARGB(255, 9, 132, 255), |
|||
elevatedColor: Color.fromARGB(255, 0, 122, 255), |
|||
darkElevatedColor: Color.fromARGB(255, 9, 132, 255), |
|||
highContrastElevatedColor: Color.fromARGB(255, 0, 122, 255), |
|||
darkHighContrastElevatedColor: Color.fromARGB(255, 9, 132, 255) |
|||
); |
|||
} |
|||
|
|||
public class CupertinoDynamicColor : Color, Diagnosticable { |
|||
|
|||
public CupertinoDynamicColor( |
|||
string debugLabel = null, |
|||
Color color = null, |
|||
Color darkColor = null, |
|||
Color highContrastColor = null, |
|||
Color darkHighContrastColor = null, |
|||
Color elevatedColor = null, |
|||
Color darkElevatedColor = null, |
|||
Color highContrastElevatedColor = null, |
|||
Color darkHighContrastElevatedColor = null |
|||
) : base(0) { |
|||
/// ._
|
|||
D.assert(color != null); |
|||
D.assert(darkColor != null); |
|||
D.assert(highContrastColor != null); |
|||
D.assert(darkHighContrastColor != null); |
|||
D.assert(elevatedColor != null); |
|||
D.assert(darkElevatedColor != null); |
|||
D.assert(highContrastElevatedColor != null); |
|||
D.assert(darkHighContrastElevatedColor != null); |
|||
D.assert(_effectiveColor != null); |
|||
_effectiveColor = color; |
|||
this.color = color; |
|||
this.darkColor = darkColor; |
|||
this.highContrastColor = highContrastColor; |
|||
this.darkHighContrastColor = darkHighContrastColor; |
|||
this.elevatedColor = elevatedColor; |
|||
this.darkElevatedColor = darkElevatedColor; |
|||
this.highContrastElevatedColor = highContrastElevatedColor; |
|||
this.darkHighContrastElevatedColor = darkHighContrastElevatedColor; |
|||
_debugResolveContext = null; |
|||
_debugLabel = debugLabel; |
|||
} |
|||
|
|||
public static CupertinoDynamicColor create( |
|||
Color _effectiveColor, |
|||
Color color, |
|||
Color darkColor , |
|||
Color highContrastColor , |
|||
Color darkHighContrastColor , |
|||
Color elevatedColor , |
|||
Color darkElevatedColor , |
|||
Color highContrastElevatedColor , |
|||
Color darkHighContrastElevatedColor , |
|||
Element _debugResolveContext , |
|||
string _debugLabel |
|||
) { |
|||
var dynamicColor = new CupertinoDynamicColor( |
|||
debugLabel: _debugLabel, |
|||
color: color, |
|||
darkColor: darkColor, |
|||
highContrastColor: color, |
|||
darkHighContrastColor: darkColor, |
|||
elevatedColor: color, |
|||
darkElevatedColor: darkColor, |
|||
highContrastElevatedColor: color, |
|||
darkHighContrastElevatedColor: darkColor |
|||
); |
|||
dynamicColor._effectiveColor = _effectiveColor; |
|||
dynamicColor._debugResolveContext = _debugResolveContext; |
|||
return dynamicColor; |
|||
|
|||
} |
|||
|
|||
public static CupertinoDynamicColor withBrightnessAndContrast( |
|||
string debugLabel = null, |
|||
Color color = null, |
|||
Color darkColor = null, |
|||
Color highContrastColor = null, |
|||
Color darkHighContrastColor = null |
|||
) { |
|||
|
|||
return new CupertinoDynamicColor( |
|||
debugLabel: debugLabel, |
|||
color: color, |
|||
darkColor: darkColor, |
|||
highContrastColor: highContrastColor, |
|||
darkHighContrastColor: darkHighContrastColor, |
|||
elevatedColor: color, |
|||
darkElevatedColor: darkColor, |
|||
highContrastElevatedColor: highContrastColor, |
|||
darkHighContrastElevatedColor: darkHighContrastColor |
|||
); |
|||
} |
|||
|
|||
public static CupertinoDynamicColor withBrightness( |
|||
string debugLabel = null, |
|||
Color color = null, |
|||
Color darkColor = null |
|||
) { |
|||
return new CupertinoDynamicColor( |
|||
debugLabel: debugLabel, |
|||
color: color, |
|||
darkColor: darkColor, |
|||
highContrastColor: color, |
|||
darkHighContrastColor: darkColor, |
|||
elevatedColor: color, |
|||
darkElevatedColor: darkColor, |
|||
highContrastElevatedColor: color, |
|||
darkHighContrastElevatedColor: darkColor); |
|||
} |
|||
|
|||
public Color _effectiveColor; |
|||
|
|||
|
|||
public int value { |
|||
get { return (int) _effectiveColor.value; } |
|||
} |
|||
|
|||
|
|||
public readonly string _debugLabel; |
|||
|
|||
public Element _debugResolveContext; |
|||
public readonly Color color; |
|||
|
|||
public readonly Color darkColor; |
|||
|
|||
public readonly Color highContrastColor; |
|||
public readonly Color darkHighContrastColor; |
|||
|
|||
public readonly Color elevatedColor; |
|||
|
|||
public readonly Color darkElevatedColor; |
|||
public readonly Color highContrastElevatedColor; |
|||
public readonly Color darkHighContrastElevatedColor; |
|||
|
|||
|
|||
public static Color resolve(Color resolvable, BuildContext context, bool nullOk = true) { |
|||
if (resolvable == null) |
|||
return null; |
|||
D.assert(context != null); |
|||
return (resolvable is CupertinoDynamicColor) |
|||
? ((CupertinoDynamicColor) resolvable).resolveFrom(context, nullOk: nullOk) |
|||
: resolvable; |
|||
} |
|||
|
|||
public bool _isPlatformBrightnessDependent { |
|||
get { |
|||
return color != darkColor |
|||
|| elevatedColor != darkElevatedColor |
|||
|| highContrastColor != darkHighContrastColor |
|||
|| highContrastElevatedColor != darkHighContrastElevatedColor; |
|||
} |
|||
|
|||
} |
|||
|
|||
public bool _isHighContrastDependent { |
|||
get { |
|||
return color != highContrastColor |
|||
|| darkColor != darkHighContrastColor |
|||
|| elevatedColor != highContrastElevatedColor |
|||
|| darkElevatedColor != darkHighContrastElevatedColor; |
|||
} |
|||
} |
|||
|
|||
public bool _isInterfaceElevationDependent { |
|||
get { |
|||
return color != elevatedColor |
|||
|| darkColor != darkElevatedColor |
|||
|| highContrastColor != highContrastElevatedColor |
|||
|| darkHighContrastColor != darkHighContrastElevatedColor; |
|||
} |
|||
} |
|||
|
|||
public CupertinoDynamicColor resolveFrom(BuildContext context, bool nullOk = true) { |
|||
Brightness brightness = _isPlatformBrightnessDependent |
|||
? CupertinoTheme.brightnessOf(context, nullOk: nullOk) ?? Brightness.light |
|||
: Brightness.light; |
|||
|
|||
bool isHighContrastEnabled = _isHighContrastDependent |
|||
&& (MediaQuery.of(context, nullOk: nullOk)?.highContrast ?? false); |
|||
|
|||
CupertinoUserInterfaceLevelData? CupertinoUserInterfacelevel = |
|||
CupertinoUserInterfaceLevel.of(context, nullOk: nullOk); |
|||
CupertinoUserInterfaceLevelData level = _isInterfaceElevationDependent |
|||
? CupertinoUserInterfacelevel ?? CupertinoUserInterfaceLevelData.baselayer |
|||
: CupertinoUserInterfaceLevelData.baselayer; |
|||
|
|||
Color resolved = null; |
|||
switch (brightness) { |
|||
case Brightness.light: |
|||
switch (level) { |
|||
case CupertinoUserInterfaceLevelData.baselayer: |
|||
resolved = isHighContrastEnabled ? highContrastColor : color; |
|||
break; |
|||
case CupertinoUserInterfaceLevelData.elevatedlayer: |
|||
resolved = isHighContrastEnabled ? highContrastElevatedColor : elevatedColor; |
|||
break; |
|||
} |
|||
|
|||
break; |
|||
case Brightness.dark: |
|||
switch (level) { |
|||
case CupertinoUserInterfaceLevelData.baselayer: |
|||
resolved = isHighContrastEnabled ? darkHighContrastColor : darkColor; |
|||
break; |
|||
case CupertinoUserInterfaceLevelData.elevatedlayer: |
|||
resolved = isHighContrastEnabled ? darkHighContrastElevatedColor : darkElevatedColor; |
|||
break; |
|||
} |
|||
|
|||
break; |
|||
} |
|||
|
|||
Element _debugContext = null; |
|||
D.assert(() => { |
|||
_debugContext = context as Element; |
|||
return true; |
|||
} |
|||
); |
|||
return create( |
|||
resolved, |
|||
color, |
|||
darkColor, |
|||
highContrastColor, |
|||
darkHighContrastColor, |
|||
elevatedColor, |
|||
darkElevatedColor, |
|||
highContrastElevatedColor, |
|||
darkHighContrastElevatedColor, |
|||
_debugContext, |
|||
_debugLabel |
|||
|
|||
); |
|||
} |
|||
|
|||
public bool Equals(CupertinoDynamicColor other) { |
|||
if (ReferenceEquals(null, other)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, other)) { |
|||
return true; |
|||
} |
|||
|
|||
return Equals(value, other.value) && Equals(darkColor, other.darkColor) && |
|||
Equals(highContrastColor, other.highContrastColor) |
|||
&& Equals(darkHighContrastColor, other.darkHighContrastColor) |
|||
&& Equals(elevatedColor, other.elevatedColor) |
|||
&& Equals(darkElevatedColor, other.darkElevatedColor) |
|||
&& Equals(highContrastElevatedColor, other.highContrastElevatedColor) |
|||
&& Equals(darkHighContrastElevatedColor, other.darkHighContrastElevatedColor); |
|||
} |
|||
|
|||
public override bool Equals(object obj) { |
|||
|
|||
if (ReferenceEquals(null, obj)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, obj)) { |
|||
return true; |
|||
} |
|||
|
|||
if (obj.GetType() != GetType()) { |
|||
return false; |
|||
} |
|||
|
|||
return Equals((CupertinoDynamicColor) obj); |
|||
} |
|||
|
|||
public override int GetHashCode() { |
|||
unchecked { |
|||
var hashCode = (value != null ? value.GetHashCode() : 0); |
|||
hashCode = (color != null ? color.GetHashCode() : 0); |
|||
hashCode = (hashCode * 397) ^ (darkColor != null ? darkColor.GetHashCode() : 0); |
|||
hashCode = (hashCode * 397) ^ (highContrastColor != null ? highContrastColor.GetHashCode() : 0); |
|||
hashCode = (hashCode * 397) ^ (elevatedColor != null ? elevatedColor.GetHashCode() : 0); |
|||
hashCode = (hashCode * 397) ^ (darkElevatedColor != null ? darkElevatedColor.GetHashCode() : 0); |
|||
hashCode = (hashCode * 397) ^ (darkHighContrastColor != null ? darkHighContrastColor.GetHashCode() : 0); |
|||
hashCode = (hashCode * 397) ^ (darkHighContrastElevatedColor != null |
|||
? darkHighContrastElevatedColor.GetHashCode() |
|||
: 0); |
|||
hashCode = (hashCode * 397) ^ |
|||
(highContrastElevatedColor != null ? highContrastElevatedColor.GetHashCode() : 0); |
|||
return hashCode; |
|||
} |
|||
|
|||
} |
|||
|
|||
public static bool operator ==(CupertinoDynamicColor left, CupertinoDynamicColor right) { |
|||
return Equals(left, right); |
|||
} |
|||
|
|||
public static bool operator !=(CupertinoDynamicColor left, CupertinoDynamicColor right) { |
|||
return !Equals(left, right); |
|||
} |
|||
|
|||
public override string ToString() { |
|||
return toString(); |
|||
} |
|||
|
|||
public string toString(DiagnosticLevel minLevel = DiagnosticLevel.debug) { |
|||
List<string> xs = new List<string>(); |
|||
xs.Add(toStringColor("color",color)); |
|||
if (_isPlatformBrightnessDependent) |
|||
xs.Add(toStringColor("darkColor", darkColor)); |
|||
if (_isHighContrastDependent) |
|||
xs.Add( toStringColor("highContrastColor", highContrastColor)); |
|||
if (_isPlatformBrightnessDependent && _isHighContrastDependent) |
|||
xs.Add(toStringColor("darkHighContrastColor", darkHighContrastColor)); |
|||
if (_isInterfaceElevationDependent) |
|||
xs.Add( toStringColor("elevatedColor", elevatedColor)); |
|||
if (_isPlatformBrightnessDependent && _isInterfaceElevationDependent) |
|||
xs.Add(toStringColor("darkElevatedColor", darkElevatedColor)); |
|||
if (_isHighContrastDependent && _isInterfaceElevationDependent) |
|||
xs.Add(toStringColor("highContrastElevatedColor", highContrastElevatedColor)); |
|||
if (_isPlatformBrightnessDependent && _isHighContrastDependent && _isInterfaceElevationDependent) |
|||
xs.Add(toStringColor("darkHighContrastElevatedColor", darkHighContrastElevatedColor)); |
|||
|
|||
string xsStr = ""; |
|||
foreach (var xss in xs) { |
|||
xsStr += xss; |
|||
} |
|||
var debugContext = _debugResolveContext?.widget; |
|||
if (_debugResolveContext?.widget == null) { |
|||
return $"[{_debugLabel ?? GetType().ToString()}({xsStr}, resolved by: UNRESOLVED)]"; |
|||
} |
|||
else { |
|||
return $"[{_debugLabel ?? GetType().ToString()}({xsStr}, resolved by: {_debugResolveContext?.widget })]"; |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
public string toStringColor(string name, Color color) { |
|||
string marker = color == _effectiveColor ? "*" : ""; |
|||
return marker + name + " = " + color.ToString() + marker; |
|||
} |
|||
|
|||
|
|||
public new void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
if (_debugLabel != null) |
|||
properties.add(new MessageProperty("debugLabel", _debugLabel)); |
|||
properties.add(createCupertinoColorProperty("color", color)); |
|||
if (_isPlatformBrightnessDependent) |
|||
properties.add(createCupertinoColorProperty("darkColor", darkColor)); |
|||
if (_isHighContrastDependent) |
|||
properties.add(createCupertinoColorProperty("highContrastColor", highContrastColor)); |
|||
if (_isPlatformBrightnessDependent && _isHighContrastDependent) |
|||
properties.add(createCupertinoColorProperty("darkHighContrastColor", darkHighContrastColor)); |
|||
if (_isInterfaceElevationDependent) |
|||
properties.add(createCupertinoColorProperty("elevatedColor", elevatedColor)); |
|||
if (_isPlatformBrightnessDependent && _isInterfaceElevationDependent) |
|||
properties.add(createCupertinoColorProperty("darkElevatedColor", darkElevatedColor)); |
|||
if (_isHighContrastDependent && _isInterfaceElevationDependent) |
|||
properties.add(createCupertinoColorProperty("highContrastElevatedColor", highContrastElevatedColor)); |
|||
if (_isPlatformBrightnessDependent && _isHighContrastDependent && _isInterfaceElevationDependent) |
|||
properties.add(createCupertinoColorProperty("darkHighContrastElevatedColor", |
|||
darkHighContrastElevatedColor)); |
|||
|
|||
if (_debugResolveContext != null) |
|||
properties.add(new DiagnosticsProperty<Element>("last resolved", _debugResolveContext)); |
|||
|
|||
} |
|||
|
|||
public static DiagnosticsProperty<Color> createCupertinoColorProperty( |
|||
string name = null, |
|||
Color value = null, |
|||
bool showName = true, |
|||
object defaultValue = null, |
|||
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.singleLine, |
|||
DiagnosticLevel level = DiagnosticLevel.info |
|||
) { |
|||
|
|||
if (value is CupertinoDynamicColor) { |
|||
return new DiagnosticsProperty<Color>( |
|||
name: name, |
|||
value: value, |
|||
// description: value._debugLabel,
|
|||
showName: showName, |
|||
defaultValue: defaultValue, |
|||
style: style, |
|||
level: level |
|||
); |
|||
} |
|||
else { |
|||
|
|||
return new ColorProperty( |
|||
name, |
|||
value, |
|||
showName: showName, |
|||
defaultValue: defaultValue, |
|||
style: style, |
|||
level: level |
|||
); |
|||
} |
|||
} |
|||
} |
|||
} |
1001
com.unity.uiwidgets/Runtime/cupertino/context_menu.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 24797e4675ab3314ea1a636afd32bfee |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.scheduler2; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
|
|||
public class CupertinoContextMenuAction : StatefulWidget { |
|||
|
|||
public CupertinoContextMenuAction( |
|||
Key key = null, |
|||
Widget child = null, |
|||
bool isDefaultAction = false, |
|||
bool isDestructiveAction = false, |
|||
VoidCallback onPressed = null, |
|||
IconData trailingIcon = null |
|||
) : base(key: key) { |
|||
D.assert(child != null); |
|||
D.assert(isDefaultAction != null); |
|||
D.assert(isDestructiveAction != null); |
|||
this.child = child; |
|||
this.isDefaultAction = isDefaultAction; |
|||
this.isDestructiveAction = isDestructiveAction; |
|||
this.onPressed = onPressed; |
|||
this.trailingIcon = trailingIcon; |
|||
|
|||
} |
|||
public readonly Widget child; |
|||
public readonly bool isDefaultAction; |
|||
public readonly bool isDestructiveAction; |
|||
public readonly VoidCallback onPressed; |
|||
public readonly IconData trailingIcon; |
|||
|
|||
public override State createState() { |
|||
return new _CupertinoContextMenuActionState(); |
|||
} |
|||
} |
|||
public class _CupertinoContextMenuActionState : State<CupertinoContextMenuAction> { |
|||
public static Color _kBackgroundColor = new Color(0xFFEEEEEE); |
|||
public static Color _kBackgroundColorPressed = new Color(0xFFDDDDDD); |
|||
public static float _kButtonHeight = 56.0f; |
|||
|
|||
public static readonly TextStyle _kActionSheetActionStyle = new TextStyle( |
|||
fontFamily: ".SF UI Text", |
|||
inherit: false, |
|||
fontSize: 20.0f, |
|||
fontWeight: FontWeight.w400, |
|||
color: CupertinoColors.black, |
|||
textBaseline: TextBaseline.alphabetic |
|||
); |
|||
public GlobalKey _globalKey = new LabeledGlobalKey<State<StatefulWidget>>(); |
|||
//GlobalKey();
|
|||
bool _isPressed = false; |
|||
|
|||
void onTapDown(TapDownDetails details) { |
|||
setState(()=>{ |
|||
_isPressed = true; |
|||
}); |
|||
} |
|||
|
|||
void onTapUp(TapUpDetails details) { |
|||
setState(()=>{ |
|||
_isPressed = false; |
|||
}); |
|||
} |
|||
|
|||
void onTapCancel() { |
|||
setState(()=>{ |
|||
_isPressed = false; |
|||
}); |
|||
} |
|||
|
|||
TextStyle _textStyle { |
|||
get { |
|||
if (widget.isDefaultAction) { |
|||
return _kActionSheetActionStyle.copyWith( |
|||
fontWeight: FontWeight.w600 |
|||
); |
|||
} |
|||
if (widget.isDestructiveAction) { |
|||
return _kActionSheetActionStyle.copyWith( |
|||
color: CupertinoColors.destructiveRed |
|||
); |
|||
} |
|||
return _kActionSheetActionStyle; |
|||
} |
|||
|
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
List<Widget> widgets = new List<Widget>(); |
|||
widgets.Add(new Flexible(child: widget.child)); |
|||
if (widget.trailingIcon != null) { |
|||
widgets.Add(new Icon( |
|||
widget.trailingIcon, |
|||
color: _textStyle.color)); |
|||
} |
|||
|
|||
return new GestureDetector( |
|||
key: _globalKey, |
|||
onTapDown: onTapDown, |
|||
onTapUp: onTapUp, |
|||
onTapCancel: onTapCancel, |
|||
onTap: //widget.onPressed,
|
|||
widget.onPressed == null |
|||
? (GestureTapCallback) null |
|||
: () => { |
|||
if (widget.onPressed != null) { |
|||
widget.onPressed(); |
|||
} |
|||
}, |
|||
behavior: HitTestBehavior.opaque, |
|||
child: /////semantics tbc ???
|
|||
new ConstrainedBox( |
|||
constraints: new BoxConstraints( |
|||
minHeight: _kButtonHeight |
|||
), |
|||
child: |
|||
new Container( |
|||
padding: EdgeInsets.symmetric( |
|||
vertical: 16.0f, |
|||
horizontal: 10.0f |
|||
), |
|||
decoration: new BoxDecoration( |
|||
color: _isPressed ? _kBackgroundColorPressed : _kBackgroundColor, |
|||
border: new Border( |
|||
bottom: new BorderSide(width: 1.0f, color: _kBackgroundColorPressed) |
|||
) |
|||
), |
|||
child: new DefaultTextStyle( |
|||
style: _textStyle, |
|||
child: new Row( |
|||
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|||
children:widgets |
|||
) |
|||
) |
|||
|
|||
) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: d5246034a96caf946b0142d694f1acac |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Runtime.CompilerServices; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.service; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using Brightness = Unity.UIWidgets.ui.Brightness; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
class CupertinoIconThemeData : IconThemeData { |
|||
|
|||
public CupertinoIconThemeData( |
|||
Color color = null, |
|||
float? opacity = null, |
|||
float? size = null |
|||
) : base(color: color, opacity: opacity, size: size) { |
|||
|
|||
} |
|||
|
|||
public new IconThemeData resolve(BuildContext context) { |
|||
Color resolvedColor = CupertinoDynamicColor.resolve(color, context); |
|||
return resolvedColor == color ? this : copyWith(color: resolvedColor); |
|||
} |
|||
public new CupertinoIconThemeData copyWith(Color color = null , float? opacity = null, float? size = null) |
|||
{ |
|||
return new CupertinoIconThemeData( |
|||
color: color ?? this.color, |
|||
opacity: opacity ?? this.opacity, |
|||
size: size ?? this.size |
|||
); |
|||
} |
|||
|
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
properties.add(CupertinoDynamicColor.createCupertinoColorProperty("color", color, defaultValue: null)); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 696a8c3b3fd073847bc390f64a2b112f |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.widgets; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
public enum CupertinoUserInterfaceLevelData { |
|||
baselayer, |
|||
elevatedlayer, |
|||
|
|||
} |
|||
public class CupertinoUserInterfaceLevel : InheritedWidget { |
|||
|
|||
public CupertinoUserInterfaceLevel( |
|||
Key key = null, |
|||
CupertinoUserInterfaceLevelData data = default, |
|||
Widget child = null |
|||
) : base(key: key, child: child) |
|||
{ |
|||
D.assert(data != null); |
|||
_data = data; |
|||
} |
|||
public CupertinoUserInterfaceLevelData _data; |
|||
|
|||
public static CupertinoUserInterfaceLevelData? of(BuildContext context, bool nullOk = false ) { |
|||
D.assert(context != null); |
|||
D.assert(nullOk != null); |
|||
CupertinoUserInterfaceLevel query = context.dependOnInheritedWidgetOfExactType<CupertinoUserInterfaceLevel>(null); |
|||
if (query != null) |
|||
return query._data; |
|||
//if (nullOk)
|
|||
// return ;
|
|||
throw new UIWidgetsError( |
|||
"CupertinoUserInterfaceLevel.of() called with a context that does not contain a CupertinoUserInterfaceLevel.\n" + |
|||
"No CupertinoUserInterfaceLevel ancestor could be found starting from the context that was passed "+ |
|||
"to CupertinoUserInterfaceLevel.of(). This can happen because you do not have a WidgetsApp or "+ |
|||
"MaterialApp widget (those widgets introduce a CupertinoUserInterfaceLevel), or it can happen "+ |
|||
"if the context you use comes from a widget above those widgets.\n"+ |
|||
"The context used was:\n"+ |
|||
context.ToString() |
|||
); |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
properties.add(new EnumProperty<CupertinoUserInterfaceLevelData>("user interface level", _data)); |
|||
} |
|||
|
|||
public override bool updateShouldNotify(InheritedWidget oldWidget) { |
|||
//throw new System.NotImplementedException();
|
|||
//oldWidget._data != _data;
|
|||
/// ?????
|
|||
if (oldWidget.GetType() == typeof(CupertinoUserInterfaceLevel)) { |
|||
return updateShouldNotify(oldWidget); |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
public bool updateShouldNotify(CupertinoUserInterfaceLevel oldWidget) => oldWidget._data != _data; |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 28fded021801d9047ab539e8b57eda6e |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
class BottomAppBarUtils { |
|||
public const float _kTabBarHeight = 50.0f; |
|||
public static readonly Color _kDefaultTabBarBorderColor = new Color(0x4C000000); |
|||
} |
|||
|
|||
|
|||
public class CupertinoTabBar : StatelessWidget { |
|||
public CupertinoTabBar( |
|||
Key key = null, |
|||
List<BottomNavigationBarItem> items = null, |
|||
ValueChanged<int> onTap = null, |
|||
int currentIndex = 0, |
|||
Color backgroundColor = null, |
|||
Color activeColor = null, |
|||
Color inactiveColor = null, |
|||
float iconSize = 30.0f, |
|||
Border border = null |
|||
) : base(key: key) { |
|||
D.assert(items != null); |
|||
D.assert(items.Count >= 2, |
|||
() => "Tabs need at least 2 items to conform to Apple's HIG" |
|||
); |
|||
D.assert(0 <= currentIndex && currentIndex < items.Count); |
|||
|
|||
|
|||
this.items = items; |
|||
this.onTap = onTap; |
|||
this.currentIndex = currentIndex; |
|||
|
|||
this.backgroundColor = backgroundColor; |
|||
this.activeColor = activeColor; |
|||
this.inactiveColor = inactiveColor ?? CupertinoColors.inactiveGray; |
|||
this.iconSize = iconSize; |
|||
this.border = border ?? new Border( |
|||
top: new BorderSide( |
|||
color: BottomAppBarUtils._kDefaultTabBarBorderColor, |
|||
width: 0.0f, // One physical pixel.
|
|||
style: BorderStyle.solid |
|||
) |
|||
); |
|||
} |
|||
|
|||
public readonly List<BottomNavigationBarItem> items; |
|||
|
|||
public readonly ValueChanged<int> onTap; |
|||
|
|||
public readonly int currentIndex; |
|||
|
|||
public readonly Color backgroundColor; |
|||
|
|||
public readonly Color activeColor; |
|||
|
|||
public readonly Color inactiveColor; |
|||
|
|||
public readonly float iconSize; |
|||
|
|||
public readonly Border border; |
|||
|
|||
public Size preferredSize { |
|||
get { return Size.fromHeight(BottomAppBarUtils._kTabBarHeight); } |
|||
} |
|||
|
|||
public bool opaque(BuildContext context) { |
|||
Color backgroundColor = |
|||
this.backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor; |
|||
return backgroundColor.alpha == 0xFF; |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
float bottomPadding = MediaQuery.of(context).padding.bottom; |
|||
|
|||
Widget result = new DecoratedBox( |
|||
decoration: new BoxDecoration( |
|||
border: border, |
|||
color: backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor |
|||
), |
|||
child: new SizedBox( |
|||
height: BottomAppBarUtils._kTabBarHeight + bottomPadding, |
|||
child: IconTheme.merge( // Default with the inactive state.
|
|||
data: new IconThemeData( |
|||
color: inactiveColor, |
|||
size: iconSize |
|||
), |
|||
child: new DefaultTextStyle( // Default with the inactive state.
|
|||
style: CupertinoTheme.of(context).textTheme.tabLabelTextStyle |
|||
.copyWith(color: inactiveColor), |
|||
child: new Padding( |
|||
padding: EdgeInsets.only(bottom: bottomPadding), |
|||
child: new Row( |
|||
crossAxisAlignment: CrossAxisAlignment.end, |
|||
children: _buildTabItems(context) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
); |
|||
|
|||
if (!opaque(context)) { |
|||
result = new ClipRect( |
|||
child: new BackdropFilter( |
|||
filter: ImageFilter.blur(sigmaX: 10.0f, sigmaY: 10.0f), |
|||
child: result |
|||
) |
|||
); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
List<Widget> _buildTabItems(BuildContext context) { |
|||
List<Widget> result = new List<Widget> { }; |
|||
|
|||
for (int index = 0; index < items.Count; index += 1) { |
|||
bool active = index == currentIndex; |
|||
var tabIndex = index; |
|||
result.Add( |
|||
_wrapActiveItem( |
|||
context, |
|||
new Expanded( |
|||
child: new GestureDetector( |
|||
behavior: HitTestBehavior.opaque, |
|||
onTap: onTap == null ? null : (GestureTapCallback) (() => { onTap(tabIndex); }), |
|||
child: new Padding( |
|||
padding: EdgeInsets.only(bottom: 4.0f), |
|||
child: new Column( |
|||
mainAxisAlignment: MainAxisAlignment.end, |
|||
children: _buildSingleTabItem(items[index], active) |
|||
) |
|||
) |
|||
) |
|||
), |
|||
active: active |
|||
) |
|||
); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
List<Widget> _buildSingleTabItem(BottomNavigationBarItem item, bool active) { |
|||
List<Widget> components = new List<Widget> { |
|||
new Expanded( |
|||
child: new Center(child: active ? item.activeIcon : item.icon) |
|||
) |
|||
}; |
|||
|
|||
if (item.title != null) { |
|||
components.Add(item.title); |
|||
} |
|||
|
|||
return components; |
|||
} |
|||
|
|||
Widget _wrapActiveItem(BuildContext context, Widget item, bool active) { |
|||
if (!active) { |
|||
return item; |
|||
} |
|||
|
|||
Color activeColor = this.activeColor ?? CupertinoTheme.of(context).primaryColor; |
|||
return IconTheme.merge( |
|||
data: new IconThemeData(color: activeColor), |
|||
child: DefaultTextStyle.merge( |
|||
style: new TextStyle(color: activeColor), |
|||
child: item |
|||
) |
|||
); |
|||
} |
|||
|
|||
public CupertinoTabBar copyWith( |
|||
Key key = null, |
|||
List<BottomNavigationBarItem> items = null, |
|||
Color backgroundColor = null, |
|||
Color activeColor = null, |
|||
Color inactiveColor = null, |
|||
float? iconSize = null, |
|||
Border border = null, |
|||
int? currentIndex = null, |
|||
ValueChanged<int> onTap = null |
|||
) { |
|||
return new CupertinoTabBar( |
|||
key: key ?? this.key, |
|||
items: items ?? this.items, |
|||
backgroundColor: backgroundColor ?? this.backgroundColor, |
|||
activeColor: activeColor ?? this.activeColor, |
|||
inactiveColor: inactiveColor ?? this.inactiveColor, |
|||
iconSize: iconSize ?? this.iconSize, |
|||
border: border ?? this.border, |
|||
currentIndex: currentIndex ?? this.currentIndex, |
|||
onTap: onTap ?? this.onTap |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
public class CupertinoColors { |
|||
public static readonly Color activeBlue = new Color(0xFF007AFF); |
|||
|
|||
public static readonly Color activeGreen = new Color(0xFF4CD964); |
|||
|
|||
public static readonly Color activeOrange = new Color(0xFFFF9500); |
|||
|
|||
public static readonly Color white = new Color(0xFFFFFFFF); |
|||
|
|||
public static readonly Color black = new Color(0xFF000000); |
|||
|
|||
public static readonly Color lightBackgroundGray = new Color(0xFFE5E5EA); |
|||
|
|||
public static readonly Color extraLightBackgroundGray = new Color(0xFFEFEFF4); |
|||
|
|||
public static readonly Color darkBackgroundGray = new Color(0xFF171717); |
|||
|
|||
public static readonly Color inactiveGray = new Color(0xFF8E8E93); |
|||
|
|||
public static readonly Color destructiveRed = new Color(0xFFFF3B30); |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue