Aidra Driver 1.3.5+68
Aidra Driver - Your path to green energy
Loading...
Searching...
No Matches
triple_tab_selector.dart
Go to the documentation of this file.
1import 'package:flutter/material.dart';
2import 'package:flutter_screenutil/flutter_screenutil.dart';
3
4import '../../../../../../core/ui/theme/color_palette.dart';
5
6class TripleTabSelector extends StatefulWidget {
7 final Function(int) onTabSelected;
8 final int initialSelection;
12
14 super.key,
15 required this.onTabSelected,
16 required this.firstTabName,
17 required this.secondTabName,
18 required this.thirdTabName,
19 this.initialSelection = 0,
20 });
21
22 @override
23 State<TripleTabSelector> createState() => _TripleTabSelectorState();
24}
25
26class _TripleTabSelectorState extends State<TripleTabSelector> {
28
29 @override
30 void initState() {
31 super.initState();
32 selectedTabIndex = widget.initialSelection;
33 }
34
35 void _selectTab(int index) {
36 setState(() {
37 selectedTabIndex = index;
38 });
39 widget.onTabSelected(index);
40 }
41
42 Widget _buildTab(BuildContext context, String tabName, int index) {
43 bool isSelected = selectedTabIndex == index;
44 bool hasGreyBackground = selectedTabIndex != index;
45
46 return Expanded(
47 child: InkWell(
48 onTap: () => _selectTab(index),
49 child: Container(
50 padding: EdgeInsets.symmetric(vertical: 16.sp),
51 decoration: BoxDecoration(
52 color: hasGreyBackground ? ColorPalette.grey.withValues(alpha:0.1) : ColorPalette.white,
53 border: Border(
54 bottom: BorderSide(
56 width: 2.sp,
57 ),
58 ),
59 ),
60 child: Text(
61 tabName,
62 textAlign: TextAlign.center,
63 style: Theme.of(context).textTheme.titleSmall!.copyWith(
65 fontWeight: FontWeight.w600,
66 ),
67 ),
68 ),
69 ),
70 );
71 }
72
73 @override
74 Widget build(BuildContext context) {
75 return Container(
76 margin: EdgeInsets.only(bottom: 5.sp),
77 decoration: BoxDecoration(
79 boxShadow: [
80 BoxShadow(
81 color: ColorPalette.black.withValues(alpha:0.04),
82 blurRadius: 15,
83 offset: const Offset(0, 5),
84 ),
85 ],
86 ),
87 child: Padding(
88 padding: EdgeInsets.all(2.sp),
89 child: Row(
90 children: [
91 _buildTab(context, widget.firstTabName, 0),
92 _buildTab(context, widget.secondTabName, 1),
93 _buildTab(context, widget.thirdTabName, 2),
94 ],
95 ),
96 ),
97 );
98 }
99}
override void initState()
class App extends StatefulWidget build(BuildContext context)
Definition app.dart:31
static const lightGreen
static const black
static const white
static const grey
override State< TripleTabSelector > createState()
final String secondTabName
const TripleTabSelector({ super.key, required this.onTabSelected, required this.firstTabName, required this.secondTabName, required this.thirdTabName, this.initialSelection=0, })
final bool initialSelection
final String firstTabName
final Function(int) onTabSelected
final Widget child
final EdgeInsets padding
class Partner String
final Color color
Definition failures.dart:1
final VoidCallback onTap
Widget _buildTab(String text, bool isSelected)
void _selectTab(int index)
class TripleTabSelector extends StatefulWidget selectedTabIndex
class UnloadingCollectionItem extends StatefulWidget isSelected
style Text( '${ 'scheduling.reference'.tr()}:${collection.internalCode}', style:Theme.of(context).textTheme.bodySmall,)