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

faculty notes changes to be merged #152

Merged
merged 3 commits into from
Jun 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,21 @@ class NotesDropdownField extends ConsumerStatefulWidget {
}

class _NotesDropdownFieldState extends ConsumerState<NotesDropdownField> {

@override

Widget build(BuildContext context) {
UserModel user = ref.watch(userModelProvider)!;
final _size = MediaQuery.of(context).size;
return Padding(
padding: !user.isStudent
? const EdgeInsets.fromLTRB(20, 11, 20, 11)
? const EdgeInsets.fromLTRB(10, 11, 10, 11)
: EdgeInsets.fromLTRB(15, 0, 15, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (user.isStudent)
SizedBox(
// width: _size.width*0.5,
height: 20,
child: Align(
alignment: Alignment.bottomLeft,
Expand Down
262 changes: 154 additions & 108 deletions lib/new_ui/screens/notes_screen/widgets/notes_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:tsec_app/models/class_model/class_model.dart';
import 'package:tsec_app/models/notes_model/notes_model.dart';
import 'package:tsec_app/models/subject_model/subject_model.dart';
import 'package:tsec_app/models/user_model/user_model.dart';
import 'package:tsec_app/new_ui/colors.dart';
import 'package:tsec_app/new_ui/screens/notes_screen/widgets/download_button.dart';
import 'package:tsec_app/new_ui/screens/notes_screen/widgets/notes_dropdown_field.dart';
import 'package:tsec_app/new_ui/screens/notes_screen/widgets/notes_text_field.dart';
Expand Down Expand Up @@ -181,6 +182,7 @@ class _NotesModalState extends ConsumerState<NotesModal> {
evenOrOddSem() == "even_sem" ? semData.even_sem : semData.odd_sem;

final scrollController = ScrollController();
final _size = MediaQuery.of(context).size;

return Scaffold(
appBar: AppBar(
Expand Down Expand Up @@ -265,7 +267,7 @@ class _NotesModalState extends ConsumerState<NotesModal> {
? Row(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * .39,
width: MediaQuery.of(context).size.width * .4,
child: NotesDropdownField(
editMode: true,
label: "Branch",
Expand All @@ -289,7 +291,7 @@ class _NotesModalState extends ConsumerState<NotesModal> {
),
),
SizedBox(
width: MediaQuery.of(context).size.width * .3,
width: MediaQuery.of(context).size.width * .26,
child: NotesDropdownField(
editMode: true,
label: "Year",
Expand All @@ -313,7 +315,7 @@ class _NotesModalState extends ConsumerState<NotesModal> {
),
),
SizedBox(
width: MediaQuery.of(context).size.width * .24,
width: MediaQuery.of(context).size.width * .25,
child: NotesDropdownField(
editMode: year != null && branch != null,
label: "Div",
Expand Down Expand Up @@ -415,35 +417,42 @@ class _NotesModalState extends ConsumerState<NotesModal> {
),
// widget.note != null
// ? SizedBox(
SizedBox(
Container(
height: 300,
decoration: BoxDecoration(
color: commonbgLightblack,
borderRadius: BorderRadius.circular(10), // Circular border radius
),
child: attachments.isEmpty
? Center(
child: Text(
"No attachments added",
style: TextStyle(color: Colors.grey),
),
)
:Scrollbar(
controller: scrollController,
thumbVisibility: true,
child: GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1, // number of items in each row
mainAxisSpacing: 15.0, // spacing between rows
crossAxisSpacing: 8.0, // spacing between columns
childAspectRatio: 35 / 9,
:Padding(
padding: const EdgeInsets.all(8),
child: Scrollbar(
controller: scrollController,
thumbVisibility: true,
child: GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1, // number of items in each row
mainAxisSpacing: 15.0, // spacing between rows
crossAxisSpacing: 8.0, // spacing between columns
childAspectRatio: 35 / 9,
),
itemCount: attachments.length,
itemBuilder: (context, index) {
return DownloadButton(
key: ValueKey(attachments[index]),
url: attachments[index],
removeFile: () {
deselectFile(index);
},
);
},
),
itemCount: attachments.length,
itemBuilder: (context, index) {
return DownloadButton(
key: ValueKey(attachments[index]),
url: attachments[index],
removeFile: () {
deselectFile(index);
},
);
},
),
),

Expand Down Expand Up @@ -522,106 +531,143 @@ class _NotesModalState extends ConsumerState<NotesModal> {
),
),
SizedBox(
height: 1,
),
// !user.isStudent
// ? Row(
// mainAxisAlignment: MainAxisAlignment.end,
// children: [
// Padding(
// padding:
// const EdgeInsets.fromLTRB(20, 11, 20, 11),
// child: ElevatedButton(
// style: ButtonStyle(
// backgroundColor:
// MaterialStateProperty.all<Color>(
// Theme.of(context)
// .colorScheme
// .onBackground),
// // You can customize other properties as needed
// // textColor, elevation, padding, shape, etc.
// ),
// onPressed: () async {
// await pickFiles();
// },
// child: Text('Attach',
// style: Theme.of(context)
// .textTheme
// .headlineMedium),
// ),
// ),
// ],
// )
// : Container(),

const SizedBox(
height: 10,
),
!user.isStudent
? Row(
mainAxisAlignment: MainAxisAlignment.end,
? Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(width: _size.width*0.9,),
Padding(
padding:
const EdgeInsets.fromLTRB(20, 11, 20, 11),
child: ElevatedButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(
Theme.of(context)
.colorScheme
.onBackground),
// You can customize other properties as needed
// textColor, elevation, padding, shape, etc.
const EdgeInsets.fromLTRB(10, 11, 5, 11),
child: Container(
width: _size.width*.5,
child: ElevatedButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(
Theme.of(context)
.colorScheme
.onBackground),
// You can customize other properties as needed
// textColor, elevation, padding, shape, etc.
),
onPressed: () async {
await pickFiles();
},
child: Text('Attach',
style: Theme.of(context)
.textTheme
.headlineMedium),
),
),
),
Padding(
padding: const EdgeInsets.all(5.0),
child: Container(
width: _size.width*.5,
child: ElevatedButton(

style: ButtonStyle(

backgroundColor:
MaterialStateProperty.all<Color>(
Theme.of(context)
.colorScheme
.tertiaryContainer),

// You can customize other properties as needed
// textColor, elevation, padding, shape, etc.
),
onPressed: () {
debugPrint(
"inside notes modal clicked note id: ${widget.note?.id}");
widget.uploadNoteCallback(
newAttachments,
deletedAttachments,
attachments
.where((file) =>
file.startsWith("http"))
.toList(),
widget.note?.id,
titleController.text,
descriptionController.text,
subject,
branch,
division,
year);
},
child: Text(
widget.note == null ? 'Upload' : 'Save',
style: Theme.of(context)
.textTheme
.headlineMedium),
),
onPressed: () async {
await pickFiles();
},
child: Text('Attach',
style: Theme.of(context)
.textTheme
.headlineMedium),
),
),
],
)
: Container(),
const SizedBox(
height: 10,
),
!user.isStudent
? Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
widget.note != null
? Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(
Theme.of(context)
.colorScheme
.error),
padding: const EdgeInsets.all(5.0),
child: Container(
width: _size.width*.5,
child: ElevatedButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(
Theme.of(context)
.colorScheme
.error),
),
onPressed: () async {
ref
.read(notesProvider.notifier)
.deleteNote(
widget.note!.id!, context);
widget.action.call();
},
child: Text('Delete',
style: Theme.of(context)
.textTheme
.headlineMedium),
),
onPressed: () async {
ref
.read(notesProvider.notifier)
.deleteNote(
widget.note!.id!, context);
widget.action.call();
},
child: Text('Delete',
style: Theme.of(context)
.textTheme
.headlineMedium),
),
)
: Container(),
Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(
Theme.of(context)
.colorScheme
.tertiaryContainer),
// You can customize other properties as needed
// textColor, elevation, padding, shape, etc.
),
onPressed: () {
debugPrint(
"inside notes modal clicked note id: ${widget.note?.id}");
widget.uploadNoteCallback(
newAttachments,
deletedAttachments,
attachments
.where((file) =>
file.startsWith("http"))
.toList(),
widget.note?.id,
titleController.text,
descriptionController.text,
subject,
branch,
division,
year);
},
child: Text(
widget.note == null ? 'Upload' : 'Save',
style: Theme.of(context)
.textTheme
.headlineMedium),
),
),
],
)
: Container(),
Expand Down
Loading