mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-04-21 14:29:12 +00:00
Improved animation
This commit is contained in:
parent
1eb0df9063
commit
4a2f7b8bdb
2 changed files with 75 additions and 24 deletions
|
@ -9,7 +9,7 @@ import 'package:adguard_home_manager/providers/app_config_provider.dart';
|
||||||
import 'package:adguard_home_manager/providers/logs_provider.dart';
|
import 'package:adguard_home_manager/providers/logs_provider.dart';
|
||||||
import 'package:adguard_home_manager/providers/status_provider.dart';
|
import 'package:adguard_home_manager/providers/status_provider.dart';
|
||||||
|
|
||||||
class RowItem extends StatelessWidget {
|
class RowItem extends StatefulWidget {
|
||||||
final String type;
|
final String type;
|
||||||
final Color chartColor;
|
final Color chartColor;
|
||||||
final String domain;
|
final String domain;
|
||||||
|
@ -27,6 +27,53 @@ class RowItem extends StatelessWidget {
|
||||||
required this.showColor,
|
required this.showColor,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<RowItem> createState() => _RowItemState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RowItemState extends State<RowItem> with TickerProviderStateMixin {
|
||||||
|
late AnimationController expandController;
|
||||||
|
late Animation<double> animation;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
prepareAnimations();
|
||||||
|
_runExpandCheck();
|
||||||
|
}
|
||||||
|
|
||||||
|
void prepareAnimations() {
|
||||||
|
expandController = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: const Duration(milliseconds: 250)
|
||||||
|
);
|
||||||
|
animation = CurvedAnimation(
|
||||||
|
parent: expandController,
|
||||||
|
curve: Curves.ease,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _runExpandCheck() {
|
||||||
|
if (widget.showColor) {
|
||||||
|
expandController.forward();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
expandController.reverse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
_runExpandCheck();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
expandController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final statusProvider = Provider.of<StatusProvider>(context);
|
final statusProvider = Provider.of<StatusProvider>(context);
|
||||||
|
@ -34,9 +81,9 @@ class RowItem extends StatelessWidget {
|
||||||
final logsProvider = Provider.of<LogsProvider>(context);
|
final logsProvider = Provider.of<LogsProvider>(context);
|
||||||
|
|
||||||
String? name;
|
String? name;
|
||||||
if (clients == true) {
|
if (widget.clients == true) {
|
||||||
try {
|
try {
|
||||||
name = statusProvider.serverStatus!.clients.firstWhere((c) => c.ids.contains(domain)).name;
|
name = statusProvider.serverStatus!.clients.firstWhere((c) => c.ids.contains(widget.domain)).name;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// ---- //
|
// ---- //
|
||||||
}
|
}
|
||||||
|
@ -45,30 +92,30 @@ class RowItem extends StatelessWidget {
|
||||||
return Material(
|
return Material(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: DomainOptions(
|
child: DomainOptions(
|
||||||
item: domain,
|
item: widget.domain,
|
||||||
isClient: type == 'topClients',
|
isClient: widget.type == 'topClients',
|
||||||
isBlocked: type == 'topBlockedDomains',
|
isBlocked: widget.type == 'topBlockedDomains',
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (type == 'topQueriedDomains' || type == 'topBlockedDomains') {
|
if (widget.type == 'topQueriedDomains' || widget.type == 'topBlockedDomains') {
|
||||||
logsProvider.setSearchText(domain);
|
logsProvider.setSearchText(widget.domain);
|
||||||
logsProvider.setSelectedClients(null);
|
logsProvider.setSelectedClients(null);
|
||||||
logsProvider.setAppliedFilters(
|
logsProvider.setAppliedFilters(
|
||||||
AppliedFiters(
|
AppliedFiters(
|
||||||
selectedResultStatus: 'all',
|
selectedResultStatus: 'all',
|
||||||
searchText: domain,
|
searchText: widget.domain,
|
||||||
clients: null
|
clients: null
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
appConfigProvider.setSelectedScreen(2);
|
appConfigProvider.setSelectedScreen(2);
|
||||||
}
|
}
|
||||||
else if (type == 'topClients') {
|
else if (widget.type == 'topClients') {
|
||||||
logsProvider.setSearchText(null);
|
logsProvider.setSearchText(null);
|
||||||
logsProvider.setSelectedClients([domain]);
|
logsProvider.setSelectedClients([widget.domain]);
|
||||||
logsProvider.setAppliedFilters(
|
logsProvider.setAppliedFilters(
|
||||||
AppliedFiters(
|
AppliedFiters(
|
||||||
selectedResultStatus: 'all',
|
selectedResultStatus: 'all',
|
||||||
searchText: null,
|
searchText: null,
|
||||||
clients: [domain]
|
clients: [widget.domain]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
appConfigProvider.setSelectedScreen(2);
|
appConfigProvider.setSelectedScreen(2);
|
||||||
|
@ -85,15 +132,18 @@ class RowItem extends StatelessWidget {
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
AnimatedContainer(
|
SizeTransition(
|
||||||
duration: const Duration(milliseconds: 200),
|
axisAlignment: 1.0,
|
||||||
curve: Curves.ease,
|
sizeFactor: animation,
|
||||||
margin: EdgeInsets.only(right: showColor ? 16 : 0),
|
axis: Axis.horizontal,
|
||||||
width: showColor ? 12 : 0,
|
child: Container(
|
||||||
height: showColor ? 12 : 0,
|
margin: const EdgeInsets.only(right: 16),
|
||||||
|
width: 12,
|
||||||
|
height: 12,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(30),
|
borderRadius: BorderRadius.circular(30),
|
||||||
color: chartColor
|
color: widget.chartColor
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
|
@ -101,7 +151,7 @@ class RowItem extends StatelessWidget {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
domain,
|
widget.domain,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
|
@ -127,7 +177,7 @@ class RowItem extends StatelessWidget {
|
||||||
),
|
),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
Text(
|
Text(
|
||||||
number,
|
widget.number,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.onSurface
|
color: Theme.of(context).colorScheme.onSurface
|
||||||
),
|
),
|
||||||
|
@ -168,7 +218,7 @@ class _OthersRowItemState extends State<OthersRowItem> with SingleTickerProvider
|
||||||
void prepareAnimations() {
|
void prepareAnimations() {
|
||||||
expandController = AnimationController(
|
expandController = AnimationController(
|
||||||
vsync: this,
|
vsync: this,
|
||||||
duration: const Duration(milliseconds: 200)
|
duration: const Duration(milliseconds: 250)
|
||||||
);
|
);
|
||||||
animation = CurvedAnimation(
|
animation = CurvedAnimation(
|
||||||
parent: expandController,
|
parent: expandController,
|
||||||
|
|
|
@ -153,6 +153,7 @@ class _TopItemsState extends State<TopItems> {
|
||||||
expandedHeaderPadding: const EdgeInsets.all(0),
|
expandedHeaderPadding: const EdgeInsets.all(0),
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
expansionCallback: (_, isExpanded) => setState(() => _showChart = isExpanded),
|
expansionCallback: (_, isExpanded) => setState(() => _showChart = isExpanded),
|
||||||
|
animationDuration: const Duration(milliseconds: 250),
|
||||||
children: [
|
children: [
|
||||||
ExpansionPanel(
|
ExpansionPanel(
|
||||||
headerBuilder: (context, isExpanded) => Padding(
|
headerBuilder: (context, isExpanded) => Padding(
|
||||||
|
|
Loading…
Add table
Reference in a new issue