From 0e6910aedc0ead02714153260023c5767d16703d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans-J=C3=BCrgen=20Tappe?= Date: Thu, 12 Dec 2024 22:32:39 +0100 Subject: [PATCH] #26: Align URL button and QRCode vertically in event details --- lib/components/url_button.dart | 63 ++++++++++++++++++++++--------- lib/pages/event_details_page.dart | 12 ++++-- 2 files changed, 54 insertions(+), 21 deletions(-) diff --git a/lib/components/url_button.dart b/lib/components/url_button.dart index b7a7202..e958f5b 100644 --- a/lib/components/url_button.dart +++ b/lib/components/url_button.dart @@ -1,14 +1,17 @@ import 'package:flutter/material.dart'; +import 'package:iccm_eu_app/pages/share_page.dart'; import 'package:iccm_eu_app/utils/url_functions.dart'; class UrlButton extends StatelessWidget { final String? url; final String title; + final bool? withQrCode; const UrlButton({ super.key, required this.url, required this.title, + this.withQrCode = false, }); @override @@ -20,27 +23,51 @@ class UrlButton extends StatelessWidget { const SizedBox(height: 16.0), Center( child: FractionallySizedBox( - widthFactor: 0.9, // 90% of parent width - child: ElevatedButton( - style: ElevatedButton.styleFrom( - side: BorderSide( - color: Colors.green, - width: 2.0, - style: BorderStyle.solid, - strokeAlign: BorderSide.strokeAlignInside, + widthFactor: 0.9, + child: Row( // Use Row to arrange ElevatedButton and IconButton + mainAxisAlignment: MainAxisAlignment.spaceBetween, + // Space between items + children: [ + Expanded( // Allow ElevatedButton to take available space + child: ElevatedButton( + style: ElevatedButton.styleFrom( + side: BorderSide( + color: Colors.green, + width: 2.0, + style: BorderStyle.solid, + strokeAlign: BorderSide.strokeAlignInside, + ), + ), + onPressed: () => UrlFunctions.launch(url!), + child: Text( + title, + style: const TextStyle(fontSize: 20.0), + ), + ), ), - ), - onPressed: () => UrlFunctions.launch(url!), - child: Text( - title, - style: const TextStyle( - fontSize: 20.0, - ), - ), + const SizedBox(width: 16.0), + // Add spacing between ElevatedButton and IconButton + (withQrCode ?? false) + ? IconButton( + icon: Icon( + Icons.share, + color: Colors.grey[700], + ), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => SharePage(url: url!), + fullscreenDialog: true, + ), + ); + }, + ) + : const SizedBox.shrink(), + ], ), ), - ) - , + ), ], ); } else { diff --git a/lib/pages/event_details_page.dart b/lib/pages/event_details_page.dart index 2345d50..546bdc1 100644 --- a/lib/pages/event_details_page.dart +++ b/lib/pages/event_details_page.dart @@ -224,9 +224,15 @@ class EventDetailsPage extends StatelessWidget { const SizedBox(height: 8), if (item.surveyUrl != null && item.surveyUrl!.startsWith('https://')) - UrlButton( - title: 'Survey URL', - url: item.surveyUrl, + Column( + children: [ + UrlButton( + title: 'Survey URL', + url: item.surveyUrl, + withQrCode: true, + ), + + ] ) else SizedBox.shrink(),