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

View File

@ -17,7 +17,12 @@ class _ScriptsEditorPaneState extends ConsumerState<ScriptsEditorPane> {
@override
Widget build(BuildContext context) {
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(
styles: settings.isDark ? monokaiTheme : xcodeTheme,
),
@ -41,6 +46,7 @@ class _ScriptsEditorPaneState extends ConsumerState<ScriptsEditorPane> {
),
),
),
),
);
}
}