-
Notifications
You must be signed in to change notification settings - Fork 5
/
platform_tooltip.dart
181 lines (172 loc) · 5.21 KB
/
platform_tooltip.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import 'package:fluent_ui/fluent_ui.dart' as FluentUI;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:platform_ui/platform_ui.dart';
class PlatformTooltip extends StatelessWidget with PlatformMixin<Widget> {
final String? message;
final InlineSpan? richMessage;
final double? height;
final EdgeInsetsGeometry? padding;
final EdgeInsetsGeometry? margin;
final double? verticalOffset;
final bool? preferBelow;
final bool? excludeFromSemantics;
final Widget? child;
final Decoration? decoration;
final TextStyle? textStyle;
final TextAlign? textAlign;
final Duration? waitDuration;
final Duration? showDuration;
final TooltipTriggerMode? triggerMode;
final bool? enableFeedback;
final TooltipTriggeredCallback? onTriggered;
const PlatformTooltip({
Key? key,
this.message,
this.richMessage,
this.height,
this.padding,
this.margin,
this.verticalOffset,
this.preferBelow,
this.excludeFromSemantics,
this.decoration,
this.textStyle,
this.textAlign,
this.waitDuration,
this.showDuration,
this.triggerMode,
this.enableFeedback,
this.onTriggered,
this.child,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return getPlatformType(context);
}
@override
Widget android(BuildContext context) {
return Tooltip(
key: key,
message: message,
richMessage: richMessage,
height: height,
padding: padding,
margin: margin,
verticalOffset: verticalOffset,
preferBelow: preferBelow,
excludeFromSemantics: excludeFromSemantics,
decoration: decoration,
textStyle: textStyle,
textAlign: textAlign,
waitDuration: waitDuration,
showDuration: showDuration,
triggerMode: triggerMode,
enableFeedback: enableFeedback,
onTriggered: onTriggered,
child: child,
);
}
@override
Widget ios(BuildContext context) {
return Tooltip(
key: key,
message: message,
richMessage: richMessage,
height: height,
padding: padding ?? const EdgeInsets.all(12),
margin: margin,
verticalOffset: verticalOffset ?? 10,
preferBelow: preferBelow ?? false,
excludeFromSemantics: excludeFromSemantics,
decoration:
(decoration as BoxDecoration? ?? const BoxDecoration()).copyWith(
color: CupertinoTheme.of(context).brightness == Brightness.light
? Colors.grey[900]
: Colors.grey[800],
borderRadius: BorderRadius.circular(8),
),
textStyle: textStyle,
textAlign: textAlign,
waitDuration: waitDuration,
showDuration: showDuration,
triggerMode: triggerMode,
enableFeedback: enableFeedback,
onTriggered: onTriggered,
child: child,
);
}
@override
Widget linux(BuildContext context) {
return android(context);
}
@override
Widget macos(BuildContext context) {
return Tooltip(
key: key,
message: message,
richMessage: richMessage,
height: height,
padding: padding ?? const EdgeInsets.all(8),
margin: margin,
verticalOffset: verticalOffset ?? 10,
preferBelow: preferBelow ?? false,
excludeFromSemantics: excludeFromSemantics,
decoration:
(decoration as BoxDecoration? ?? const BoxDecoration()).copyWith(
color: CupertinoTheme.of(context).brightness == Brightness.light
? Colors.white
: Colors.grey[800],
borderRadius: BorderRadius.circular(5),
boxShadow: [
BoxShadow(
color: CupertinoTheme.of(context).brightness == Brightness.light
? Colors.grey[300]!
: Colors.grey[900]!,
blurRadius: 7,
offset: const Offset(0, 0),
)
],
),
textStyle: textStyle ??
TextStyle(
color: CupertinoTheme.of(context).brightness == Brightness.light
? Colors.black
: Colors.white,
),
textAlign: textAlign,
waitDuration: waitDuration,
showDuration: showDuration,
triggerMode: triggerMode,
enableFeedback: enableFeedback,
onTriggered: onTriggered,
child: child,
);
}
@override
Widget windows(BuildContext context) {
final fluentTheme = FluentUI.FluentTheme.of(context).tooltipTheme;
return FluentUI.TooltipTheme(
data: FluentUI.TooltipThemeData(
textStyle: textStyle ?? fluentTheme.textStyle,
decoration: decoration ?? fluentTheme.decoration,
height: height ?? fluentTheme.height,
margin: margin ?? fluentTheme.margin,
verticalOffset: verticalOffset ?? fluentTheme.verticalOffset,
preferBelow: preferBelow ?? fluentTheme.preferBelow,
waitDuration: waitDuration ?? fluentTheme.waitDuration,
showDuration: showDuration ?? fluentTheme.showDuration,
padding: padding ?? fluentTheme.padding,
),
child: FluentUI.Tooltip(
key: key,
message: message,
richMessage: richMessage,
excludeFromSemantics: excludeFromSemantics ?? false,
triggerMode: triggerMode,
enableFeedback: enableFeedback,
child: child,
),
);
}
}