Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New date picker #17

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions lib/config/routes.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import 'dart:async';

import 'package:flutter/cupertino.dart';

import 'package:go_router/go_router.dart';

import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/pages/archive/archive.dart';
import 'package:fluffychat/pages/chat/chat.dart';
Expand Down Expand Up @@ -42,6 +38,9 @@ import 'package:fluffychat/widgets/layouts/empty_page.dart';
import 'package:fluffychat/widgets/layouts/two_column_layout.dart';
import 'package:fluffychat/widgets/log_view.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'package:flutter/cupertino.dart';
import 'package:go_router/go_router.dart';

import '../pangea/pages/analytics/class_analytics/class_analytics.dart';
import '../pangea/pages/analytics/class_list/class_list.dart';

Expand Down Expand Up @@ -109,6 +108,16 @@ abstract class AppRoutes {
const LogViewer(),
),
),
// #Pangea
GoRoute(
path: '/user_age',
pageBuilder: (context, state) => defaultPageBuilder(
context,
const PUserAge(),
),
redirect: loggedOutRedirect,
),
// Pangea#
ShellRoute(
pageBuilder: (context, state, child) => defaultPageBuilder(
context,
Expand Down Expand Up @@ -160,14 +169,6 @@ abstract class AppRoutes {
),
routes: [
// #Pangea
GoRoute(
path: 'user_age',
pageBuilder: (context, state) => defaultPageBuilder(
context,
const PUserAge(),
),
redirect: loggedOutRedirect,
),
GoRoute(
path: 'mylearning',
pageBuilder: (context, state) => defaultPageBuilder(
Expand Down
7 changes: 3 additions & 4 deletions lib/pangea/guard/p_vguard.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import 'dart:async';

import 'package:fluffychat/widgets/matrix.dart';
import 'package:flutter/material.dart';

import 'package:go_router/go_router.dart';

import 'package:fluffychat/widgets/matrix.dart';
import '../controllers/pangea_controller.dart';

class PAuthGaurd {
Expand All @@ -19,7 +18,7 @@ class PAuthGaurd {
final bool setDob = await pController!
.userController.isUserDataAvailableAndDateOfBirthSet;
if (Matrix.of(context).client.isLogged()) {
return !setDob ? '/rooms/user_age' : '/rooms';
return !setDob ? '/user_age' : '/rooms';
}
return null;
} else {
Expand All @@ -39,7 +38,7 @@ class PAuthGaurd {
return !Matrix.of(context).client.isLogged()
? '/home'
: !setDob
? '/rooms/user_age'
? '/user_age'
: null;
} else {
debugPrint("controller is null in pguard check");
Expand Down
62 changes: 46 additions & 16 deletions lib/pangea/pages/p_user_age/p_user_age_view.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:fluffychat/pangea/pages/p_user_age/p_user_age.dart';
import 'package:flutter/material.dart';

import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:intl/intl.dart';
import 'package:syncfusion_flutter_datepicker/datepicker.dart';

import 'package:fluffychat/pangea/pages/p_user_age/p_user_age.dart';
import '../../../widgets/layouts/login_scaffold.dart';

class PUserAgeView extends StatelessWidget {
Expand All @@ -12,7 +12,6 @@ class PUserAgeView extends StatelessWidget {

@override
Widget build(BuildContext context) {
controller.dobController.text = "";
return LoginScaffold(
appBar: AppBar(
automaticallyImplyLeading: !controller.loading,
Expand Down Expand Up @@ -45,21 +44,52 @@ class PUserAgeView extends StatelessWidget {
controller.loading ? null : [AutofillHints.birthday],
validator: controller.dobFieldValidator,
onTap: () async {
final DateTime? pickedDate = await showDatePicker(
initialDatePickerMode: DatePickerMode.year,
showDialog(
context: context,
initialDate: controller.initialDate,
firstDate: DateTime(1940),
lastDate: DateTime.now(),
builder: (BuildContext context) {
return Center(
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25),
color: Theme.of(context).colorScheme.background,
),
padding: const EdgeInsets.all(12),
// height: 350,
width: 500,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Card(
child: SfDateRangePicker(
view: DateRangePickerView.month,
showNavigationArrow: true,
showActionButtons: true,
selectionMode:
DateRangePickerSelectionMode.single,
initialDisplayDate: controller.initialDate,
initialSelectedDate: controller.initialDate,
onSubmit: (val) {
final DateTime? pickedDate =
val as DateTime?;
if (pickedDate != null) {
controller.dobController.text =
DateFormat.yMd().format(pickedDate);
controller.error = null;
} else {
controller.error =
L10n.of(context)!.invalidDob;
}
Navigator.pop(context);
},
onCancel: () => Navigator.pop(context),
),
),
],
),
),
);
},
);

if (pickedDate != null) {
controller.dobController.text =
DateFormat.yMd().format(pickedDate);
controller.error = null;
} else {
controller.error = L10n.of(context)!.invalidDob;
}
},
// onChanged: (String newValue) {
// try {
Expand Down
23 changes: 11 additions & 12 deletions lib/widgets/matrix.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:collection/collection.dart';
import 'package:desktop_notifications/desktop_notifications.dart';
import 'package:fluffychat/pangea/controllers/pangea_controller.dart';
import 'package:fluffychat/pangea/utils/any_state_holder.dart';
import 'package:fluffychat/utils/client_manager.dart';
import 'package:fluffychat/utils/localized_exception_extension.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/utils/uia_request_manager.dart';
import 'package:fluffychat/utils/voip_plugin.dart';
import 'package:fluffychat/widgets/fluffy_chat_app.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:http/http.dart' as http;
Expand All @@ -19,14 +26,6 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:universal_html/html.dart' as html;
import 'package:url_launcher/url_launcher_string.dart';

import 'package:fluffychat/pangea/controllers/pangea_controller.dart';
import 'package:fluffychat/pangea/utils/any_state_holder.dart';
import 'package:fluffychat/utils/client_manager.dart';
import 'package:fluffychat/utils/localized_exception_extension.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/utils/uia_request_manager.dart';
import 'package:fluffychat/utils/voip_plugin.dart';
import 'package:fluffychat/widgets/fluffy_chat_app.dart';
import '../config/app_config.dart';
import '../config/setting_keys.dart';
import '../pages/key_verification/key_verification_dialog.dart';
Expand Down Expand Up @@ -354,7 +353,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
routeDestination = await pangeaController
.userController.isUserDataAvailableAndDateOfBirthSet
? '/rooms'
: "/rooms/user_age";
: "/user_age";
} else {
routeDestination = '/home';
}
Expand Down
20 changes: 14 additions & 6 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2047,26 +2047,34 @@ packages:
dependency: transitive
description:
name: syncfusion_flutter_core
sha256: "9f0a4593f7642b2f106e329734d0e5fc746baf8d0a59495eec586cd0d9ba7d02"
sha256: a2427697bfad5b611db78ea4c4daef82d3350b83c729a8dc37959662a31547f9
url: "https://pub.dev"
source: hosted
version: "22.2.12"
version: "23.2.7"
syncfusion_flutter_datepicker:
dependency: "direct main"
description:
name: syncfusion_flutter_datepicker
sha256: b3340a7786f674d18bd22c226358648985e7631734dfc4aae09fdcfb71c09156
url: "https://pub.dev"
source: hosted
version: "23.2.7"
syncfusion_flutter_xlsio:
dependency: "direct main"
description:
name: syncfusion_flutter_xlsio
sha256: "66b009fce91e10cfa5d9b3cdf2c4aa3fdf7430dab159626f4c67297638da2caf"
sha256: "84c771ce3684820e930d27604e801991efaa0e7a72ee1df4ba4c843258f16285"
url: "https://pub.dev"
source: hosted
version: "22.2.12"
version: "23.2.7"
syncfusion_officecore:
dependency: transitive
description:
name: syncfusion_officecore
sha256: "66d0a0faba40f043bba4ef102474213d3145ffeca2b3f2351a98c0cc10079c27"
sha256: a037c8a72748332ba28723eaed2fd1656b9acdaf03c23c6a08e87f7c31dbed18
url: "https://pub.dev"
source: hosted
version: "22.2.12"
version: "23.2.7"
synchronized:
dependency: transitive
description:
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ dependencies:
shared_preferences: ^2.2.0 # Pinned because https://github.com/flutter/flutter/issues/118401
slugify: ^2.0.0
swipe_to_action: ^0.2.0
syncfusion_flutter_xlsio: ^22.2.9
syncfusion_flutter_datepicker: ^23.2.7
syncfusion_flutter_xlsio: ^23.2.7
tor_detector_web: ^1.1.0
uni_links: ^0.5.1
unifiedpush: ^5.0.1
Expand Down
Loading