@@ -27,15 +27,17 @@ class FeedAdSettingsForm extends StatefulWidget {
2727 State <FeedAdSettingsForm > createState () => _FeedAdSettingsFormState ();
2828}
2929
30- class _FeedAdSettingsFormState extends State <FeedAdSettingsForm > {
31- AppUserRole _selectedUserRole = AppUserRole .guestUser;
30+ class _FeedAdSettingsFormState extends State <FeedAdSettingsForm >
31+ with SingleTickerProviderStateMixin {
32+ late TabController _tabController;
3233 late final Map <AppUserRole , TextEditingController > _adFrequencyControllers;
3334 late final Map <AppUserRole , TextEditingController >
3435 _adPlacementIntervalControllers;
3536
3637 @override
3738 void initState () {
3839 super .initState ();
40+ _tabController = TabController (length: AppUserRole .values.length, vsync: this );
3941 _initializeControllers ();
4042 }
4143
@@ -95,6 +97,7 @@ class _FeedAdSettingsFormState extends State<FeedAdSettingsForm> {
9597
9698 @override
9799 void dispose () {
100+ _tabController.dispose ();
98101 for (final controller in _adFrequencyControllers.values) {
99102 controller.dispose ();
100103 }
@@ -129,10 +132,12 @@ class _FeedAdSettingsFormState extends State<FeedAdSettingsForm> {
129132 const SizedBox (height: AppSpacing .lg),
130133 ExpansionTile (
131134 title: Text (l10n.feedAdTypeSelectionTitle),
132- childrenPadding: const EdgeInsets .symmetric (
133- horizontal: AppSpacing .xxl,
134- vertical: AppSpacing .md,
135+ childrenPadding: const EdgeInsetsDirectional .only (
136+ start: AppSpacing .lg, // Adjusted padding for hierarchy
137+ top: AppSpacing .md,
138+ bottom: AppSpacing .md,
135139 ),
140+ expandedCrossAxisAlignment: CrossAxisAlignment .start, // Align content to start
136141 children: [
137142 Text (
138143 l10n.feedAdTypeSelectionDescription,
@@ -142,6 +147,7 @@ class _FeedAdSettingsFormState extends State<FeedAdSettingsForm> {
142147 .onSurface
143148 .withOpacity (0.7 ),
144149 ),
150+ textAlign: TextAlign .start, // Ensure text aligns to start
145151 ),
146152 const SizedBox (height: AppSpacing .lg),
147153 Align (
@@ -179,10 +185,12 @@ class _FeedAdSettingsFormState extends State<FeedAdSettingsForm> {
179185 const SizedBox (height: AppSpacing .lg),
180186 ExpansionTile (
181187 title: Text (l10n.userRoleFrequencySettingsTitle),
182- childrenPadding: const EdgeInsets .symmetric (
183- horizontal: AppSpacing .xxl,
184- vertical: AppSpacing .md,
188+ childrenPadding: const EdgeInsetsDirectional .only (
189+ start: AppSpacing .lg, // Adjusted padding for hierarchy
190+ top: AppSpacing .md,
191+ bottom: AppSpacing .md,
185192 ),
193+ expandedCrossAxisAlignment: CrossAxisAlignment .start, // Align content to start
186194 children: [
187195 Text (
188196 l10n.userRoleFrequencySettingsDescription,
@@ -192,39 +200,42 @@ class _FeedAdSettingsFormState extends State<FeedAdSettingsForm> {
192200 .onSurface
193201 .withOpacity (0.7 ),
194202 ),
203+ textAlign: TextAlign .start, // Ensure text aligns to start
195204 ),
196205 const SizedBox (height: AppSpacing .lg),
206+ // Replaced SegmentedButton with TabBar for role selection
197207 Align (
198208 alignment: AlignmentDirectional .centerStart,
199- child: SegmentedButton <AppUserRole >(
200- style: SegmentedButton .styleFrom (
201- shape: const RoundedRectangleBorder (
202- borderRadius: BorderRadius .zero,
203- ),
209+ child: SizedBox (
210+ height: kTextTabBarHeight,
211+ child: TabBar (
212+ controller: _tabController,
213+ tabAlignment: TabAlignment .start,
214+ isScrollable: true ,
215+ tabs: AppUserRole .values
216+ .map ((role) => Tab (text: role.l10n (context)))
217+ .toList (),
204218 ),
205- segments: AppUserRole .values
219+ ),
220+ ),
221+ const SizedBox (height: AppSpacing .lg),
222+ // TabBarView to display role-specific fields
223+ SizedBox (
224+ height: 250 , // Fixed height for TabBarView within a ListView
225+ child: TabBarView (
226+ controller: _tabController,
227+ children: AppUserRole .values
206228 .map (
207- (role) => ButtonSegment <AppUserRole >(
208- value: role,
209- label: Text (role.l10n (context)),
229+ (role) => _buildRoleSpecificFields (
230+ context,
231+ l10n,
232+ role,
233+ feedAdConfig,
210234 ),
211235 )
212236 .toList (),
213- selected: {_selectedUserRole},
214- onSelectionChanged: (newSelection) {
215- setState (() {
216- _selectedUserRole = newSelection.first;
217- });
218- },
219237 ),
220238 ),
221- const SizedBox (height: AppSpacing .lg),
222- _buildRoleSpecificFields (
223- context,
224- l10n,
225- _selectedUserRole,
226- feedAdConfig,
227- ),
228239 ],
229240 ),
230241 ],
0 commit comments