From 0abd7a4ddc607837051afe5019c729e1511c7b19 Mon Sep 17 00:00:00 2001 From: Feichtmeier Date: Thu, 10 Nov 2022 12:24:05 +0100 Subject: [PATCH] Center the code-snippet button --- example/lib/main.dart | 122 ++++++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 58 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index a254bf8b2..9572e04ed 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -96,65 +96,71 @@ class _HomeState extends State { return Container(); } - return IconButton( - onPressed: () => showDialog( - barrierDismissible: true, - context: context, - builder: (context) { - var snippet = ''; - - return AlertDialog( - titlePadding: EdgeInsets.zero, - title: YaruTitleBar( - title: Text(pageItem.tooltipMessage), - trailing: const YaruCloseButton(), - leading: IconButton( - icon: const Icon(YaruIcons.edit_copy), - tooltip: 'Copy', - onPressed: () async { - await Clipboard.setData( - ClipboardData(text: snippet), - ); - }, - ), - ), - content: FutureBuilder( - future: _getCodeSnippet( - pageItem.snippetUrl!, - ), - builder: (context, snapshot) { - switch (snapshot.connectionState) { - case ConnectionState.none: - case ConnectionState.waiting: - case ConnectionState.active: - return const Center( - child: YaruCircularProgressIndicator( - strokeWidth: 3, - ), - ); - case ConnectionState.done: - snippet = snapshot.data!; - return SingleChildScrollView( - child: HighlightView( - snippet, - language: 'dart', - theme: Theme.of(context).brightness == Brightness.dark - ? vs2015Theme - : vsTheme, - padding: const EdgeInsets.all(12), - textStyle: const TextStyle( - fontSize: 16, - ), - ), - ); - } - }, - ), - ); - }, + return Padding( + padding: const EdgeInsets.only(right: 8), + child: Center( + child: YaruIconButton( + onPressed: () => showDialog( + barrierDismissible: true, + context: context, + builder: (context) { + var snippet = ''; + + return AlertDialog( + titlePadding: EdgeInsets.zero, + title: YaruTitleBar( + title: Text(pageItem.tooltipMessage), + trailing: const YaruCloseButton(), + leading: IconButton( + icon: const Icon(YaruIcons.edit_copy), + tooltip: 'Copy', + onPressed: () async { + await Clipboard.setData( + ClipboardData(text: snippet), + ); + }, + ), + ), + content: FutureBuilder( + future: _getCodeSnippet( + pageItem.snippetUrl!, + ), + builder: (context, snapshot) { + switch (snapshot.connectionState) { + case ConnectionState.none: + case ConnectionState.waiting: + case ConnectionState.active: + return const Center( + child: YaruCircularProgressIndicator( + strokeWidth: 3, + ), + ); + case ConnectionState.done: + snippet = snapshot.data!; + return SingleChildScrollView( + child: HighlightView( + snippet, + language: 'dart', + theme: + Theme.of(context).brightness == Brightness.dark + ? vs2015Theme + : vsTheme, + padding: const EdgeInsets.all(12), + textStyle: const TextStyle( + fontSize: 16, + ), + ), + ); + } + }, + ), + ); + }, + ), + icon: const Icon(YaruIcons.desktop_panel_look), + tooltip: 'Example snippet', + ), ), - icon: const Icon(YaruIcons.desktop_panel_look), - tooltip: 'Example snippet', ); } }