From 445157f3e26af52a2c86e0bcec9a011a1772c05c Mon Sep 17 00:00:00 2001 From: Banana <69007475+Just-Learned-It@users.noreply.github.com> Date: Fri, 28 Oct 2022 21:28:33 +0200 Subject: [PATCH] new attributionwidget constructor --- lib/src/layer/attribution_layer.dart | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/lib/src/layer/attribution_layer.dart b/lib/src/layer/attribution_layer.dart index cd8614b34..82f0fec76 100644 --- a/lib/src/layer/attribution_layer.dart +++ b/lib/src/layer/attribution_layer.dart @@ -65,4 +65,39 @@ class AttributionWidget extends StatelessWidget { ), ), ); + + + /// Quick constructor for a more classic styled attibution box + /// + /// Displayed as a padded translucent white box with the text from [source]. + /// + /// Provide [onSourceTapped] to carry out a function when the box is tapped. If that isn't null, the source text will have [sourceTextStyle] styling - which defaults to a link styling. + static Widget customText({ + required String source, + void Function()? onSourceTapped, + TextStyle sourceTextStyle = const TextStyle(color: Color(0xFF0078a8)), + Alignment alignment = Alignment.bottomRight, + }) => + Align( + alignment: alignment, + child: ColoredBox( + color: const Color(0xCCFFFFFF), + child: GestureDetector( + onTap: onSourceTapped, + child: Padding( + padding: const EdgeInsets.all(3), + child: + MouseRegion( + cursor: onSourceTapped == null + ? MouseCursor.defer + : SystemMouseCursors.click, + child: Text( + source, + style: onSourceTapped == null ? null : sourceTextStyle, + ), + ), + ), + ), + ), + ); }