Aidra Driver 1.3.5+68
Aidra Driver - Your path to green energy
Loading...
Searching...
No Matches
tab_selector.dart
Go to the documentation of this file.
1import 'package:flutter/material.dart';
2import 'package:flutter_screenutil/flutter_screenutil.dart';
3
4import '../theme/color_palette.dart';
5
6class TabSelector extends StatefulWidget {
7 final Function(bool) onTabSelected;
8 final bool initialSelection;
11
13 super.key,
14 required this.onTabSelected,
15 required this.firstTabName,
16 required this.secondTabName,
17 this.initialSelection = true,
18 });
19
20 @override
21 State<TabSelector> createState() => _TabSelectorState();
22}
23
24class _TabSelectorState extends State<TabSelector> {
26
27 @override
28 void initState() {
29 super.initState();
30 isFirstTabSelected = widget.initialSelection;
31 }
32
33 void _toggleTab(bool value) {
34 setState(() {
35 isFirstTabSelected = value;
36 });
37 widget.onTabSelected(value);
38 }
39
40 @override
41 Widget build(BuildContext context) {
42 return Container(
43 decoration: BoxDecoration(
45 boxShadow: [
46 BoxShadow(
47 color: ColorPalette.black.withValues(alpha:0.04),
48 blurRadius: 15,
49 offset: const Offset(0, 5),
50 ),
51 ],
52 ),
53 child: Padding(
54 padding: EdgeInsets.all(2.sp),
55 child: Row(
56 children: [
57 Expanded(
58 child: InkWell(
59 onTap: () => _toggleTab(true),
60 child: Container(
61 padding: EdgeInsets.symmetric(vertical: 16.sp),
62 decoration: BoxDecoration(
63 color: !isFirstTabSelected ? ColorPalette.grey.withValues(alpha:0.1) : ColorPalette.white,
64 border: Border(
65 bottom: BorderSide(
67 width: 2.sp,
68 ),
69 ),
70 ),
71 child: Text(
72 widget.firstTabName,
73 textAlign: TextAlign.center,
74 style: Theme.of(context).textTheme.titleSmall!.copyWith(
76 fontWeight: FontWeight.w600,
77 ),
78 ),
79 ),
80 ),
81 ),
82 Expanded(
83 child: InkWell(
84 onTap: () => _toggleTab(false),
85 child: Container(
86 padding: EdgeInsets.symmetric(vertical: 16.sp),
87 decoration: BoxDecoration(
89 border: Border(
90 bottom: BorderSide(
92 width: 2.sp,
93 ),
94 ),
95 ),
96 child: Text(
97 widget.secondTabName,
98 textAlign: TextAlign.center,
99 style: Theme.of(context).textTheme.titleSmall!.copyWith(
101 fontWeight: FontWeight.w600,
102 ),
103 ),
104 ),
105 ),
106 ),
107 ],
108 ),
109 ),
110 );
111 }
112}
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
final String secondTabName
final bool initialSelection
final Function(bool) onTabSelected
override State< TabSelector > createState()
final String firstTabName
const TabSelector({ super.key, required this.onTabSelected, required this.firstTabName, required this.secondTabName, this.initialSelection=true, })
final Widget child
final EdgeInsets padding
class Partner String
final Color color
Definition failures.dart:1
final VoidCallback onTap
void _toggleTab(bool value)
class TabSelector extends StatefulWidget isFirstTabSelected
style Text( '${ 'scheduling.reference'.tr()}:${collection.internalCode}', style:Theme.of(context).textTheme.bodySmall,)