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