diff --git a/lib/Components/side_drawer.dart b/lib/Components/side_drawer.dart index be08db0e..92f342d8 100644 --- a/lib/Components/side_drawer.dart +++ b/lib/Components/side_drawer.dart @@ -142,7 +142,11 @@ class _SideDrawerState extends State { ModulesPadding(line: 'Leave Module'), ModulesPadding(line: 'Placement Module'), ModulesPadding(line: 'Visitors Hostel Module'), - ModulesPadding(line: 'File Tracking Module'), + ModulesPadding( + line: 'File Tracking Module', + pageMover: '/compose_file', + isActive: true, + ), ], ), ) diff --git a/lib/api.dart b/lib/api.dart index 802bee2d..d9bf8365 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -1,9 +1,9 @@ //Server and local links String klocalLink = "127.0.0.1:8000"; -String kserverLink = "172.27.16.215:80"; +String kserverLink = "172.27.16.214:80"; //Login Service -String kAuthUrl = "172.27.16.215:80"; +String kAuthUrl = "172.27.16.214:80"; String kAuthLogin = "/api/auth/login/"; //Profile Service @@ -29,6 +29,9 @@ const kGymkhanaMemberRecords = '/api/gymkhana/members_record'; //HealthCentre String kHealthCentreStudent = "/healthcenter/api/student"; +//FileTracking +const kFileTracking = '/filetracking/'; + //------------Screens------------ //screens/Academic/Current_Semester diff --git a/lib/main.dart b/lib/main.dart index 9ca81ff8..2141b438 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -42,6 +42,7 @@ import 'package:fusion/screens/Healthcenter/viewschedule.dart'; import 'package:fusion/screens/Healthcenter/history.dart'; import 'package:fusion/screens/Healthcenter/HealthCenter.dart'; import 'package:fusion/services/service_locator.dart'; +import 'package:fusion/screens/File_Tracking/compose_file.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); @@ -60,7 +61,7 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { MediaQueryData windowData = - MediaQueryData.fromWindow(WidgetsBinding.instance.window); + MediaQueryData.fromWindow(WidgetsBinding.instance.window); windowData = windowData.copyWith( textScaleFactor: 1, ); @@ -71,6 +72,7 @@ class MyApp extends StatelessWidget { title: 'Fusion', debugShowCheckedModeBanner: false, theme: ThemeData( + // primarySwatch: Colors.blueGrey, // colorSchemeSeed: Color(0xFF2085D0), colorSchemeSeed: Color(0xFFF36C35), @@ -127,6 +129,7 @@ class MyApp extends StatelessWidget { '/health_center/feedback': (context) => FeedBack(), '/health_center/viewschedule': (context) => ViewSchedule(), '/health_center/history': (context) => History(), + '/compose_file': (context) => ComposeFile(), }, ), ); diff --git a/lib/models/file_tracking.dart b/lib/models/file_tracking.dart new file mode 100644 index 00000000..72f5b6ed --- /dev/null +++ b/lib/models/file_tracking.dart @@ -0,0 +1,47 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +class File { + late final String id; + late final String subject; + late final String description; + late final String upload_date; + late final String upload_file; + late final String is_read; + late final String designation_id; + late final String uploader_id; + + File( + {required this.id, + required this.subject, + required this.description, + required this.upload_date, + required this.upload_file, + required this.is_read, + required this.designation_id, + required this.uploader_id}); + + factory File.fromJson(Map json) { + return File( + id: json['id'], + subject: json['subject'], + description: json['description'], + upload_date: json['upload_date'], + upload_file: json['upload_file'], + is_read: json['is_read'], + designation_id: json['designation_id'], + uploader_id: json['uploader_id'], + ); + } + + dynamic toJson() => { + 'id': id, + 'subject': subject, + 'description': description, + 'upload_date': upload_date, + 'upload_file': upload_file, + 'is_read': is_read, + 'designation_id': designation_id, + 'uploader_id': uploader_id + }; +} diff --git a/lib/screens/File_Tracking/compose_file.dart b/lib/screens/File_Tracking/compose_file.dart new file mode 100644 index 00000000..a1a1d2f7 --- /dev/null +++ b/lib/screens/File_Tracking/compose_file.dart @@ -0,0 +1,325 @@ +// ignore_for_file: non_constant_identifier_names + +import 'dart:async'; +import 'dart:convert'; +import 'dart:developer'; +import 'package:fusion/constants.dart'; +import 'package:fusion/services/file_tracking_service.dart'; +import 'package:http/http.dart' as http; +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +import 'package:flutter/services.dart' show rootBundle; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/screens/File_Tracking/drafts_page.dart'; +import 'package:fusion/screens/File_Tracking/outbox.dart'; +import 'package:fusion/screens/File_Tracking/inbox.dart'; +import 'package:fusion/models/file_tracking.dart'; +import 'package:fusion/api.dart'; +import 'package:http/http.dart'; +import 'package:provider/provider.dart'; +// import 'package:csv/csv.dart'; + +//use this controller to get what the user has typed +TextEditingController title = TextEditingController(); +TextEditingController description = TextEditingController(); +TextEditingController create_as = TextEditingController(); +TextEditingController forward_to = TextEditingController(); +TextEditingController recievers_designation = TextEditingController(); +TextEditingController remarks = TextEditingController(); + +class ComposeFile extends StatefulWidget { + const ComposeFile({Key? key}) : super(key: key); + + @override + State createState() => _ComposeFileState(); +} + +class _ComposeFileState extends State { + final _composefile = GlobalKey(); + + @override + void initState() { + super.initState(); + } + + final ButtonStyle style = + ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 20)); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: Container( + child: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: SafeArea( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + + // child:Row( + children: [ + const SizedBox(height: 30), + + // Padding(padding:EdgeInsets.all(0)), + OutlinedButton( + style: style, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ComposeFile())); + }, + child: const Text('Compose'), + ), + + OutlinedButton( + style: style, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => DraftPage())); + }, + child: const Text('Drafts'), + ), + + OutlinedButton( + style: style, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => OutboxPage())); + }, + child: const Text('Outbox'), + ), + OutlinedButton( + style: style, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => InboxPage())); + }, + child: const Text('Inbox'), + ), + + //OutlinedButton( + //style: style, + //onPressed: () { + // Navigator.push(context, + // MaterialPageRoute(builder: (context) => const MobileScaffold())); + //}, + //child: const Text('Track'), + //), + ]), + Container( + child: Padding( + padding: const EdgeInsets.all(20.0), + // child: SingleChildScrollView( + // scrollDirection: Axis.vertical, + // child: SafeArea( + child: Form( + key: _composefile, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const SizedBox(height: 4), + + //title box + Text( + 'Title', + style: TextStyle(fontSize: 17), + ), + + const SizedBox(height: 8), + TextField( + controller: title, + decoration: InputDecoration( + hintText: 'Title', + border: const OutlineInputBorder(), + suffixIcon: IconButton( + onPressed: () { + // clear what's currently in the text box + title.clear(); + }, + icon: Icon(Icons.clear), + )), + ), + + const SizedBox(height: 15), + + //description box + Text( + 'Description', + style: TextStyle(fontSize: 17), + ), + + const SizedBox(height: 10), + TextField( + controller: description, + decoration: InputDecoration( + hintText: 'Description', + border: const OutlineInputBorder(), + suffixIcon: IconButton( + onPressed: () { + // clear what's currently in the text box + description.clear(); + }, + icon: Icon(Icons.clear), + )), + ), + + const SizedBox(height: 15), + + // create box + Text( + 'Create As', + style: TextStyle(fontSize: 17), + ), + + const SizedBox(height: 10), + TextField( + controller: create_as, + decoration: InputDecoration( + hintText: 'Create As', + border: const OutlineInputBorder(), + suffixIcon: IconButton( + onPressed: () { + // clear what's currently in the text box + create_as.clear(); + }, + icon: Icon(Icons.clear), + )), + ), + + const SizedBox(height: 15), + + // attach file + Text( + 'Attach Files(Maximum Size: 10MB)', + style: TextStyle(fontSize: 17), + ), + + const SizedBox(height: 10), + MaterialButton( + onPressed: () { + // _pickFile(); + }, + color: Colors.blue, + child: const Text( + 'Choose File', + style: TextStyle(color: Colors.white), + ), + ), + + const SizedBox(height: 15), + + // remarks + Text( + 'Remarks', + style: TextStyle(fontSize: 17), + ), + + const SizedBox(height: 10), + TextField( + controller: remarks, + decoration: InputDecoration( + hintText: 'Remarks', + border: const OutlineInputBorder(), + suffixIcon: IconButton( + onPressed: () { + // clear what's currently in the text box + remarks.clear(); + }, + icon: Icon(Icons.clear), + )), + ), + + const SizedBox(height: 15), + + //forward to + Text( + 'Forward To', + style: TextStyle(fontSize: 17), + ), + + const SizedBox(height: 10), + TextField( + controller: forward_to, + decoration: InputDecoration( + hintText: 'Forward To', + border: const OutlineInputBorder(), + suffixIcon: IconButton( + onPressed: () { + // clear what's currently in the text box + forward_to.clear(); + }, + icon: Icon(Icons.clear), + )), + ), + + const SizedBox(height: 15), + + //reciever's designation + Text( + 'Recievers Designation', + style: TextStyle(fontSize: 17), + ), + + const SizedBox(height: 10), + TextField( + controller: recievers_designation, + decoration: InputDecoration( + hintText: 'Recievers Designation', + border: const OutlineInputBorder(), + suffixIcon: IconButton( + onPressed: () { + // clear what's currently in the text box + recievers_designation.clear(); + }, + icon: Icon(Icons.clear), + )), + ), + + const SizedBox(height: 20), + + //send + Row(children: [ + MaterialButton( + onPressed: () {}, + color: Colors.blue, + child: Text( + "Save To draft", + style: TextStyle( + color: Colors.white), + )), + Padding( + padding: const EdgeInsets.fromLTRB( + 115, 0, 0, 0), + child: MaterialButton( + onPressed: () {}, + color: Colors.green, + child: const Text( + 'Send', + style: TextStyle( + color: Colors.white), + ), + ), + ) + ]), + ], + ), + ))) + ]), + )))); + } +} diff --git a/lib/screens/File_Tracking/drafts_page.dart b/lib/screens/File_Tracking/drafts_page.dart new file mode 100644 index 00000000..0a423149 --- /dev/null +++ b/lib/screens/File_Tracking/drafts_page.dart @@ -0,0 +1,223 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +// import 'package:flutter/services.dart' show rootBundle; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/screens/File_Tracking/compose_file.dart'; +import 'package:fusion/screens/File_Tracking/outbox.dart'; +import 'package:fusion/screens/File_Tracking/inbox.dart'; +// import 'package:fusion/screens/File_Tracking/drafts_page.dart'; + +class DraftPage extends StatefulWidget { + // const DraftPage({super.key}); + + @override + State createState() => _DraftPageState(); +} + +class _DraftPageState extends State { + final ButtonStyle style = + ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 20)); + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: Container( + child: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: SafeArea( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + + // child:Row( + children: [ + const SizedBox(height: 30), + + // Padding(padding:EdgeInsets.all(0)), + OutlinedButton( + style: style, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + const ComposeFile())); + }, + child: const Text('Compose'), + ), + + OutlinedButton( + style: style, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => DraftPage())); + }, + child: const Text('Drafts'), + ), + + OutlinedButton( + style: style, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => OutboxPage())); + }, + child: const Text('Outbox'), + ), + OutlinedButton( + style: style, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => InboxPage())); + }, + child: const Text('Inbox'), + ), + OutlinedButton( + style: style, + onPressed: () { + // Navigator.push(context, + // MaterialPageRoute(builder: (context) => const MobileScaffold())); + }, + child: const Text('Track'), + ), + ]), + Column( + children: [ + Padding( + padding: EdgeInsets.only( + left: 0, + bottom: 20, + top: 30, + right: 190), //apply padding to all four sides + child: Text( + 'Draft Files', + style: TextStyle( + color: Colors.black, + fontSize: 30.0, + ), + ), + ), + ListView.builder( + itemCount: 1, + shrinkWrap: true, + itemBuilder: (BuildContext, int index) => + Container( + width: MediaQuery.of(context).size.width, + padding: EdgeInsets.symmetric( + horizontal: 20.0, vertical: 15.0), + child: Card( + elevation: 25.0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(0.0)), + child: Container( + width: MediaQuery.of(context).size.width, + padding: EdgeInsets.symmetric( + horizontal: 10.0, vertical: 5.0), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Container( + width: 55.0, + height: 55.0, + color: Colors.blue, + child: CircleAvatar( + backgroundColor: + Colors.blue, + foregroundColor: + Colors.blue, + child: Icon( + Icons.folder, + size: 40, + color: Colors.white, + ))), + SizedBox(width: 6.0), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Text("Subject", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 20.0, + )), + const Divider( + height: 20, + thickness: 5, + indent: 20, + endIndent: 0, + color: Colors.black, + ), + Text("20BCS056-Student", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 13.0, + )), + ], + ), + ], + ), + // Container( + // alignment:Alignment.center, + // padding:EdgeInsets.symmetric(horizontal:10.0,vertical:10.0), + SizedBox(width: 6.0), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + TextButton( + style: TextButton.styleFrom( + backgroundColor: Colors.blue, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 0.0)), + ), + onPressed: () {}, + child: Text( + 'View', + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: 13.0, + fontStyle: FontStyle.normal, + ), + ), + ), + // Text(DateFormat('dd/MM/yy').format(DateTime.now())), + ], + ), + ], + ), + ), + ), + ), + ), + ], + ) + ]), + )))); + } +} diff --git a/lib/screens/File_Tracking/inbox.dart b/lib/screens/File_Tracking/inbox.dart new file mode 100644 index 00000000..9b7db9ac --- /dev/null +++ b/lib/screens/File_Tracking/inbox.dart @@ -0,0 +1,224 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +// import 'package:flutter/services.dart' show rootBundle; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/screens/File_Tracking/compose_file.dart'; +import 'package:fusion/screens/File_Tracking/outbox.dart'; +import 'package:fusion/screens/File_Tracking/drafts_page.dart'; + +// import 'package:fusion/screens/File_Tracking/drafts_page.dart'; + +class InboxPage extends StatefulWidget { + // const DraftPage({super.key}); + + @override + State createState() => _InboxPageState(); +} + +class _InboxPageState extends State { + final ButtonStyle style = + ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 20)); + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: Container( + child: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: SafeArea( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + + // child:Row( + children: [ + const SizedBox(height: 30), + + // Padding(padding:EdgeInsets.all(0)), + OutlinedButton( + style: style, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + const ComposeFile())); + }, + child: const Text('Compose'), + ), + + OutlinedButton( + style: style, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => DraftPage())); + }, + child: const Text('Drafts'), + ), + + OutlinedButton( + style: style, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => OutboxPage())); + }, + child: const Text('Outbox'), + ), + OutlinedButton( + style: style, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => OutboxPage())); + }, + child: const Text('Inbox'), + ), + OutlinedButton( + style: style, + onPressed: () { + // Navigator.push(context, + // MaterialPageRoute(builder: (context) => const MobileScaffold())); + }, + child: const Text('Track'), + ), + ]), + Column( + children: [ + Padding( + padding: EdgeInsets.only( + left: 0, + bottom: 20, + top: 30, + right: 190), //apply padding to all four sides + child: Text( + 'Received Files', + style: TextStyle( + color: Colors.black, + fontSize: 30.0, + ), + ), + ), + ListView.builder( + itemCount: 1, + shrinkWrap: true, + itemBuilder: (BuildContext, int index) => + Container( + width: MediaQuery.of(context).size.width, + padding: EdgeInsets.symmetric( + horizontal: 20.0, vertical: 15.0), + child: Card( + elevation: 25.0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(0.0)), + child: Container( + width: MediaQuery.of(context).size.width, + padding: EdgeInsets.symmetric( + horizontal: 10.0, vertical: 5.0), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Container( + width: 55.0, + height: 55.0, + color: Colors.blue, + child: CircleAvatar( + backgroundColor: + Colors.blue, + foregroundColor: + Colors.blue, + child: Icon( + Icons.folder, + size: 40, + color: Colors.white, + ))), + SizedBox(width: 6.0), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Text("Subject", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 20.0, + )), + const Divider( + height: 20, + thickness: 5, + indent: 20, + endIndent: 0, + color: Colors.black, + ), + Text("20BCS056-Student", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 13.0, + )), + ], + ), + ], + ), + // Container( + // alignment:Alignment.center, + // padding:EdgeInsets.symmetric(horizontal:10.0,vertical:10.0), + SizedBox(width: 6.0), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + TextButton( + style: TextButton.styleFrom( + backgroundColor: Colors.blue, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 0.0)), + ), + onPressed: () {}, + child: Text( + 'View', + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: 13.0, + fontStyle: FontStyle.normal, + ), + ), + ), + // Text(DateFormat('dd/MM/yy').format(DateTime.now())), + ], + ), + ], + ), + ), + ), + ), + ), + ], + ) + ]), + )))); + } +} diff --git a/lib/screens/File_Tracking/outbox.dart b/lib/screens/File_Tracking/outbox.dart new file mode 100644 index 00000000..e49ced54 --- /dev/null +++ b/lib/screens/File_Tracking/outbox.dart @@ -0,0 +1,226 @@ +import 'package:flutter/material.dart'; +import 'package:fusion/Components/appBar.dart'; +// import 'package:flutter/services.dart' show rootBundle; +import 'package:fusion/Components/side_drawer.dart'; +import 'package:fusion/screens/File_Tracking/compose_file.dart'; +import 'package:fusion/screens/File_Tracking/drafts_page.dart'; +import 'package:fusion/screens/File_Tracking/inbox.dart'; + +class OutboxPage extends StatefulWidget { + // const OutboxPage({super.key}); + + // final _textController = TextEditingController(); + + @override + State createState() => _OutboxPageState(); +} + +class _OutboxPageState extends State { + final _textController = TextEditingController(); + final ButtonStyle style = + ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 20)); + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: DefaultAppBar().buildAppBar(), + drawer: SideDrawer(), + body: Container( + child: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: SafeArea( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + + // child:Row( + children: [ + const SizedBox(height: 30), + + // Padding(padding:EdgeInsets.all(0)), + OutlinedButton( + style: style, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + const ComposeFile())); + }, + child: const Text('Compose'), + ), + + OutlinedButton( + style: style, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => DraftPage())); + }, + child: const Text('Drafts'), + ), + + OutlinedButton( + style: style, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => OutboxPage())); + }, + child: const Text('Outbox'), + ), + OutlinedButton( + style: style, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => InboxPage())); + }, + child: const Text('Inbox'), + ), + + OutlinedButton( + style: style, + onPressed: () { + // Navigator.push(context, + // MaterialPageRoute(builder: (context) => const MobileScaffold())); + }, + child: const Text('Track'), + ), + ]), + Column( + children: [ + Padding( + padding: EdgeInsets.only( + left: 0, + bottom: 20, + top: 30, + right: 190), //apply padding to all four sides + child: Text( + 'Sent Files', + style: TextStyle( + color: Colors.black, + fontSize: 30.0, + ), + ), + ), + ListView.builder( + itemCount: 4, + shrinkWrap: true, + itemBuilder: (BuildContext, int index) => + Container( + width: MediaQuery.of(context).size.width, + padding: EdgeInsets.symmetric( + horizontal: 20.0, vertical: 15.0), + child: Card( + elevation: 25.0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(0.0)), + child: Container( + width: MediaQuery.of(context).size.width, + padding: EdgeInsets.symmetric( + horizontal: 10.0, vertical: 5.0), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Container( + width: 55.0, + height: 55.0, + color: Colors.blue, + child: CircleAvatar( + backgroundColor: + Colors.blue, + foregroundColor: + Colors.blue, + child: Icon( + Icons.folder, + size: 40, + color: Colors.white, + ))), + SizedBox(width: 6.0), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Text("Subject", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 20.0, + )), + const Divider( + height: 20, + thickness: 5, + indent: 20, + endIndent: 0, + color: Colors.black, + ), + Text("20BCS056-Student", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 13.0, + )), + ], + ), + ], + ), + // Container( + // alignment:Alignment.center, + // padding:EdgeInsets.symmetric(horizontal:10.0,vertical:10.0), + SizedBox(width: 6.0), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + TextButton( + style: TextButton.styleFrom( + backgroundColor: Colors.blue, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 0.0)), + ), + onPressed: () {}, + child: Text( + 'View', + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: 13.0, + fontStyle: FontStyle.normal, + ), + ), + ), + // Text(DateFormat('dd/MM/yy').format(DateTime.now())), + ], + ), + ], + ), + ), + ), + ), + ), + ], + ) + ]), + )))); + } +} diff --git a/lib/services/file_tracking_service.dart b/lib/services/file_tracking_service.dart new file mode 100644 index 00000000..1e8b395d --- /dev/null +++ b/lib/services/file_tracking_service.dart @@ -0,0 +1,47 @@ +import 'package:fusion/api.dart'; +import 'package:fusion/constants.dart'; +import 'package:http/http.dart' as http; +import 'dart:collection'; +import 'dart:convert'; +import 'package:flutter/material.dart'; +import 'package:fusion/models/file_tracking.dart'; + +class FileTrackingService extends ChangeNotifier { + FileTrackingService() { + this.fetchFiles(); + } + + List _files = []; + + UnmodifiableListView get allFiles => UnmodifiableListView(_files); + + void compose_file(File file) async { + final response = await http.post( + "http://127.0.0.1:8000/filetracking/" as Uri, + headers: {"Content-Type": "application/json"}, + body: json.encode(file), + ); + if (response.statusCode == 201) { + file.id = json.decode(response.body)['id']; + file.subject = json.decode(response.body)['subject']; + file.description = json.decode(response.body)['description']; + file.upload_date = json.decode(response.body)['upload_date']; + file.upload_file = json.decode(response.body)['upload_file']; + file.is_read = json.decode(response.body)['is_read']; + file.designation_id = json.decode(response.body)['designation_id']; + file.uploader_id = json.decode(response.body)['uploader_id']; + _files.add(file); + notifyListeners(); + } + } + + fetchFiles() async { + final response = + await http.get("http://127.0.0.1:8000/filetracking/" as Uri); + if (response.statusCode == 200) { + var data = json.decode(response.body) as List; + _files = data.map((json) => File.fromJson(json)).toList(); + notifyListeners(); + } + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 49030f0b..bdc10bdd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -28,7 +28,7 @@ dependencies: google_fonts: shared_preferences: ^2.0.3 provider: - http: ^0.13.0 + http: ^0.13.5 pull_to_refresh: ^1.6.3 date_field: ^2.0.0 datetime_picker_formfield: ^2.0.0 @@ -39,6 +39,9 @@ dependencies: path_provider: ^2.0.8 open_file: ^3.2.1 flutter_html: ^2.2.1 + sqflite: ^2.2.6 + dio: ^5.0.0 + dio_cookie_manager: ^2.0.0