|
| 1 | +// Copyright 2017 Workiva Inc. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +library abstract_transition_props; |
| 16 | + |
| 17 | +import 'dart:collection'; |
| 18 | + |
| 19 | +import 'package:over_react/over_react.dart'; |
| 20 | + |
| 21 | +/// Props that mirror the implementation of [AbstractTransitionProps], made available as a mixin for components |
| 22 | +/// that cannot extend directly from [AbstractTransitionComponent]. |
| 23 | +@PropsMixin() |
| 24 | +abstract class TransitionPropsMixin { |
| 25 | + static final TransitionPropsMapView defaultProps = new TransitionPropsMapView({}) |
| 26 | + ..transitionCount = 1; |
| 27 | + |
| 28 | + Map get props; |
| 29 | + |
| 30 | + /// Number of transitions to occur within the [AbstractTransitionComponent]. |
| 31 | + /// |
| 32 | + /// Default: 1 |
| 33 | + int transitionCount; |
| 34 | + |
| 35 | + /// Optional callback that fires before the [AbstractTransitionComponent] is hidden. |
| 36 | + /// |
| 37 | + /// Returning `false` will cancel default behavior, and the [AbstractTransitionComponent] will remain visible. |
| 38 | + Callback onWillHide; |
| 39 | + |
| 40 | + /// Optional callback that fires after the [AbstractTransitionComponent] is hidden. |
| 41 | + Callback onDidHide; |
| 42 | + |
| 43 | + /// Optional callback that fires before the [AbstractTransitionComponent] appears. |
| 44 | + /// |
| 45 | + /// Returning `false` will cancel default behavior, and the [AbstractTransitionComponent] will not appear. |
| 46 | + Callback onWillShow; |
| 47 | + |
| 48 | + /// Optional callback that fires after the [AbstractTransitionComponent] appears. |
| 49 | + Callback onDidShow; |
| 50 | +} |
| 51 | + |
| 52 | +class TransitionPropsMapView extends MapView with |
| 53 | + TransitionPropsMixin { |
| 54 | + /// Create a new instance backed by the specified map. |
| 55 | + TransitionPropsMapView(Map map) : super(map); |
| 56 | + |
| 57 | + /// The props to be manipulated via the getters/setters. |
| 58 | + /// In this case, it's the current MapView object. |
| 59 | + @override |
| 60 | + Map get props => this; |
| 61 | +} |
0 commit comments