Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,6 @@
"close": "Close",
"share": "Share",
"appNotFound": "App not found",
"networkError": "Network connection failed",
"invalidUrlFormat": "Invalid URL format",
"accessDenied": "Access denied",
"importFailed": "Import failed",
"updatiumExportHyphenatedLowercase": "updatium-export",
"pickAnAPK": "Pick an APK",
"appHasMoreThanOnePackage": "{} has more than one package:",
Expand Down
208 changes: 208 additions & 0 deletions lib/components/animated_navigation_bar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

/// Animated Navigation Bar with expressive interactions and animations
class AnimatedNavigationBar extends StatefulWidget {
final List<NavigationDestination> destinations;
final int selectedIndex;
final ValueChanged<int>? onDestinationSelected;

const AnimatedNavigationBar({
super.key,
required this.destinations,
required this.selectedIndex,
this.onDestinationSelected,
});

@override
State<AnimatedNavigationBar> createState() => _AnimatedNavigationBarState();
}

class _AnimatedNavigationBarState extends State<AnimatedNavigationBar>
with TickerProviderStateMixin {
late AnimationController _animationController;
late Animation<double> _slideAnimation;
late Animation<double> _fadeAnimation;
int? _previousIndex;

@override
void initState() {
super.initState();
_animationController = AnimationController(
duration: const Duration(milliseconds: 300),
vsync: this,
);

_slideAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(parent: _animationController, curve: Curves.easeOutCubic),
);

_fadeAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(parent: _animationController, curve: Curves.easeOutCubic),
);

_previousIndex = widget.selectedIndex;
_animationController.forward();
}

@override
void didUpdateWidget(AnimatedNavigationBar oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.selectedIndex != widget.selectedIndex) {
_previousIndex = oldWidget.selectedIndex;
_animationController.reset();
_animationController.forward();
}
}

@override
void dispose() {
_animationController.dispose();
super.dispose();
}

void _handleDestinationSelected(int index) {
HapticFeedback.selectionClick();
widget.onDestinationSelected?.call(index);
}

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final colorScheme = theme.colorScheme;

return Container(
height: 80,
decoration: BoxDecoration(
color: colorScheme.surface,
boxShadow: [
BoxShadow(
color: colorScheme.shadow.withOpacity(0.12),
blurRadius: 12,
offset: const Offset(0, -2),
),
],
),
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: widget.destinations.asMap().entries.map((entry) {
final index = entry.key;
final destination = entry.value;
final isSelected = index == widget.selectedIndex;

return Expanded(
child: GestureDetector(
onTap: () => _handleDestinationSelected(index),
child: AnimatedBuilder(
animation: _animationController,
builder: (context, child) {
// Calculate animation progress
final bool isEntering =
isSelected && _previousIndex != index;
final bool isExiting =
!isSelected && _previousIndex == index;

double scale = 1.0;
double opacity = 1.0;
double verticalOffset = 0.0;

if (isEntering) {
scale = 0.8 + (0.2 * _slideAnimation.value);
opacity = _fadeAnimation.value;
verticalOffset = 4.0 * (1.0 - _slideAnimation.value);
} else if (isExiting) {
scale = 1.0 - (0.2 * _slideAnimation.value);
opacity = 1.0 - (0.3 * _fadeAnimation.value);
verticalOffset = -4.0 * _slideAnimation.value;
} else if (isSelected) {
scale = 1.0;
opacity = 1.0;
verticalOffset = 0.0;
} else {
scale = 1.0;
opacity = 0.7;
verticalOffset = 0.0;
}

return Transform.translate(
offset: Offset(0, verticalOffset),
child: Transform.scale(
scale: scale,
child: AnimatedOpacity(
opacity: opacity,
duration: const Duration(milliseconds: 200),
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 12,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: isSelected
? colorScheme.secondaryContainer
: Colors.transparent,
border: Border.all(
color: isSelected
? colorScheme.secondary.withOpacity(0.3)
: Colors.transparent,
width: 1,
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
AnimatedContainer(
duration: const Duration(milliseconds: 300),
curve: Curves.easeOutCubic,
transform: Matrix4.identity()
..scale(isSelected ? 1.1 : 1.0),
child: IconTheme(
data: IconThemeData(
color: isSelected
? colorScheme.onSecondaryContainer
: colorScheme.onSurface.withOpacity(
0.7,
),
size: 24,
),
child: destination.icon,
),
),
if (isSelected)
AnimatedContainer(
duration: const Duration(
milliseconds: 200,
),
curve: Curves.easeOutCubic,
transform: Matrix4.identity()
..scale(_slideAnimation.value),
child: Container(
width: 4,
height: 4,
decoration: BoxDecoration(
color: colorScheme.primary,
shape: BoxShape.circle,
),
),
),
],
),
),
),
),
);
},
),
),
);
}).toList(),
),
),
),
);
}
}
Comment on lines +1 to +208

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The animations for scale, opacity, and verticalOffset are calculated inside the AnimatedBuilder but then passed to Transform.scale, AnimatedOpacity, and Transform.translate respectively. While this works, it's slightly inefficient and less direct than it could be. AnimatedOpacity creates its own AnimationController. You can directly use the _fadeAnimation.value on an Opacity widget inside the AnimatedBuilder to avoid this. Similarly, the transforms can be combined into a single Transform widget with a Matrix4 for better performance.

