-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
369 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
lib/modules/drawer/modules/portal/documents/bindings/document_images_binding.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:get/get.dart'; | ||
import 'package:ummobile/modules/drawer/modules/portal/documents/controllers/document_images_controller.dart'; | ||
|
||
class DocumentImagesBinding implements Bindings { | ||
final int documentId; | ||
|
||
final int pagesCount; | ||
|
||
DocumentImagesBinding(this.documentId, this.pagesCount); | ||
|
||
@override | ||
void dependencies() { | ||
Get.lazyPut<DocumentImagesController>( | ||
() => DocumentImagesController(documentId, pagesCount)); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
lib/modules/drawer/modules/portal/documents/controllers/document_images_controller.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import 'package:get/get.dart'; | ||
import 'package:ummobile/modules/login/controllers/login_controller.dart'; | ||
import 'package:ummobile/statics/templates/controller_template.dart'; | ||
import 'package:ummobile_sdk/ummobile_sdk.dart'; | ||
|
||
class DocumentImagesController extends ControllerTemplate | ||
with StateMixin<List<DocumentPage>> { | ||
/// The document id | ||
final int documentId; | ||
|
||
/// The amount of pages in the document | ||
final int pagesCount; | ||
|
||
/// The document pages | ||
List<DocumentPage> pages = List<DocumentPage>.empty(growable: true); | ||
|
||
DocumentImagesController(this.documentId, this.pagesCount); | ||
|
||
Future<UMMobileAcademic> get academicApi async { | ||
String accessToken = await Get.find<LoginController>().token; | ||
return UMMobileAcademic(token: accessToken); | ||
} | ||
|
||
@override | ||
void onInit() { | ||
fetchPages(); | ||
super.onInit(); | ||
} | ||
|
||
@override | ||
void refreshContent() { | ||
change(null, status: RxStatus.loading()); | ||
fetchPages(); | ||
super.refreshContent(); | ||
} | ||
|
||
void fetchPages() async { | ||
for (int i = 0; i < pagesCount; i++) { | ||
await call<DocumentPage>( | ||
httpCall: () async => | ||
await (await academicApi).getImagePage(this.documentId, i + 1), | ||
onSuccess: (data) => pages.add(data), | ||
onCallError: (status) => change(null, status: status), | ||
onError: (e) => change(null, status: RxStatus.error(e.toString())), | ||
); | ||
} | ||
|
||
if (pages.isNotEmpty) { | ||
change(pages, status: RxStatus.success()); | ||
} else { | ||
change(pages, status: RxStatus.empty()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
lib/modules/drawer/modules/portal/documents/views/subpages/document_images.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:get/get.dart'; | ||
import 'package:ummobile/modules/drawer/modules/portal/documents/controllers/document_images_controller.dart'; | ||
|
||
class DocumentImages extends StatefulWidget { | ||
/// The document Name | ||
final String documentName; | ||
|
||
DocumentImages({required this.documentName}); | ||
|
||
@override | ||
State<DocumentImages> createState() => _DocumentImagesState(); | ||
} | ||
|
||
class _DocumentImagesState extends State<DocumentImages> { | ||
final controller = Get.find<DocumentImagesController>(); | ||
|
||
@override | ||
void dispose() { | ||
Get.delete<DocumentImagesController>(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
iconTheme: IconThemeData(color: Colors.white), | ||
title: Text( | ||
widget.documentName, | ||
style: TextStyle(color: Colors.white), | ||
), | ||
backgroundColor: Colors.black, | ||
), | ||
backgroundColor: Colors.black, | ||
body: controller.obx( | ||
(images) => InteractiveViewer( | ||
clipBehavior: Clip.none, | ||
child: ListView( | ||
padding: const EdgeInsets.all(20), | ||
children: images! | ||
.map( | ||
(image) => Image.memory(base64Decode(image.base64Image!)), | ||
) | ||
.toList(), | ||
), | ||
), | ||
onEmpty: Center( | ||
child: Text( | ||
"No existen imágenes para este documento", | ||
style: TextStyle( | ||
color: Colors.white, | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.