Skip to content

Commit

Permalink
Merge pull request #116 from krolmic/chore/graph-header-widget
Browse files Browse the repository at this point in the history
chore 🔧: add _GraphHeader
  • Loading branch information
krolmic authored Sep 2, 2024
2 parents 3b2d4ec + f443a72 commit d28021c
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 59 deletions.
63 changes: 4 additions & 59 deletions tracking_flutter/lib/graph/view/graph_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import 'package:tracking_app/shared/widgets/spacing.dart';
import 'package:tracking_app/update_mood/bloc/update_mood_bloc.dart';
import 'package:user_profile_repository/user_profile_repository.dart';

part 'widgets/graph_header.dart';
part 'widgets/graph_settings.dart';
part 'widgets/line_graph_explanation.dart';
part 'widgets/months_selection.dart';
Expand Down Expand Up @@ -101,30 +102,6 @@ class GraphScreen extends StatelessWidget {
class _GraphView extends StatelessWidget {
const _GraphView();

Future<void> _showSettingsDialog(
BuildContext context,
) {
return showDialog<void>(
context: context,
builder: (dialogContext) {
final translations = AppLocalizations.of(context)!;

return AppDialog(
title: translations.display,
body: BlocProvider.value(
value: BlocProvider.of<GraphBloc>(context),
child: const _GraphSettings(),
),
confirmButtonText: translations.ok,
onConfirm: () {
Navigator.of(dialogContext).pop();
},
buildCancelButton: false,
);
},
);
}

@override
Widget build(BuildContext context) {
final translations = AppLocalizations.of(context)!;
Expand All @@ -137,43 +114,11 @@ class _GraphView extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const VerticalSpacing.large(),
Padding(
padding: const EdgeInsets.symmetric(
const Padding(
padding: EdgeInsets.symmetric(
horizontal: horizontalPaddingSmall,
),
child: SizedBox(
height: 30,
child: Stack(
children: [
Positioned.fill(
child: Center(
child: Text(
dateTimeNow.year.toString(),
style: Theme.of(context).textTheme.headlineSmall,
),
),
),
Positioned.fill(
child: Align(
alignment: Alignment.centerRight,
child: IconButton(
padding: const EdgeInsets.symmetric(
horizontal: horizontalPaddingSmall,
),
color: AppColors.primarySwatch,
icon: Icon(
Iconsax.setting_4_outline,
size: Theme.of(context).appBarTheme.iconTheme!.size,
),
onPressed: () async {
await _showSettingsDialog(context);
},
),
),
),
],
),
),
child: _GraphHeader(),
),
const VerticalSpacing.medium(),
BlocBuilder<GraphBloc, GraphState>(
Expand Down
66 changes: 66 additions & 0 deletions tracking_flutter/lib/graph/view/widgets/graph_header.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
part of '../graph_screen.dart';

class _GraphHeader extends StatelessWidget {
const _GraphHeader();

Future<void> showSettingsDialog(
BuildContext context,
) {
return showDialog<void>(
context: context,
builder: (dialogContext) {
final translations = AppLocalizations.of(context)!;

return AppDialog(
title: translations.display,
body: BlocProvider.value(
value: BlocProvider.of<GraphBloc>(context),
child: const _GraphSettings(),
),
confirmButtonText: translations.ok,
onConfirm: () {
Navigator.of(dialogContext).pop();
},
buildCancelButton: false,
);
},
);
}

@override
Widget build(BuildContext context) {
return SizedBox(
height: 30,
child: Stack(
children: [
Positioned.fill(
child: Center(
child: Text(
DateTime.now().year.toString(),
style: Theme.of(context).textTheme.headlineSmall,
),
),
),
Positioned.fill(
child: Align(
alignment: Alignment.centerRight,
child: IconButton(
padding: const EdgeInsets.symmetric(
horizontal: horizontalPaddingSmall,
),
color: AppColors.primarySwatch,
icon: Icon(
Iconsax.setting_4_outline,
size: Theme.of(context).appBarTheme.iconTheme!.size,
),
onPressed: () async {
await showSettingsDialog(context);
},
),
),
),
],
),
);
}
}

0 comments on commit d28021c

Please sign in to comment.