mirror of
https://github.com/foss42/apidash.git
synced 2025-07-03 06:27:26 +08:00
refactor: replace TabView with DropdownButton
This commit is contained in:
@ -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,52 +50,45 @@ 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,
|
borderRadius: BorderRadius.circular(9),
|
||||||
shape: RoundedRectangleBorder(
|
elevation: 4,
|
||||||
borderRadius: BorderRadius.circular(2),
|
style: TextStyle(
|
||||||
),
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
selectedTileColor: _selectedTabIndex == i
|
fontSize: 12,
|
||||||
? Theme.of(context).colorScheme.secondaryFixed
|
),
|
||||||
: Theme.of(context).colorScheme.surface,
|
underline: Container(
|
||||||
title: Text(
|
height: 0,
|
||||||
tabs[i],
|
),
|
||||||
style: TextStyle(
|
value: _selectedTabIndex,
|
||||||
fontSize: 12,
|
items: tabs.asMap().entries.map((entry) {
|
||||||
color: _selectedTabIndex == i
|
return DropdownMenuItem<int>(
|
||||||
? Theme.of(context)
|
value: entry.key,
|
||||||
.colorScheme
|
child: Text(entry.value),
|
||||||
.onSecondaryFixedVariant
|
);
|
||||||
: Theme.of(context).colorScheme.onSurface,
|
}).toList(),
|
||||||
),
|
onChanged: (int? newValue) {
|
||||||
),
|
if (newValue != null) {
|
||||||
selected: _selectedTabIndex == i,
|
setState(() {
|
||||||
onTap: () {
|
_selectedTabIndex = newValue;
|
||||||
setState(() {
|
});
|
||||||
_selectedTabIndex = i;
|
}
|
||||||
});
|
},
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const VerticalDivider(width: 1),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: content[_selectedTabIndex],
|
||||||
color: Theme.of(context).colorScheme.surfaceContainerLowest,
|
|
||||||
child: content[_selectedTabIndex],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -17,27 +17,33 @@ 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(
|
||||||
data: CodeThemeData(
|
decoration: BoxDecoration(
|
||||||
styles: settings.isDark ? monokaiTheme : xcodeTheme,
|
borderRadius: BorderRadius.circular(9),
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainerLowest,
|
||||||
),
|
),
|
||||||
child: SingleChildScrollView(
|
child: CodeTheme(
|
||||||
child: CodeField(
|
data: CodeThemeData(
|
||||||
smartDashesType: SmartDashesType.enabled,
|
styles: settings.isDark ? monokaiTheme : xcodeTheme,
|
||||||
smartQuotesType: SmartQuotesType.enabled,
|
),
|
||||||
background: Theme.of(context).colorScheme.surfaceContainerLowest,
|
child: SingleChildScrollView(
|
||||||
gutterStyle: GutterStyle(
|
child: CodeField(
|
||||||
width: 40, // TODO: Fix numbers size
|
smartDashesType: SmartDashesType.enabled,
|
||||||
margin: 2,
|
smartQuotesType: SmartQuotesType.enabled,
|
||||||
textAlign: TextAlign.left,
|
background: Theme.of(context).colorScheme.surfaceContainerLowest,
|
||||||
showFoldingHandles: false,
|
gutterStyle: GutterStyle(
|
||||||
showLineNumbers: false,
|
width: 40, // TODO: Fix numbers size
|
||||||
),
|
margin: 2,
|
||||||
cursorColor: Theme.of(context).colorScheme.primary,
|
textAlign: TextAlign.left,
|
||||||
controller: widget.controller,
|
showFoldingHandles: false,
|
||||||
textStyle: TextStyle(
|
showLineNumbers: false,
|
||||||
fontSize: 12,
|
),
|
||||||
fontFamily: 'monospace',
|
cursorColor: Theme.of(context).colorScheme.primary,
|
||||||
|
controller: widget.controller,
|
||||||
|
textStyle: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
fontFamily: 'monospace',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user