Skip to content

Commit

Permalink
Merge pull request #260 from Eldar2021/ai/fix-bugs
Browse files Browse the repository at this point in the history
Fixed BottomNav always show & Fixed Settings twice navigation pop & Fixed onTap juz item
  • Loading branch information
Eldar2021 authored Nov 5, 2024
2 parents c227ee4 + d252e2f commit 19e967e
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 94 deletions.
14 changes: 13 additions & 1 deletion app/lib/config/router/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ final class AppRouter {
builder: (context, state) => const DevModeView(),
),
StatefulShellRoute.indexedStack(
builder: (context, state, navigationShell) => MainView(navigationShell),
builder: (context, state, navigationShell) {
return MainView(navigationShell);
},
branches: [
StatefulShellBranch(
navigatorKey: _sectionNavigatorKey1,
Expand Down Expand Up @@ -124,11 +126,13 @@ final class AppRouter {
GoRoute(
path: hatim,
name: hatim,
parentNavigatorKey: rootNavigatorKey,
builder: (context, state) => const HatimView(),
routes: [
GoRoute(
path: '$hatimRead/:isHatim/:pages',
name: hatimRead,
parentNavigatorKey: rootNavigatorKey,
builder: (context, state) {
final args = ParseParams.parseRead(state.pathParameters);
return ReadView(args.$1, isHatim: args.$2);
Expand All @@ -139,6 +143,7 @@ final class AppRouter {
GoRoute(
path: settingsPage,
name: settingsPage,
parentNavigatorKey: rootNavigatorKey,
builder: (context, state) => const SettingsView(),
routes: settingsSubRoutes,
),
Expand All @@ -150,6 +155,7 @@ final class AppRouter {
GoRoute(
path: '$read/:isHatim/:pages',
name: read,
parentNavigatorKey: rootNavigatorKey,
builder: (context, state) {
final args = ParseParams.parseRead(state.pathParameters);
return ReadView(args.$1, isHatim: args.$2);
Expand All @@ -163,31 +169,37 @@ final class AppRouter {
GoRoute(
path: genderSettings,
name: genderSettings,
parentNavigatorKey: rootNavigatorKey,
builder: (context, state) => const GenderSettingView(),
),
GoRoute(
path: langSettings,
name: langSettings,
parentNavigatorKey: rootNavigatorKey,
builder: (context, state) => const LangSettingsView(),
),
GoRoute(
path: themeSettings,
name: themeSettings,
parentNavigatorKey: rootNavigatorKey,
builder: (context, state) => const ThemeSettingsView(),
),
GoRoute(
path: aboutUs,
name: aboutUs,
parentNavigatorKey: rootNavigatorKey,
builder: (context, state) => const AboutUsVuew(),
),
GoRoute(
path: contactUs,
name: contactUs,
parentNavigatorKey: rootNavigatorKey,
builder: (context, state) => const ContactUsView(),
),
GoRoute(
path: developers,
name: developers,
parentNavigatorKey: rootNavigatorKey,
builder: (context, state) => const DevelopersView(),
),
];
Expand Down
212 changes: 125 additions & 87 deletions app/lib/modules/hatim/presentation/widgets/hatim_juz_list_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class HatimJuzListBuilder extends StatelessWidget {
@override
Widget build(BuildContext context) {
final completedItems = items.where((item) => [20, 21, 23].contains(item.done)).length;

final gaugeValue = (completedItems / 30) * 100;

return Padding(
padding: const EdgeInsets.fromLTRB(14, 0, 14, 0),
child: SingleChildScrollView(
Expand Down Expand Up @@ -86,94 +84,16 @@ class HatimJuzListBuilder extends StatelessWidget {
shrinkWrap: true,
itemBuilder: (BuildContext context, int index) {
final item = items[index];

final endAngleTodo = (item.toDo / 20) * 100;

final endAngleDone = (item.done / 20) * 100;

final endAngleInProgress = (item.inProgress / 20) * 100;

return InkWell(
onTap: () async {
MqAnalytic.track(
AnalyticKey.selectHatimJuz,
params: {'juzId': item.id},
);
final bloc = context.read<HatimBloc>();

await Navigator.push<void>(
context,
MaterialPageRoute<void>(
builder: (BuildContext context) => BlocProvider.value(
value: bloc..add(GetHatimJuzPagesEvent(item.id)),
child: HatimJusSelectPagesView(hatimJusEntity: item),
),
),
);
bloc.add(const ResetJuzPagesEvent());
},
child: SfRadialGauge(
key: Key(MqKeys.hatimJuzIndex(index)),
axes: <RadialAxis>[
RadialAxis(
startAngle: 0,
endAngle: 0,
showTicks: false,
showLabels: false,
axisLineStyle: AxisLineStyle(thickness: 2, color: const Color(0xffFFDEEA).withOpacity(0.5)),
pointers: <GaugePointer>[
RangePointer(
value: endAngleTodo,
width: 0.03,
sizeUnit: GaugeSizeUnit.factor,
cornerStyle: CornerStyle.startCurve,
color: const Color(0xffF6684E),
),
],
),
RadialAxis(
startAngle: 0,
endAngle: 0,
showTicks: false,
showLabels: false,
radiusFactor: 0.85,
axisLineStyle: AxisLineStyle(thickness: 2, color: const Color(0xffFFDEEA).withOpacity(0.4)),
pointers: <GaugePointer>[
RangePointer(
value: endAngleInProgress,
width: 0.03,
sizeUnit: GaugeSizeUnit.factor,
cornerStyle: CornerStyle.startCurve,
color: const Color.fromARGB(255, 232, 168, 192),
),
],
),
RadialAxis(
startAngle: 0,
endAngle: 0,
showTicks: false,
radiusFactor: 0.75,
showLabels: false,
axisLineStyle: AxisLineStyle(thickness: 2, color: const Color(0xffFFDEEA).withOpacity(0.4)),
pointers: <GaugePointer>[
RangePointer(
value: endAngleDone,
width: 0.03,
sizeUnit: GaugeSizeUnit.factor,
cornerStyle: CornerStyle.startCurve,
color: const Color(0xffA851FA),
),
],
annotations: <GaugeAnnotation>[
GaugeAnnotation(
positionFactor: 0.7,
angle: 90,
widget: JuzAnnotationWidget(item: item),
),
],
),
],
),
return HatimJuzItemWidget(
endAngleTodo: endAngleTodo,
endAngleInProgress: endAngleInProgress,
endAngleDone: endAngleDone,
item: item,
index: index,
onTap: () => _onTap(item, context),
);
},
),
Expand All @@ -183,4 +103,122 @@ class HatimJuzListBuilder extends StatelessWidget {
),
);
}

Future<void> _onTap(HatimJusEntity item, BuildContext context) async {
MqAnalytic.track(
AnalyticKey.selectHatimJuz,
params: {'juzId': item.id},
);
final bloc = context.read<HatimBloc>();

await Navigator.push<void>(
context,
MaterialPageRoute<void>(
builder: (BuildContext context) => BlocProvider.value(
value: bloc..add(GetHatimJuzPagesEvent(item.id)),
child: HatimJusSelectPagesView(hatimJusEntity: item),
),
),
);
bloc.add(const ResetJuzPagesEvent());
}
}

class HatimJuzItemWidget extends StatelessWidget {
const HatimJuzItemWidget({
required this.endAngleTodo,
required this.endAngleInProgress,
required this.endAngleDone,
required this.item,
required this.onTap,
required this.index,
super.key,
});

final double endAngleTodo;
final double endAngleInProgress;
final double endAngleDone;
final HatimJusEntity item;
final void Function() onTap;
final int index;

@override
Widget build(BuildContext context) {
return SfRadialGauge(
axes: <RadialAxis>[
RadialAxis(
startAngle: 0,
endAngle: 0,
showTicks: false,
showLabels: false,
axisLineStyle: AxisLineStyle(
thickness: 2,
color: const Color(0xffFFDEEA).withOpacity(0.5),
),
pointers: <GaugePointer>[
RangePointer(
value: endAngleTodo,
width: 0.03,
sizeUnit: GaugeSizeUnit.factor,
cornerStyle: CornerStyle.startCurve,
color: const Color(0xffF6684E),
),
],
),
RadialAxis(
startAngle: 0,
endAngle: 0,
showTicks: false,
showLabels: false,
radiusFactor: 0.85,
axisLineStyle: AxisLineStyle(
thickness: 2,
color: const Color(0xffFFDEEA).withOpacity(0.4),
),
pointers: <GaugePointer>[
RangePointer(
value: endAngleInProgress,
width: 0.03,
sizeUnit: GaugeSizeUnit.factor,
cornerStyle: CornerStyle.startCurve,
color: const Color.fromARGB(255, 232, 168, 192),
),
],
),
RadialAxis(
startAngle: 0,
endAngle: 0,
showTicks: false,
radiusFactor: 0.75,
showLabels: false,
axisLineStyle: AxisLineStyle(
thickness: 2,
color: const Color(0xffFFDEEA).withOpacity(0.4),
),
pointers: <GaugePointer>[
RangePointer(
value: endAngleDone,
width: 0.03,
sizeUnit: GaugeSizeUnit.factor,
cornerStyle: CornerStyle.startCurve,
color: const Color(0xffA851FA),
),
],
annotations: <GaugeAnnotation>[
GaugeAnnotation(
widget: Center(
child: InkWell(
onTap: onTap,
child: JuzAnnotationWidget(
key: Key(MqKeys.hatimJuzIndex(index)),
item: item,
),
),
),
),
],
),
],
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class JuzAnnotationWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'${item.number}-${context.l10n.juz}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ProgressRowWidget extends StatelessWidget {
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
RichText(
textAlign: TextAlign.center,
Expand Down
12 changes: 6 additions & 6 deletions app/lib/modules/settings/presentation/view/settings_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SettingsView extends StatelessWidget {
),
onTap: () {
MqAnalytic.track(AnalyticKey.goGenderPage);
context.goNamed(AppRouter.genderSettings);
context.pushNamed(AppRouter.genderSettings);
},
),
ListTile(
Expand All @@ -59,7 +59,7 @@ class SettingsView extends StatelessWidget {
),
onTap: () {
MqAnalytic.track(AnalyticKey.selectLanguage);
context.goNamed(AppRouter.langSettings);
context.pushNamed(AppRouter.langSettings);
},
),
ListTile(
Expand All @@ -68,7 +68,7 @@ class SettingsView extends StatelessWidget {
trailing: const Icon(Icons.arrow_forward_ios),
onTap: () {
MqAnalytic.track(AnalyticKey.goThemePage);
context.goNamed(AppRouter.themeSettings);
context.pushNamed(AppRouter.themeSettings);
},
),
ListTile(
Expand All @@ -77,7 +77,7 @@ class SettingsView extends StatelessWidget {
trailing: const Icon(Icons.arrow_forward_ios),
onTap: () {
MqAnalytic.track(AnalyticKey.goAboutUsPage);
context.goNamed(AppRouter.aboutUs);
context.pushNamed(AppRouter.aboutUs);
},
),
ListTile(
Expand All @@ -86,7 +86,7 @@ class SettingsView extends StatelessWidget {
trailing: const Icon(Icons.arrow_forward_ios),
onTap: () {
MqAnalytic.track(AnalyticKey.goContactUsPage);
context.goNamed(AppRouter.contactUs);
context.pushNamed(AppRouter.contactUs);
},
),
ListTile(
Expand All @@ -95,7 +95,7 @@ class SettingsView extends StatelessWidget {
trailing: const Icon(Icons.arrow_forward_ios),
onTap: () {
MqAnalytic.track(AnalyticKey.goDevelopersPage);
context.goNamed(AppRouter.developers);
context.pushNamed(AppRouter.developers);
},
),
ListTile(
Expand Down

0 comments on commit 19e967e

Please sign in to comment.