Skip to content

Commit

Permalink
Merge pull request #294 from enrique-lozano/fix/appbar-slivers
Browse files Browse the repository at this point in the history
Wrong states and UI bugs in the sliver appbar headers
  • Loading branch information
enrique-lozano authored Jan 9, 2025
2 parents 06e447f + 550ef92 commit 4c72b1c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
20 changes: 14 additions & 6 deletions lib/app/accounts/details/account_details.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:math';

import 'package:drift/drift.dart' as drift;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -252,11 +254,15 @@ class _AccountDetailHeader extends SliverPersistentHeaderDelegate {
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
crossAxisAlignment: shrinkPercent > 0.5
? CrossAxisAlignment.center
: CrossAxisAlignment.end,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.end,
mainAxisAlignment: shrinkPercent > 0.5
? MainAxisAlignment.center
: MainAxisAlignment.end,
children: [
Text(account.name),
StreamBuilder(
Expand All @@ -273,7 +279,8 @@ class _AccountDetailHeader extends SliverPersistentHeaderDelegate {
.textTheme
.headlineMedium!
.copyWith(
fontSize: 32 - shrinkPercent * 16,
fontSize:
32 - (1 - pow(1 - shrinkPercent, 4)) * 15,
fontWeight: FontWeight.w600,
),
child: CurrencyDisplayer(
Expand Down Expand Up @@ -320,7 +327,8 @@ class _AccountDetailHeader extends SliverPersistentHeaderDelegate {
),
Hero(
tag: accountIconHeroTag ?? UniqueKey(),
child: account.displayIcon(context, size: 48 - shrinkPercent * 20),
child: account.displayIcon(context,
size: 48 - (1 - pow(1 - shrinkPercent, 4)) * 20),
),
],
),
Expand All @@ -334,8 +342,8 @@ class _AccountDetailHeader extends SliverPersistentHeaderDelegate {
double get minExtent => 80;

@override
bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) =>
false;
bool shouldRebuild(covariant _AccountDetailHeader oldDelegate) =>
oldDelegate.account != account;
}

class ArchiveWarnDialog extends StatefulWidget {
Expand Down
8 changes: 5 additions & 3 deletions lib/app/transactions/transaction_details.page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:math';

import 'package:collection/collection.dart';
import 'package:drift/drift.dart' as drift;
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -771,7 +773,7 @@ class _TransactionDetailHeader extends SliverPersistentHeaderDelegate {
AnimatedDefaultTextStyle(
duration: const Duration(milliseconds: 100),
style: Theme.of(context).textTheme.headlineMedium!.copyWith(
fontSize: 34 - shrinkPercent * 16,
fontSize: 34 - (1 - pow(1 - shrinkPercent, 4)) * 16,
fontWeight: FontWeight.w600,
color: transaction.status == TransactionStatus.voided
? Colors.grey.shade400
Expand Down Expand Up @@ -845,7 +847,7 @@ class _TransactionDetailHeader extends SliverPersistentHeaderDelegate {
tag: heroTag ?? UniqueKey(),
child: transaction.getDisplayIcon(
context,
size: 42 - shrinkPercent * 16,
size: 42 - (1 - pow(1 - shrinkPercent, 4)) * 16,
),
),
],
Expand All @@ -857,7 +859,7 @@ class _TransactionDetailHeader extends SliverPersistentHeaderDelegate {
double get maxExtent => 120;

@override
double get minExtent => 90;
double get minExtent => 80;

@override
bool shouldRebuild(covariant _TransactionDetailHeader oldDelegate) =>
Expand Down

0 comments on commit 4c72b1c

Please sign in to comment.