Merge branch 'master' into feature-landscape-support

This commit is contained in:
Shawn 2022-12-01 20:36:03 -07:00
commit e1143e252e
2 changed files with 32 additions and 37 deletions

View File

@ -24,7 +24,7 @@ class AppColors {
TextTheme txtTheme = (isDark ? ThemeData.dark() : ThemeData.light()).textTheme; TextTheme txtTheme = (isDark ? ThemeData.dark() : ThemeData.light()).textTheme;
Color txtColor = white; Color txtColor = white;
ColorScheme colorScheme = ColorScheme( ColorScheme colorScheme = ColorScheme(
// Decide how you want to apply your own custom them, to the MaterialApp // Decide how you want to apply your own custom theme, to the MaterialApp
brightness: isDark ? Brightness.dark : Brightness.light, brightness: isDark ? Brightness.dark : Brightness.light,
primary: accent1, primary: accent1,
primaryContainer: accent1, primaryContainer: accent1,

View File

@ -148,46 +148,41 @@ class _PhotoGalleryState extends State<PhotoGallery> {
gridOffset += Offset(0, -context.mq.padding.top / 2); gridOffset += Offset(0, -context.mq.padding.top / 2);
final offsetTweenDuration = _skipNextOffsetTween ? Duration.zero : swipeDuration; final offsetTweenDuration = _skipNextOffsetTween ? Duration.zero : swipeDuration;
final cutoutTweenDuration = _skipNextOffsetTween ? Duration.zero : swipeDuration * .5; final cutoutTweenDuration = _skipNextOffsetTween ? Duration.zero : swipeDuration * .5;
return Stack( return _AnimatedCutoutOverlay(
children: [ animationKey: ValueKey(_index),
// A overlay with a transparent middle sits on top of everything, animating itself each time index changes cutoutSize: imgSize,
_AnimatedCutoutOverlay( swipeDir: _lastSwipeDir,
animationKey: ValueKey(_index), duration: cutoutTweenDuration,
cutoutSize: imgSize, opacity: _scale == 1 ? .7 : .5,
swipeDir: _lastSwipeDir, child: SafeArea(
duration: cutoutTweenDuration, bottom: false,
opacity: _scale == 1 ? .7 : .5, // Place content in overflow box, to allow it to flow outside the parent
child: SafeArea( child: OverflowBox(
bottom: false, maxWidth: _gridSize * imgSize.width + padding * (_gridSize - 1),
// Place content in overflow box, to allow it to flow outside the parent maxHeight: _gridSize * imgSize.height + padding * (_gridSize - 1),
child: OverflowBox( alignment: Alignment.center,
maxWidth: _gridSize * imgSize.width + padding * (_gridSize - 1), // Detect swipes in order to change index
maxHeight: _gridSize * imgSize.height + padding * (_gridSize - 1), child: EightWaySwipeDetector(
alignment: Alignment.center, onSwipe: _handleSwipe,
// Detect swipes in order to change index threshold: 30,
child: EightWaySwipeDetector( // A tween animation builder moves from image to image based on current offset
onSwipe: _handleSwipe, child: TweenAnimationBuilder<Offset>(
threshold: 30, tween: Tween(begin: gridOffset, end: gridOffset),
// A tween animation builder moves from image to image based on current offset duration: offsetTweenDuration,
child: TweenAnimationBuilder<Offset>( curve: Curves.easeOut,
tween: Tween(begin: gridOffset, end: gridOffset), builder: (_, value, child) => Transform.translate(offset: value, child: child),
duration: offsetTweenDuration, child: GridView.count(
curve: Curves.easeOut, physics: NeverScrollableScrollPhysics(),
builder: (_, value, child) => Transform.translate(offset: value, child: child), crossAxisCount: _gridSize,
child: GridView.count( childAspectRatio: imgSize.aspectRatio,
physics: NeverScrollableScrollPhysics(), mainAxisSpacing: padding,
crossAxisCount: _gridSize, crossAxisSpacing: padding,
childAspectRatio: imgSize.aspectRatio, children: List.generate(_imgCount, (i) => _buildImage(i, swipeDuration, imgSize)),
mainAxisSpacing: padding,
crossAxisSpacing: padding,
children: List.generate(_imgCount, (i) => _buildImage(i, swipeDuration, imgSize)),
),
),
), ),
), ),
), ),
), ),
], ),
); );
}); });
} }