Loading...
Searching...
No Matches
zoom_controls.dart
Go to the documentation of this file.
1import 'package:flutter/material.dart';
2import 'widget_styles.dart';
3import 'zoom_controls_config.dart';
4
18class ZoomControls extends StatefulWidget {
20 final void Function() zoomInPressed;
22 final void Function() zoomOutPressed;
24 final ZoomControlsConfig config;
25
27 Key? key,
28 required this.zoomInPressed,
29 required this.zoomOutPressed,
31 }) : super(key: key);
32
33 @override
34 State<ZoomControls> createState() => _ZoomControlsState();
35}
36
37class _ZoomControlsState extends State<ZoomControls> {
38 @override
39 void initState() {
40 super.initState();
41 }
42
43 void _zoomIn() {
44 widget.zoomInPressed();
45 }
46
47 void _zoomOut() {
48 widget.zoomOutPressed();
49 }
50
51 @override
52 Widget build(BuildContext context) {
53 final config = widget.config;
54 final width = config.buttonWidth ?? kStandardButtonWidth;
55 final height = config.zoomControlsHeight ?? kZoomControlsHeight;
56 final bgColor = config.buttonBackgroundColor ?? kButtonBackgroundColorOpaque;
57 final textColor = config.textColor ?? kBaseBlackColor;
58 final padding = config.padding ?? EdgeInsets.only(right: kStandardRightPadding + MediaQuery.of(context).padding.right);
59
60 return Align(
61 alignment: Alignment.centerRight,
62 child: Padding(
63 padding: padding,
64 child: Container(
65 width: width,
66 height: height,
67 decoration: BoxDecoration(
68 borderRadius: kStandardBorderRadius,
69 boxShadow: kStandardShadows,
70 ),
71 child: Column(
72 children: [
73 Expanded(
74 child: Material(
75 color: bgColor,
76 borderRadius: kTopBorderRadius,
77 child: InkWell(
78 borderRadius: kTopBorderRadius,
79 onTap: _zoomIn,
80 child: Center(
81 child: config.zoomInIcon ?? Text(
82 '+',
83 style: TextStyle(fontSize: kButtonFontSize, color: textColor),
84 ),
85 ),
86 ),
87 ),
88 ),
89 Expanded(
90 child: Material(
91 color: bgColor,
92 borderRadius: kBottomBorderRadius,
93 child: InkWell(
94 borderRadius: kBottomBorderRadius,
95 onTap: _zoomOut,
96 child: Center(
97 child: config.zoomOutIcon ?? Text(
98 '−',
99 style: TextStyle(fontSize: kButtonFontSize, color: textColor),
100 ),
101 ),
102 ),
103 ),
104 ),
105 ],
106 ),
107 ),
108 ),
109 );
110 }
111}