Enable declarative effect variations #35
                
     Open
            
            
          
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
What this does
Initial pass at a solution for #31 and beginnings of #34.
It sets a core architecture that supports both declarative syntax
[ FadeInEffect() ]and imperitiveanimate().fadeIn()when creating effect variations. The current solution for variations supports only the imperative syntax.It also adds some plumbing to more easily make variations of other effects. Whether this is composing two or more existing effect together (FadeEffect + SlideEffect), or simply creating a variation of an existing one (FadeIn or BlurX).
NOTE: While this touches many files, that is mostly due to a rename. The bulk of the interesting changes are in the effect.dart class and the new variations themselves.
Architecture
Effects do not always want to expose a public begin/end value.
FadeInAndUpmay haveOffset beginOffsetanddouble beginOpacityToggleorSwap.Being forced to inherit
begin/endfields in these cases is confusing/undesired, so (imo) we need to make this optional.To allow this, a new
BeginEndEffect<T>class was created, which extendsEffect, and thebegin/endfields were moved there.Most of the existing 'core' effects were modified to extend
BeginEndEffect, the exceptions wereThen,Toggle,CallbackandSwapwhere we were able to extendEffectdirectly and remove the weirdEffect<double>andEffect<void>stuff that was being forced. There are also no longer phantom begin/end properties on these effects which is nice.Finally a
CompositeEffectMixinwas created, to make it easier to create a new effect from existing ones. The mixin is just a small bit of syntactic sugar, that requires a list of effects, overrides build, and auto-builds all the effects. This allows variations to be created with virtually no boilerplate.Importantly, a new effect can both extend
BeginEndEffect<T>and use theCompositeEffectMixinif needed so it's quite flexible and easy to use in different configurations.Example 1,
FadeInEffect, does not want to expose public begin/end values, so it onlyextends Effect. It usesCompositeEffectMixinto keep boilerplate to a minimum:Example 2,
BlurXdoes want a begin and end, so itextends BeginEndEffectand usesCompositeEffectMixin. This shows how a variation can change the type of its core effect,BlurEffecttakes anOffset, but this takes adouble, straight inheritence would struggle here but the compositional approach has no problems:Example 3,
FadeInUpcomposesFadeInandSlideInUpeffects, which themselves are composed ofFadeandSlide, showing advanced multi-level composition. It does not useextends BeginEndEffect, because it would be unclear what properties they refer to. Instead it declares it's ownbeginYfor clarity:NOTE: In this example its been decided that
beginYwould make sense but the other values do not (beginOpacity,endOpacityandendY). This is debatable, but also not relevant to the example.What is left?
FadeInDown,SlideRight, etc)