@@ -2,7 +2,6 @@ import 'package:example/main_area/ns_window_delegate_demo/ns_window_delegate_dem
22import 'package:example/main_area/window_manipulator_demo/window_manipulator_demo.dart' ;
33import 'package:flutter/cupertino.dart' ;
44import 'package:flutter/material.dart' ;
5- import 'package:macos_ui/macos_ui.dart' ;
65
76class MainArea extends StatefulWidget {
87 const MainArea ({super .key, required this .setState});
@@ -14,26 +13,22 @@ class MainArea extends StatefulWidget {
1413}
1514
1615class _MainAreaState extends State <MainArea > {
17- final _tabController = MacosTabController (length: 2 , initialIndex: 0 );
18-
19- @override
20- void initState () {
21- _tabController.addListener (() => setState (() {}));
22-
23- super .initState ();
24- }
16+ int ? currentTabIndex = 0 ;
2517
2618 @override
2719 Widget build (BuildContext context) {
2820 return Column (
2921 children: [
3022 const SizedBox (height: 8.0 ),
3123 _SegmentedControl (
32- tabController: _tabController,
24+ currentTabIndex: currentTabIndex,
25+ onTabIndexChanged: (newIndex) => setState (() {
26+ currentTabIndex = newIndex;
27+ }),
3328 ),
3429 Expanded (
3530 child: IndexedStack (
36- index: _tabController.index ,
31+ index: currentTabIndex ,
3732 children: [
3833 WindowManipulatorDemo (
3934 setState: widget.setState,
@@ -49,23 +44,32 @@ class _MainAreaState extends State<MainArea> {
4944
5045class _SegmentedControl extends StatelessWidget {
5146 const _SegmentedControl ({
52- required this .tabController,
47+ required this .currentTabIndex,
48+ required this .onTabIndexChanged,
5349 });
5450
55- final MacosTabController tabController;
51+ final int ? currentTabIndex;
52+ final void Function (int ? ) onTabIndexChanged;
5653
5754 @override
5855 Widget build (BuildContext context) {
59- return MacosSegmentedControl (
60- tabs: const [
61- MacosTab (
62- label: 'WindowManipulator demo' ,
56+ return CupertinoSlidingSegmentedControl (
57+ groupValue: currentTabIndex,
58+ onValueChanged: onTabIndexChanged,
59+ children: const {
60+ 0 : Padding (
61+ padding: EdgeInsets .symmetric (horizontal: 20 ),
62+ child: Text (
63+ 'WindowManipulator demo' ,
64+ ),
6365 ),
64- MacosTab (
65- label: 'NSWindowDelegate demo' ,
66+ 1 : Padding (
67+ padding: EdgeInsets .symmetric (horizontal: 20 ),
68+ child: Text (
69+ 'NSWindowDelegate demo' ,
70+ ),
6671 ),
67- ],
68- controller: tabController,
72+ },
6973 );
7074 }
7175}
0 commit comments