Skip to content

Commit

Permalink
orcid input field implemented & provider implemented (#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brunettow authored Dec 25, 2023
1 parent 27eafe9 commit 061d3f9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SettingsProvider with ChangeNotifier {
}
}

Future<void> changePreferences(User? user, String bio, bool sendNotification, bool showActivity) async {
Future<void> changePreferences(User? user, String bio, bool sendNotification, bool showActivity, String orcid) async {
final Map<String, String> header = {
"Accept": "application/json",
"content-type": "application/json",
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -24,9 +25,11 @@ class _AccountSettingsFormState extends State<AccountSettingsForm> {

final passwordController = TextEditingController();
final aboutMeController = TextEditingController();
final orcidController = TextEditingController();

final passwordFocusNode = FocusNode();
final aboutMeFocusNode = FocusNode();
final orcidFocusNode = FocusNode();

bool isSwitched = false;
bool isSwitched2 = false;
Expand Down Expand Up @@ -90,7 +93,7 @@ class _AccountSettingsFormState extends State<AccountSettingsForm> {
final User? user = Provider.of<Auth>(context, listen: false).user;
final settingsProvider = Provider.of<SettingsProvider>(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) {
Expand All @@ -106,19 +109,45 @@ class _AccountSettingsFormState extends State<AccountSettingsForm> {
final User? user = Provider.of<Auth>(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: [
Expand Down Expand Up @@ -179,10 +208,12 @@ class _AccountSettingsFormState extends State<AccountSettingsForm> {
),
),
),
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,
Expand Down

0 comments on commit 061d3f9

Please sign in to comment.