You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
176 lines
5.5 KiB
176 lines
5.5 KiB
import 'package:flutter/material.dart';
|
|
import 'package:supplier_new/resources/resources_fleet.dart';
|
|
import 'package:supplier_new/resources/resources_drivers.dart';
|
|
import 'package:supplier_new/resources/resources_sources.dart';
|
|
import 'package:supplier_new/resources/source_location.dart';
|
|
import '../common/settings.dart';
|
|
import 'employees.dart';
|
|
import 'fleet.dart';
|
|
|
|
void main() => runApp(const MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
home: ResourcesMainScreen(),
|
|
));
|
|
|
|
class ResourcesMainScreen extends StatefulWidget {
|
|
const ResourcesMainScreen({super.key});
|
|
|
|
@override
|
|
State<ResourcesMainScreen> createState() => _ResourcesMainScreenState();
|
|
}
|
|
|
|
class _ResourcesMainScreenState extends State<ResourcesMainScreen>
|
|
with SingleTickerProviderStateMixin {
|
|
late TabController _tabController;
|
|
final List<String> _labels = const ['Fleet', 'Drivers', 'Sources'];
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_tabController = TabController(length: _labels.length, vsync: this);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_tabController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
// FAB per tab
|
|
Widget? _buildFAB(int index) {
|
|
switch (index) {
|
|
case 0: // Fleet
|
|
return FloatingActionButton(
|
|
heroTag: null,
|
|
backgroundColor: Colors.black,
|
|
child: const Icon(Icons.add, color: Colors.white),
|
|
onPressed: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (_) => const HeroMode(
|
|
enabled: false,
|
|
child: FleetStep1Page(),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
|
|
case 1: // Drivers
|
|
return FloatingActionButton(
|
|
heroTag: null,
|
|
backgroundColor: Colors.black,
|
|
child: const Icon(Icons.add, color: Colors.white),
|
|
onPressed: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (_) => const HeroMode(
|
|
enabled: false,
|
|
child: FleetEmployees(),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
|
|
case 2: // Sources
|
|
return FloatingActionButton(
|
|
heroTag: null,
|
|
backgroundColor: Colors.black,
|
|
child: const Icon(Icons.add, color: Colors.white),
|
|
onPressed: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (_) => const HeroMode(
|
|
enabled: false,
|
|
child: SourceLocation(),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
// keep entire screen white
|
|
backgroundColor: Colors.white,
|
|
body: SafeArea(
|
|
child: Column(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
|
child: AnimatedBuilder(
|
|
animation: _tabController,
|
|
builder: (context, _) {
|
|
return Row(
|
|
children: List.generate(_labels.length, (index) {
|
|
final isSelected = _tabController.index == index;
|
|
return Expanded(
|
|
child: GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () =>
|
|
setState(() => _tabController.index = index),
|
|
child: AnimatedContainer(
|
|
duration: const Duration(milliseconds: 180),
|
|
curve: Curves.easeInOut,
|
|
margin: const EdgeInsets.symmetric(horizontal: 6),
|
|
padding: const EdgeInsets.symmetric(vertical: 10),
|
|
decoration: BoxDecoration(
|
|
color: isSelected
|
|
? const Color(0xFFF1F1F1)
|
|
: Colors.white,
|
|
borderRadius:
|
|
BorderRadius.circular(16), // radius 16 always
|
|
),
|
|
alignment: Alignment.center,
|
|
child: Text(
|
|
_labels[index],
|
|
style: fontTextStyle(
|
|
12,
|
|
isSelected ? const Color(0xFF101214) : const Color(0xFF646464),
|
|
isSelected ? FontWeight.w700 : FontWeight.w400,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Expanded(
|
|
child: HeroMode(
|
|
enabled: false,
|
|
child: TabBarView(
|
|
controller: _tabController,
|
|
children: const [
|
|
ResourcesFleetScreen(),
|
|
ResourcesDriverScreen(),
|
|
ResourcesSourceScreen(),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
floatingActionButton: AnimatedBuilder(
|
|
animation: _tabController.animation!,
|
|
builder: (context, _) =>
|
|
_buildFAB(_tabController.index) ?? const SizedBox.shrink(),
|
|
),
|
|
);
|
|
}
|
|
}
|