Skip to content

Commit

Permalink
Remove some fade in effects on lists
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Apr 17, 2024
1 parent e41c05a commit 8251352
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 89 deletions.
82 changes: 39 additions & 43 deletions lib/Frontend/pages/move_list.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:math';

import 'package:animate_do/animate_do.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
Expand Down Expand Up @@ -61,39 +60,38 @@ class _MoveListViewState extends ConsumerState<MoveListView> {
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
return FadeIn(
delay: Duration(milliseconds: index * 100),
child: ListTile(
title: Text(allMoveLists[index].name),
subtitle: Text("${allMoveLists[index].moves.length} move(s)"), //TODO: Localize
trailing: IconButton(
tooltip: sequencesEdit(),
icon: const Icon(Icons.edit),
onPressed: () {
context.push<MoveList>("/moveLists/editMoveList", extra: allMoveLists[index]).then(
(value) => setState(
() {
if (value != null) {
allMoveLists[index] = value;
ref.watch(moveListsProvider.notifier).store();
}
},
),
);
},
),
onTap: () async {
if (SentryHive.box(settings).get(haptics, defaultValue: hapticsDefault)) {
HapticFeedback.selectionClick();
}
for (BaseStatefulDevice element in ref.watch(knownDevicesProvider).values.where((element) => allMoveLists[index].deviceCategory.contains(element.baseDeviceDefinition.deviceType))) {
if (SentryHive.box(settings).get(kitsuneModeToggle, defaultValue: kitsuneModeDefault)) {
await Future.delayed(Duration(milliseconds: Random().nextInt(kitsuneDelayRange)));
}
runAction(allMoveLists[index], element);
}
return ListTile(
key: Key('$index'),
title: Text(allMoveLists[index].name),
subtitle: Text("${allMoveLists[index].moves.length} move(s)"),
//TODO: Localize
trailing: IconButton(
tooltip: sequencesEdit(),
icon: const Icon(Icons.edit),
onPressed: () {
context.push<MoveList>("/moveLists/editMoveList", extra: allMoveLists[index]).then(
(value) => setState(
() {
if (value != null) {
allMoveLists[index] = value;
ref.watch(moveListsProvider.notifier).store();
}
},
),
);
},
),
onTap: () async {
if (SentryHive.box(settings).get(haptics, defaultValue: hapticsDefault)) {
HapticFeedback.selectionClick();
}
for (BaseStatefulDevice element in ref.watch(knownDevicesProvider).values.where((element) => allMoveLists[index].deviceCategory.contains(element.baseDeviceDefinition.deviceType))) {
if (SentryHive.box(settings).get(kitsuneModeToggle, defaultValue: kitsuneModeDefault)) {
await Future.delayed(Duration(milliseconds: Random().nextInt(kitsuneDelayRange)));
}
runAction(allMoveLists[index], element);
}
},
);
},
),
Expand Down Expand Up @@ -242,17 +240,15 @@ class _EditMoveList extends ConsumerState<EditMoveList> with TickerProviderState
shrinkWrap: true,
children: <Widget>[
for (int index = 0; index < moveList!.moves.length; index += 1)
FadeIn(
key: Key('$index'),
delay: Duration(milliseconds: (100 * index)),
child: ListTile(
title: Text(moveList!.moves[index].toString()),
leading: Icon(moveList!.moves[index].moveType.icon),
onTap: () {
editModal(context, index);
//context.push<Move>("/moveLists/editMoveList/editMove", extra: moveList!.moves[index]).then((value) => setState(() => moveList!.moves[index] = value!));
},
))
ListTile(
key: Key('$index'),
title: Text(moveList!.moves[index].toString()),
leading: Icon(moveList!.moves[index].moveType.icon),
onTap: () {
editModal(context, index);
//context.push<Move>("/moveLists/editMoveList/editMove", extra: moveList!.moves[index]).then((value) => setState(() => moveList!.moves[index] = value!));
},
)
],
onReorder: (int oldIndex, int newIndex) {
if (oldIndex < newIndex) {
Expand Down
88 changes: 42 additions & 46 deletions lib/Frontend/pages/triggers.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:animate_do/animate_do.dart';
import 'package:back_button_interceptor/back_button_interceptor.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
Expand Down Expand Up @@ -67,55 +66,52 @@ class _TriggersState extends ConsumerState<Triggers> {
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
return FadeIn(
delay: Duration(milliseconds: 100 * index),
child: ListTile(
onTap: () {
showModalBottomSheet(
isDismissible: true,
isScrollControlled: true,
showDragHandle: true,
enableDrag: true,
useRootNavigator: true,
context: context,
builder: (BuildContext context) {
return DraggableScrollableSheet(
expand: false,
initialChildSize: 0.5,
builder: (BuildContext context, ScrollController scrollController) {
return TriggerEdit(trigger: triggersList[index], scrollController: scrollController);
return ListTile(
onTap: () {
showModalBottomSheet(
isDismissible: true,
isScrollControlled: true,
showDragHandle: true,
enableDrag: true,
useRootNavigator: true,
context: context,
builder: (BuildContext context) {
return DraggableScrollableSheet(
expand: false,
initialChildSize: 0.5,
builder: (BuildContext context, ScrollController scrollController) {
return TriggerEdit(trigger: triggersList[index], scrollController: scrollController);
},
);
},
).whenComplete(() => setState(() {}));
},
title: Text(triggersList[index].triggerDefinition!.name),
subtitle: MultiValueListenableBuilder(
builder: (BuildContext context, List<dynamic> values, Widget? child) {
return AnimatedCrossFade(
firstChild: Text(triggersList[index].triggerDefinition!.description),
secondChild: const LinearProgressIndicator(),
crossFadeState: !values.any((element) => element == true) ? CrossFadeState.showFirst : CrossFadeState.showSecond,
duration: animationTransitionDuration,
);
},
valueListenables: triggersList[index].actions.map((e) => e.isActive).toList()),
leading: ListenableBuilder(
listenable: triggersList[index],
builder: (BuildContext context, Widget? child) {
return Switch(
value: triggersList[index].enabled,
onChanged: (bool value) {
setState(
() {
triggersList[index].enabled = value;
ref.watch(triggerListProvider.notifier).store();
},
);
},
).whenComplete(() => setState(() {}));
);
},
title: Text(triggersList[index].triggerDefinition!.name),
subtitle: MultiValueListenableBuilder(
builder: (BuildContext context, List<dynamic> values, Widget? child) {
return AnimatedCrossFade(
firstChild: Text(triggersList[index].triggerDefinition!.description),
secondChild: const LinearProgressIndicator(),
crossFadeState: !values.any((element) => element == true) ? CrossFadeState.showFirst : CrossFadeState.showSecond,
duration: animationTransitionDuration,
);
},
valueListenables: triggersList[index].actions.map((e) => e.isActive).toList()),
leading: ListenableBuilder(
listenable: triggersList[index],
builder: (BuildContext context, Widget? child) {
return Switch(
value: triggersList[index].enabled,
onChanged: (bool value) {
setState(
() {
triggersList[index].enabled = value;
ref.watch(triggerListProvider.notifier).store();
},
);
},
);
},
),
),
);
},
Expand Down

0 comments on commit 8251352

Please sign in to comment.