Line data Source code
1 : import 'package:flutter/material.dart';
2 : import 'package:widgetbook/src/providers/device_provider.dart';
3 : import 'package:widgetbook/src/widgets/device_item.dart';
4 : import '../utils/extensions.dart';
5 :
6 : class DeviceBar extends StatelessWidget {
7 10 : const DeviceBar({Key? key}) : super(key: key);
8 :
9 0 : @override
10 : Widget build(BuildContext context) {
11 0 : var deviceProvider = DeviceProvider.of(context)!;
12 0 : var state = deviceProvider.state;
13 0 : return Row(
14 0 : children: [
15 : const Text('Device'),
16 : const SizedBox(
17 : width: 12,
18 : ),
19 0 : TextButton(
20 0 : onPressed: deviceProvider.previousDevice,
21 0 : style: TextButton.styleFrom(
22 : splashFactory: InkRipple.splashFactory,
23 : shape:
24 0 : RoundedRectangleBorder(borderRadius: BorderRadius.circular(90)),
25 : minimumSize: Size.zero,
26 : padding: const EdgeInsets.all(12),
27 : ),
28 0 : child: Icon(
29 : Icons.chevron_left,
30 0 : color: context.theme.hintColor,
31 : ),
32 : ),
33 0 : ListView.separated(
34 : shrinkWrap: true,
35 : scrollDirection: Axis.horizontal,
36 0 : itemBuilder: (context, index) {
37 0 : return DeviceItem(
38 0 : device: state.availableDevices[index],
39 : );
40 : },
41 0 : separatorBuilder: (context, index) {
42 : return const SizedBox(
43 : width: 8,
44 : );
45 : },
46 0 : itemCount: state.availableDevices.length,
47 : ),
48 0 : TextButton(
49 0 : onPressed: deviceProvider.nextDevice,
50 0 : style: TextButton.styleFrom(
51 : splashFactory: InkRipple.splashFactory,
52 : shape:
53 0 : RoundedRectangleBorder(borderRadius: BorderRadius.circular(90)),
54 : minimumSize: Size.zero,
55 : padding: const EdgeInsets.all(12),
56 : ),
57 0 : child: Icon(
58 : Icons.chevron_right,
59 0 : color: context.theme.hintColor,
60 : ),
61 : ),
62 : ],
63 : );
64 : }
65 : }
|