From 061d3f9e93399ffa34421e1e5d93838a58fcbc47 Mon Sep 17 00:00:00 2001 From: Bengisu Takkin <63921045+Brunettow@users.noreply.github.com> Date: Mon, 25 Dec 2023 21:31:31 +0300 Subject: [PATCH] orcid input field implemented & provider implemented (#722) --- .../lib/providers/settings_provider.dart | 5 +- .../widgets/account_settings_form.dart | 47 +++++++++++++++---- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/project/FrontEnd/collaborative_science_platform/lib/providers/settings_provider.dart b/project/FrontEnd/collaborative_science_platform/lib/providers/settings_provider.dart index ab465492..eba3c3a6 100644 --- a/project/FrontEnd/collaborative_science_platform/lib/providers/settings_provider.dart +++ b/project/FrontEnd/collaborative_science_platform/lib/providers/settings_provider.dart @@ -32,7 +32,7 @@ class SettingsProvider with ChangeNotifier { } } - Future changePreferences(User? user, String bio, bool sendNotification, bool showActivity) async { + Future changePreferences(User? user, String bio, bool sendNotification, bool showActivity, String orcid) async { final Map header = { "Accept": "application/json", "content-type": "application/json", @@ -41,7 +41,8 @@ class SettingsProvider with ChangeNotifier { final String body = json.encode({ 'bio': bio, 'email_notification_preference': sendNotification, - 'show_activity_preference': showActivity + 'show_activity_preference': showActivity, + 'orcid' : orcid ?? "", }); try { final response = await http.put( diff --git a/project/FrontEnd/collaborative_science_platform/lib/screens/profile_page/widgets/account_settings_form.dart b/project/FrontEnd/collaborative_science_platform/lib/screens/profile_page/widgets/account_settings_form.dart index be63afb3..8b1df55e 100644 --- a/project/FrontEnd/collaborative_science_platform/lib/screens/profile_page/widgets/account_settings_form.dart +++ b/project/FrontEnd/collaborative_science_platform/lib/screens/profile_page/widgets/account_settings_form.dart @@ -8,6 +8,7 @@ import 'package:collaborative_science_platform/screens/profile_page/widgets/chan import 'package:collaborative_science_platform/utils/colors.dart'; import 'package:collaborative_science_platform/utils/responsive/responsive.dart'; import 'package:collaborative_science_platform/utils/text_styles.dart'; +import 'package:collaborative_science_platform/widgets/app_text_field.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -24,9 +25,11 @@ class _AccountSettingsFormState extends State { final passwordController = TextEditingController(); final aboutMeController = TextEditingController(); + final orcidController = TextEditingController(); final passwordFocusNode = FocusNode(); final aboutMeFocusNode = FocusNode(); + final orcidFocusNode = FocusNode(); bool isSwitched = false; bool isSwitched2 = false; @@ -90,7 +93,7 @@ class _AccountSettingsFormState extends State { final User? user = Provider.of(context, listen: false).user; final settingsProvider = Provider.of(context, listen: false); await settingsProvider.changePreferences( - user, aboutMeController.text, isSwitched, isSwitched2); + user, aboutMeController.text, isSwitched, isSwitched2, orcidController.text); error = false; message = "Changed Successfully."; } catch (e) { @@ -106,19 +109,45 @@ class _AccountSettingsFormState extends State { final User? user = Provider.of(context).user; return Container( padding: const EdgeInsets.symmetric(horizontal: 16.0), - width: Responsive.getGenericPageWidth(context), + width: Responsive.getGenericPageWidth(context) / 1.2, child: Column( children: [ - const SizedBox(height: 10), + const SizedBox(height: 14), const Row( mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - SelectableText('About', style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500)), + SelectableText('About', + style: + TextStyle(color: Colors.black, fontWeight: FontWeight.bold, fontSize: 16.0)), ], ), - const SizedBox(height: 10), + const SizedBox(height: 8), AboutMeEdit(aboutMeController), - const Divider(height: 40.0), + const SizedBox(height: 14.0), + // const Divider(height: 40.0), + Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text("Add your ORCID", + style: + TextStyle(color: Colors.black, fontWeight: FontWeight.bold, fontSize: 16.0)), + const SizedBox(height: 10.0), + AppTextField( + controller: orcidController, + focusNode: orcidFocusNode, + hintText: 'Example: 0000-0002-4940-348X', + obscureText: false, + color: error && orcidController.text.isEmpty + ? AppColors.dangerColor + : AppColors.primaryColor, + prefixIcon: const Icon(Icons.edit), + height: 64.0, + onChanged: (_) {}, + ), + ], + ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -179,10 +208,12 @@ class _AccountSettingsFormState extends State { ), ), ), - const SizedBox(height: 10), Text(message), const Divider(height: 40.0), - Container( + const Text("or", + style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold, fontSize: 16.0)), + const SizedBox(height: 10.0), + SizedBox( width: 400, child: MouseRegion( cursor: SystemMouseCursors.click,