Skip to content

Commit

Permalink
Fix showcasewidget breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
FauconSpartiate committed Jun 2, 2024
1 parent ebb9572 commit be6a0c6
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 124 deletions.
206 changes: 102 additions & 104 deletions lib/ui/routes/home_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,116 +69,114 @@ class _HomePageState extends State<HomePage> {
rebuild();
},
enableShowcase: shouldShowcase,
builder: Builder(
builder: (context) {
return SafeArea(
top: false,
bottom: false,
child: Builder(
builder: (context) {
return CustomScrollView(
slivers: [
SliverOverlapInjector(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
),
SliverSafeArea(
top: false,
bottom: false,
sliver: SliverToBoxAdapter(
child: Builder(
builder: (context) {
showTutorial(context);
builder: (context) {
return SafeArea(
top: false,
bottom: false,
child: Builder(
builder: (context) {
return CustomScrollView(
slivers: [
SliverOverlapInjector(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
),
SliverSafeArea(
top: false,
bottom: false,
sliver: SliverToBoxAdapter(
child: Builder(
builder: (context) {
showTutorial(context);

final Widget child = ResultRow(
result: widget.term.getResult(),
preciseResult: widget.term.getResult(precise: true),
leading: Text(
widget.term.isYearOverview ? translations.yearly_average : translations.average,
overflow: TextOverflow.fade,
softWrap: false,
style: Theme.of(context).textTheme.titleLarge,
),
);
final Widget child = ResultRow(
result: widget.term.getResult(),
preciseResult: widget.term.getResult(precise: true),
leading: Text(
widget.term.isYearOverview ? translations.yearly_average : translations.average,
overflow: TextOverflow.fade,
softWrap: false,
style: Theme.of(context).textTheme.titleLarge,
),
);

if (shouldShowcase) {
// TODO: Change preciseValue on tap
return Showcase(
key: showCaseKey,
description: translations.showcase_precise_average,
scaleAnimationCurve: Easing.standardDecelerate,
child: child,
);
} else {
return child;
}
},
),
if (shouldShowcase) {
// TODO: Change preciseValue on tap
return Showcase(
key: showCaseKey,
description: translations.showcase_precise_average,
scaleAnimationCurve: Easing.standardDecelerate,
child: child,
);
} else {
return child;
}
},
),
),
CustomSliverSafeArea(
top: false,
maintainBottomViewPadding: true,
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
childCount: subjectData.length,
(context, index) {
if (!subjectData[index].isGroup) {
return TextRow(
leadingText: subjectData[index].name,
trailingText: subjectData[index].getResult(),
trailing: const Icon(Icons.navigate_next),
onTap: () {
Navigator.pushNamed(context, "/subject", arguments: [null, subjectData[index]]).then((_) => refreshYearOverview());
},
onLongPress: () {
showTestDialog(context, subjectData[index]).then((_) => refreshYearOverview());
},
);
} else {
return GroupRow(
leadingText: subjectData[index].name,
trailingText: subjectData[index].getResult(),
children: [
const Divider(),
for (int i = 0; i < childrenData[index].length; i++)
Column(
children: [
TextRow(
leadingText: childrenData[index][i].name,
trailingText: childrenData[index][i].getResult(),
trailing: const Icon(Icons.navigate_next),
padding: const EdgeInsets.only(left: 36, right: 24),
onTap: () {
Navigator.pushNamed(
context,
"/subject",
arguments: [subjectData[index], childrenData[index][i]],
).then((_) => refreshYearOverview());
},
onLongPress: () {
showTestDialog(context, childrenData[index][i]).then((_) => refreshYearOverview());
},
isChild: true,
),
if (i != childrenData[index].length - 1) Divider(indent: Theme.of(context).dividerTheme.indent! + 16),
],
),
],
);
}
},
),
),
CustomSliverSafeArea(
top: false,
maintainBottomViewPadding: true,
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
childCount: subjectData.length,
(context, index) {
if (!subjectData[index].isGroup) {
return TextRow(
leadingText: subjectData[index].name,
trailingText: subjectData[index].getResult(),
trailing: const Icon(Icons.navigate_next),
onTap: () {
Navigator.pushNamed(context, "/subject", arguments: [null, subjectData[index]]).then((_) => refreshYearOverview());
},
onLongPress: () {
showTestDialog(context, subjectData[index]).then((_) => refreshYearOverview());
},
);
} else {
return GroupRow(
leadingText: subjectData[index].name,
trailingText: subjectData[index].getResult(),
children: [
const Divider(),
for (int i = 0; i < childrenData[index].length; i++)
Column(
children: [
TextRow(
leadingText: childrenData[index][i].name,
trailingText: childrenData[index][i].getResult(),
trailing: const Icon(Icons.navigate_next),
padding: const EdgeInsets.only(left: 36, right: 24),
onTap: () {
Navigator.pushNamed(
context,
"/subject",
arguments: [subjectData[index], childrenData[index][i]],
).then((_) => refreshYearOverview());
},
onLongPress: () {
showTestDialog(context, childrenData[index][i]).then((_) => refreshYearOverview());
},
isChild: true,
),
if (i != childrenData[index].length - 1) Divider(indent: Theme.of(context).dividerTheme.indent! + 16),
],
),
],
);
}
},
),
),
if (subjectData.isEmpty) SliverEmptyWidget(message: translations.no_subjects),
const SliverPadding(padding: EdgeInsets.only(bottom: 16)),
],
);
},
),
);
},
),
),
if (subjectData.isEmpty) SliverEmptyWidget(message: translations.no_subjects),
const SliverPadding(padding: EdgeInsets.only(bottom: 16)),
],
);
},
),
);
},
);
}
}
38 changes: 18 additions & 20 deletions lib/ui/routes/subject_edit_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,24 @@ class _SubjectEditRouteState extends SpinningFabPage<SubjectEditRoute> {
rebuild();
},
enableShowcase: getPreference<bool>("showcase_subject_edit", true),
builder: Builder(
builder: (context) {
return SafeArea(
top: false,
bottom: false,
child: subjectData.isNotEmpty
? ReorderableListView(
padding: EdgeInsets.only(bottom: 88 + MediaQuery.paddingOf(context).bottom),
primary: true,
buildDefaultDragHandles: false,
onReorder: (int oldIndex, int newIndex) {
getCurrentYear().reorderSubjects(oldIndex, newIndex);
rebuild();
},
children: buildTiles(subjectData, childrenData),
)
: EmptyWidget(message: translations.no_subjects),
);
},
),
builder: (context) {
return SafeArea(
top: false,
bottom: false,
child: subjectData.isNotEmpty
? ReorderableListView(
padding: EdgeInsets.only(bottom: 88 + MediaQuery.paddingOf(context).bottom),
primary: true,
buildDefaultDragHandles: false,
onReorder: (int oldIndex, int newIndex) {
getCurrentYear().reorderSubjects(oldIndex, newIndex);
rebuild();
},
children: buildTiles(subjectData, childrenData),
)
: EmptyWidget(message: translations.no_subjects),
);
},
),
),
);
Expand Down

0 comments on commit be6a0c6

Please sign in to comment.