Line data Source code
1 : import 'package:flutter/material.dart';
2 : import 'package:widgetbook/src/providers/zoom_provider.dart';
3 : import 'package:widgetbook/src/utils/extensions.dart';
4 :
5 : class ZoomHandle extends StatefulWidget {
6 15 : const ZoomHandle({Key? key}) : super(key: key);
7 :
8 0 : @override
9 0 : _ZoomHandleState createState() => _ZoomHandleState();
10 : }
11 :
12 : class _ZoomHandleState extends State<ZoomHandle> {
13 0 : @override
14 : Widget build(BuildContext context) {
15 0 : final state = ZoomProvider.of(context)!.state;
16 0 : return Row(
17 0 : children: [
18 0 : TextButton(
19 0 : onPressed: ZoomProvider.of(context)!.zoomOut,
20 0 : style: TextButton.styleFrom(
21 : splashFactory: InkRipple.splashFactory,
22 : shape:
23 0 : RoundedRectangleBorder(borderRadius: BorderRadius.circular(90)),
24 : minimumSize: Size.zero,
25 : padding: const EdgeInsets.all(12),
26 : ),
27 0 : child: Icon(
28 : Icons.remove,
29 0 : color: context.theme.hintColor,
30 : ),
31 : ),
32 : const SizedBox(width: 8),
33 0 : Row(
34 0 : children: [
35 0 : SizedBox(
36 : width: 50,
37 0 : child: Text(
38 0 : state.zoomLevel.toStringAsFixed(2),
39 0 : style: context.theme.textTheme.subtitle2!.copyWith(
40 : fontSize: 20,
41 : ),
42 : ),
43 : ),
44 : const SizedBox(
45 : width: 4,
46 : ),
47 : const Text('zoom'),
48 : ],
49 : ),
50 : const SizedBox(width: 8),
51 0 : TextButton(
52 0 : onPressed: ZoomProvider.of(context)!.zoomIn,
53 0 : style: TextButton.styleFrom(
54 : splashFactory: InkRipple.splashFactory,
55 : shape:
56 0 : RoundedRectangleBorder(borderRadius: BorderRadius.circular(90)),
57 : minimumSize: Size.zero,
58 : padding: const EdgeInsets.all(12),
59 : ),
60 0 : child: Icon(
61 : Icons.add,
62 0 : color: context.theme.hintColor,
63 : ),
64 : ),
65 : const SizedBox(width: 8),
66 0 : Tooltip(
67 : message: 'Reset zoom',
68 0 : child: TextButton(
69 0 : onPressed: ZoomProvider.of(context)!.resetToNormal,
70 0 : style: TextButton.styleFrom(
71 : splashFactory: InkRipple.splashFactory,
72 0 : shape: RoundedRectangleBorder(
73 0 : borderRadius: BorderRadius.circular(90)),
74 : minimumSize: Size.zero,
75 : padding: const EdgeInsets.all(12),
76 : ),
77 0 : child: Icon(
78 : Icons.replay,
79 0 : color: context.theme.hintColor,
80 : ),
81 : ),
82 : ),
83 : ],
84 : );
85 : }
86 : }
|