-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplatform_icon_button.dart
74 lines (68 loc) · 1.7 KB
/
platform_icon_button.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
import 'package:devour/presentation/widgets/platform/abstract_platform_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class PlatformIconButton
extends AbstractPlatformWidget<CupertinoButton, IconButton> {
PlatformIconButton({
required this.icon,
required this.size,
required this.color,
required this.text,
required this.onPressed,
});
final IconData icon;
final double size;
final Color color;
final String text;
final VoidCallback? onPressed;
@override
CupertinoButton buildCupertino(BuildContext context) {
return CupertinoButton(
onPressed: onPressed,
child: _buildContent(context),
);
}
@override
IconButton buildMaterial(BuildContext context) {
return IconButton(
icon: _buildContent(context),
onPressed: onPressed,
);
}
Widget _buildContent(BuildContext context) {
final textStyle = CupertinoTheme.of(context)
.textTheme
.actionTextStyle
.copyWith(color: color);
const List<Shadow> shadows = [
Shadow(
color: Colors.black12,
offset: Offset(0, 1),
blurRadius: 1.0,
),
Shadow(
color: Colors.black26,
blurRadius: 20.0,
)
];
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
String.fromCharCode(icon.codePoint),
style: TextStyle(
fontSize: size,
color: color,
fontFamily: icon.fontFamily,
package: icon.fontPackage,
shadows: shadows,
),
),
Text(
text,
style: textStyle.copyWith(shadows: shadows),
),
],
);
}
}