forked from ImranR98/Obtainium
-
Notifications
You must be signed in to change notification settings - Fork 2
Cherry pick safe commits #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
dfadfd7
Revert "UX/UI improvmemts"
omeritzics 4616d3b
Fix build issues
omeritzics 7ce2090
Fix
omeritzics 641307b
Update lib/pages/apps.dart
omeritzics 8e92baf
Update strings
omeritzics 1f2edc8
Update strings
omeritzics ca57e14
Update lib/pages/apps.dart
omeritzics 6955045
Update ci.yml
omeritzics 4a29b1f
Merge branch 'main' into cherry-pick-safe-commits
omeritzics File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(), | ||
| ), | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||||
| ), | ||||||||||||||||
| ); | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The animations for
scale,opacity, andverticalOffsetare calculated inside theAnimatedBuilderbut then passed toTransform.scale,AnimatedOpacity, andTransform.translaterespectively. While this works, it's slightly inefficient and less direct than it could be.AnimatedOpacitycreates its ownAnimationController. You can directly use the_fadeAnimation.valueon anOpacitywidget inside theAnimatedBuilderto avoid this. Similarly, the transforms can be combined into a singleTransformwidget with aMatrix4for better performance.