refactor: replace TabView with DropdownButton

This commit is contained in:
Udhay-Adithya
2025-06-05 21:10:06 +05:30
parent f158d5de12
commit ad59d56975
2 changed files with 60 additions and 61 deletions

View File

@ -40,7 +40,7 @@ class _ScriptsCodePaneState extends ConsumerState<ScriptsCodePane> {
); );
}); });
final tabs = ["Pre-Req", "Post-Res"]; final tabs = ["Pre Request", "Post Response"];
final content = [ final content = [
ScriptsEditorPane( ScriptsEditorPane(
controller: preReqCodeController, controller: preReqCodeController,
@ -50,53 +50,46 @@ class _ScriptsCodePaneState extends ConsumerState<ScriptsCodePane> {
), ),
]; ];
return Row( return Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SizedBox( Padding(
width: 100, padding: const EdgeInsets.all(8.0),
child: Column( child: DropdownButton<int>(
mainAxisAlignment: MainAxisAlignment.start, focusColor: Theme.of(context).colorScheme.surface,
crossAxisAlignment: CrossAxisAlignment.start, icon: Icon(
children: [ Icons.arrow_drop_down_rounded,
for (int i = 0; i < tabs.length; i++) size: 22,
ListTile(
dense: true,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(2),
), ),
selectedTileColor: _selectedTabIndex == i borderRadius: BorderRadius.circular(9),
? Theme.of(context).colorScheme.secondaryFixed elevation: 4,
: Theme.of(context).colorScheme.surface,
title: Text(
tabs[i],
style: TextStyle( style: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontSize: 12, fontSize: 12,
color: _selectedTabIndex == i
? Theme.of(context)
.colorScheme
.onSecondaryFixedVariant
: Theme.of(context).colorScheme.onSurface,
), ),
underline: Container(
height: 0,
), ),
selected: _selectedTabIndex == i, value: _selectedTabIndex,
onTap: () { items: tabs.asMap().entries.map((entry) {
return DropdownMenuItem<int>(
value: entry.key,
child: Text(entry.value),
);
}).toList(),
onChanged: (int? newValue) {
if (newValue != null) {
setState(() { setState(() {
_selectedTabIndex = i; _selectedTabIndex = newValue;
}); });
}
}, },
), ),
],
), ),
),
const VerticalDivider(width: 1),
Expanded( Expanded(
child: Container(
color: Theme.of(context).colorScheme.surfaceContainerLowest,
child: content[_selectedTabIndex], child: content[_selectedTabIndex],
), ),
),
], ],
); );
} }

View File

@ -17,7 +17,12 @@ class _ScriptsEditorPaneState extends ConsumerState<ScriptsEditorPane> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final settings = ref.watch(settingsProvider); final settings = ref.watch(settingsProvider);
return CodeTheme( return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(9),
color: Theme.of(context).colorScheme.surfaceContainerLowest,
),
child: CodeTheme(
data: CodeThemeData( data: CodeThemeData(
styles: settings.isDark ? monokaiTheme : xcodeTheme, styles: settings.isDark ? monokaiTheme : xcodeTheme,
), ),
@ -41,6 +46,7 @@ class _ScriptsEditorPaneState extends ConsumerState<ScriptsEditorPane> {
), ),
), ),
), ),
),
); );
} }
} }