10 changes: 8 additions & 2 deletions lib/components/app_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,17 @@ class _AppTextButtonState extends State<AppTextButton>
);

_scaleAnimation = Tween<double>(begin: 1.0, end: 0.95).animate(
CurvedAnimation(parent: _animationController, curve: Curves.easeOutCubic),
CurvedAnimation(
parent: _animationController,
curve: Curves.easeOutCubic,
),
);

_opacityAnimation = Tween<double>(begin: 1.0, end: 0.8).animate(
CurvedAnimation(parent: _animationController, curve: Curves.easeInOut),
CurvedAnimation(
parent: _animationController,
curve: Curves.easeInOut,
),
);
}

Expand Down
15 changes: 12 additions & 3 deletions lib/components/cached_app_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ class _CachedAppIconState extends State<CachedAppIcon>
vsync: this,
);
_shimmerAnimation = Tween<double>(begin: -2.0, end: 2.0).animate(
CurvedAnimation(parent: _shimmerController, curve: Curves.easeInOut),
CurvedAnimation(
parent: _shimmerController,
curve: Curves.easeInOut,
),
);

// Scale animation for interactions
Expand All @@ -67,7 +70,10 @@ class _CachedAppIconState extends State<CachedAppIcon>
vsync: this,
);
_scaleAnimation = Tween<double>(begin: 1.0, end: 0.9).animate(
CurvedAnimation(parent: _scaleController, curve: Curves.easeOutCubic),
CurvedAnimation(
parent: _scaleController,
curve: Curves.easeOutCubic,
),
);

// Rotation animation for loading/error states
Expand All @@ -76,7 +82,10 @@ class _CachedAppIconState extends State<CachedAppIcon>
vsync: this,
);
_rotationAnimation = Tween<double>(begin: 0.0, end: 0.1).animate(
CurvedAnimation(parent: _rotationController, curve: Curves.easeInOut),
CurvedAnimation(
parent: _rotationController,
curve: Curves.easeInOut,
),
);

// Start loading the icon
Expand Down
30 changes: 30 additions & 0 deletions lib/components/custom_app_bar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:flutter/material.dart';

class CustomAppBar extends StatefulWidget {
const CustomAppBar({super.key, required this.title});

final String title;

@override
State<CustomAppBar> createState() => _CustomAppBarState();
}

class _CustomAppBarState extends State<CustomAppBar> {
@override
Widget build(BuildContext context) {
return SliverAppBar(
pinned: true,
automaticallyImplyLeading: false,
expandedHeight: 120,
flexibleSpace: FlexibleSpaceBar(
titlePadding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20),
title: Text(
widget.title,
style: TextStyle(
color: Theme.of(context).textTheme.bodyMedium!.color,
),
),
Comment on lines +21 to +26

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The CustomAppBar title's TextStyle only sets the color, using Theme.of(context).textTheme.bodyMedium!.color. This is not ideal for a few reasons:

  1. It force-unwraps a nullable property (!), which can lead to runtime errors if bodyMedium or its color is null.
  2. bodyMedium is generally not the correct text style for an app bar title. It's better to use styles from appBarTheme or more appropriate textTheme styles like titleLarge.
  3. Only setting the color means other properties (like font size, weight) will fall back to the FlexibleSpaceBar's default, which might not be what you intend.
Suggested change
title: Text(
widget.title,
style: TextStyle(
color: Theme.of(context).textTheme.bodyMedium!.color,
),
),
style: Theme.of(context).appBarTheme.titleTextStyle ?? Theme.of(context).textTheme.titleLarge,

),
);
}
}
Loading
Loading