Skip to content

Commit

Permalink
AttributionWidget cleanup and sealing
Browse files Browse the repository at this point in the history
  • Loading branch information
JaffaKetchup committed Aug 21, 2023
1 parent 2bde03c commit e752af7
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 47 deletions.
5 changes: 1 addition & 4 deletions lib/flutter_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ export 'package:flutter_map/src/geo/latlng_bounds.dart';
export 'package:flutter_map/src/gestures/interactive_flag.dart';
export 'package:flutter_map/src/gestures/map_events.dart';
export 'package:flutter_map/src/gestures/multi_finger_gesture.dart';
export 'package:flutter_map/src/layer/attribution_layer/animation.dart';
export 'package:flutter_map/src/layer/attribution_layer/rich.dart';
export 'package:flutter_map/src/layer/attribution_layer/simple.dart';
export 'package:flutter_map/src/layer/attribution_layer/source.dart';
export 'package:flutter_map/src/layer/attribution_layer/shared.dart';
export 'package:flutter_map/src/layer/circle_layer.dart';
export 'package:flutter_map/src/layer/general/translucent_pointer.dart';
export 'package:flutter_map/src/layer/marker_layer.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_map/src/layer/attribution_layer/rich.dart';
part of '../shared.dart';

/// Animation provider base for a [RichAttributionWidget]
/// Animation provider interface for a [RichAttributionWidget]
///
/// The popup box's animation is handled/built by [popupAnimationBuilder] for
/// full flexibility.
Expand All @@ -14,7 +13,7 @@ import 'package:flutter_map/src/layer/attribution_layer/rich.dart';
/// [RichAttributionWidgetAnimation], or the prebuilt [FadeRAWA] and
/// [ScaleRAWA] animations can be used with limited customization.
@immutable
abstract class RichAttributionWidgetAnimation {
abstract interface class RichAttributionWidgetAnimation {
/// The duration of the animation used when toggling the state of the
/// open/close button
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_map/src/layer/attribution_layer/rich.dart';
part of '../shared.dart';

/// Base class for attributions that render themselves as widgets
///
/// Only used by [RichAttributionWidget].
///
/// Extended/implemented by [TextSourceAttribution] & [LogoSourceAttribution].
/// Base class for attributions that render themselves as widgets in a
/// [RichAttributionWidget]
///
/// Avoid manual implementation - unknown subtypes will not be displayed.
/// Extended by [TextSourceAttribution] & [LogoSourceAttribution].
@immutable
abstract class SourceAttribution extends StatelessWidget {
final VoidCallback? _onTap;
sealed class SourceAttribution extends StatelessWidget {
const SourceAttribution._({super.key, VoidCallback? onTap}) : _onTap = onTap;

const SourceAttribution._({
super.key,
VoidCallback? onTap,
}) : _onTap = onTap;
final VoidCallback? _onTap;

Widget _render(BuildContext context);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_map/plugin_api.dart';
import 'package:meta/meta.dart';
part of '../shared.dart';

/// Position to anchor [RichAttributionWidget] to relative to the [FlutterMap]
///
Expand All @@ -22,7 +18,6 @@ enum AttributionAlignment {
const AttributionAlignment(this.real);

/// Reflects the standard [Alignment]
@internal
final Alignment real;
}

Expand Down Expand Up @@ -65,9 +60,10 @@ enum AttributionAlignment {
@immutable
class RichAttributionWidget extends StatefulWidget
with
AttributionWidget,
AnchoredLayerStatefulMixin<
AnchoredLayerStateMixin<RichAttributionWidget>> {
AnchoredLayerStateMixin<RichAttributionWidget>>
implements
AttributionWidget {
/// List of attributions to display
///
/// [TextSourceAttribution]s are shown in a popup box (toggled by a tap/click
Expand Down
21 changes: 21 additions & 0 deletions lib/src/layer/attribution_layer/shared.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_map/plugin_api.dart';
import 'package:meta/meta.dart';

part 'rich/animation.dart';
part 'rich/source.dart';
part 'rich/widget.dart';
part 'simple.dart';

/// Layer widget intended to attribute a source
///
/// Implemented by [RichAttributionWidget] & [SimpleAttributionWidget].
///
/// Has no effect other than as a label to group the provided layers together
/// for the [FlutterMap.simple] constructor.
@immutable
sealed class AttributionWidget extends Widget {
const AttributionWidget._();
}
14 changes: 3 additions & 11 deletions lib/src/layer/attribution_layer/simple.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_map/src/layer/attribution_layer/rich.dart';
import 'package:flutter_map/src/map/widget.dart';

/// Layer widget intended to attribute a source
///
/// Applied to [RichAttributionWidget] & [SimpleAttributionWidget].
///
/// Has no effect, other than as a label to group the provided layers together.
mixin AttributionWidget on Widget {}
part of 'shared.dart';

/// A simple, classic style, attribution layer
///
Expand All @@ -23,7 +14,8 @@ mixin AttributionWidget on Widget {}
/// and has a more complex appearance.
@immutable
class SimpleAttributionWidget extends StatelessWidget
with AttributionWidget, AnchoredLayerStatelessMixin {
with AnchoredLayerStatelessMixin
implements AttributionWidget {
/// Attribution text, such as 'OpenStreetMap contributors'
final Text source;

Expand Down
1 change: 0 additions & 1 deletion lib/src/layer/general/anchored_layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ part of '../../map/widget.dart';
/// and need no additional setup. These widgets should contain a notice in the
/// documentation.
/// {@endtemplate}
@immutable
sealed class AnchoredLayer extends Widget {
/// Transforms the [child] widget into an [AnchoredLayer]
///
Expand Down
7 changes: 5 additions & 2 deletions lib/src/layer/general/translucent_pointer.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Migrated from https://github.com/spkersten/flutter_transparent_pointer, with
// some API & documentation changes
////////////////////////////////////////////////////////////////
/// Based on the work by Sander Kersten ///
/// Migrated, and now maintained here for flexibility ///
/// https://github.com/spkersten/flutter_transparent_pointer ///
////////////////////////////////////////////////////////////////
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
Expand Down
3 changes: 1 addition & 2 deletions lib/src/map/widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import 'dart:math';
import 'package:flutter/widgets.dart';
import 'package:flutter_map/src/gestures/flutter_map_interactive_viewer.dart';
import 'package:flutter_map/src/gestures/map_events.dart';
import 'package:flutter_map/src/layer/attribution_layer/rich.dart';
import 'package:flutter_map/src/layer/attribution_layer/simple.dart';
import 'package:flutter_map/src/layer/attribution_layer/shared.dart';
import 'package:flutter_map/src/layer/general/translucent_pointer.dart';
import 'package:flutter_map/src/layer/overlay_image_layer.dart';
import 'package:flutter_map/src/layer/tile_layer/tile_layer.dart';
Expand Down

0 comments on commit e752af7

Please sign in to comment.