diff --git a/lib/utils/window_utils.dart b/lib/utils/window_utils.dart index c3edec1d..c3722aac 100644 --- a/lib/utils/window_utils.dart +++ b/lib/utils/window_utils.dart @@ -10,3 +10,7 @@ bool showButtonLabelsInBodySuccess(int options, double maxWidth) { return false; } } + +bool showButtonLabelsInViewCodePane(double maxWidth) { + return (maxWidth < 400) ? false : true; +} diff --git a/lib/widgets/codegen_previewer.dart b/lib/widgets/codegen_previewer.dart index 5833d547..02043805 100644 --- a/lib/widgets/codegen_previewer.dart +++ b/lib/widgets/codegen_previewer.dart @@ -135,48 +135,55 @@ class _ViewCodePaneState extends State { borderRadius: kBorderRadius8, ); - return Padding( - padding: kP10, - child: Column( - children: [ - SizedBox( - height: kHeaderHeight, - child: Row( - children: [ - Expanded( - child: Text( - "Code", - style: Theme.of(context).textTheme.titleMedium, + return LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + var showLabel = showButtonLabelsInViewCodePane( + constraints.maxWidth, + ); + return Padding( + padding: kP10, + child: Column( + children: [ + SizedBox( + height: kHeaderHeight, + child: Row( + children: [ + Expanded( + child: DropdownButtonCodegenLanguage( + codegenLanguage: widget.codegenLanguage, + onChanged: widget.onChangedCodegenLanguage, + ), + ), + CopyButton( + toCopy: widget.code, + showLabel: showLabel, + ), + SaveInDownloadsButton( + content: stringToBytes(widget.code), + mimeType: "application/vnd.dart", + showLabel: showLabel, + ) + ], + ), + ), + kVSpacer10, + Expanded( + child: Container( + width: double.maxFinite, + padding: kP8, + decoration: textContainerdecoration, + child: CodeGenPreviewer( + code: widget.code, + theme: codeTheme, + language: 'dart', + textStyle: kCodeStyle, ), ), - DropdownButtonCodegenLanguage( - codegenLanguage: widget.codegenLanguage, - onChanged: widget.onChangedCodegenLanguage, - ), - CopyButton(toCopy: widget.code), - SaveInDownloadsButton( - content: stringToBytes(widget.code), - mimeType: "application/vnd.dart", - ) - ], - ), - ), - kVSpacer10, - Expanded( - child: Container( - width: double.maxFinite, - padding: kP8, - decoration: textContainerdecoration, - child: CodeGenPreviewer( - code: widget.code, - theme: codeTheme, - language: 'dart', - textStyle: kCodeStyle, ), - ), + ], ), - ], - ), + ); + }, ); } }