import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:rasadyar_app/presentation/common/app_color.dart'; import 'package:rasadyar_app/presentation/common/app_fonts.dart'; import 'new_tab.dart'; class CupertinoSegmentedControlDemo extends StatefulWidget { const CupertinoSegmentedControlDemo({super.key}); @override State createState() => _CupertinoSegmentedControlDemoState(); } class _CupertinoSegmentedControlDemoState extends State { int _selectedSegment = 0; // The data for the segments final Map _segments = const { 0: Text('Segment 1'), 1: Text('Segment 2'), 2: Text('Segment 3'), }; @override Widget build(BuildContext context) { return SafeArea( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ CupertinoSlidingSegmentedControl( children: _segments, groupValue: _selectedSegment, onValueChanged: (int? value) { setState(() { _selectedSegment = value!; }); }, ), const SizedBox(height: 20), Text( 'Selected Segment: ${_selectedSegment + 1}', style: const TextStyle(fontSize: 24), ), ], ), ); } } class CupertinoSegmentedControlDemo2 extends StatefulWidget { const CupertinoSegmentedControlDemo2({super.key}); @override State createState() => _CupertinoSegmentedControlDemoState2(); } class _CupertinoSegmentedControlDemoState2 extends State { int _selectedSegment = 0; // The data for the segments final Map _segments = { 0:Container( padding: EdgeInsets.all(10), decoration: BoxDecoration( borderRadius: BorderRadius.circular(50) ), child: Text('لاشه', style: AppFonts.yekan13Regular), ), 1: Container( padding: EdgeInsets.all(10), decoration: BoxDecoration( borderRadius: BorderRadius.circular(50) ), child: Text('زنده', style: AppFonts.yekan13Regular), ), }; @override Widget build(BuildContext context) { return SafeArea( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ NewCupertinoSegmentedControl( padding: EdgeInsetsDirectional.symmetric( horizontal: 20, vertical: 10, ), children: _segments, groupValue: _selectedSegment, selectedColor: AppColor.blueNormal, unselectedColor: Colors.white, borderColor: Colors.grey.shade300, onValueChanged: (int value) { setState(() { _selectedSegment = value; }); }, ), const SizedBox(height: 20), Text( 'Selected Segment: ${_selectedSegment + 1}', style: const TextStyle(fontSize: 24), ), ], ), ); } }