//import 'package:advance_pdf_viewer/advance_pdf_viewer.dart';
import 'package:modelo/pdfviewer/pdfviewer_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_pdfview/flutter_pdfview.dart';
import 'package:get/get.dart';

class PDFViewerScreen extends StatelessWidget {
  final PDFViewerScreenController c = Get.put(PDFViewerScreenController());
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('i-Card'),
        centerTitle: false,
        leading: Container(),
        leadingWidth: 0,
        actions: [
          Obx(() => c.loadPDF.value
              ? Center(child: CircularProgressIndicator())
              : IconButton(icon: Icon(Icons.share), onPressed: c.sharePDF)),
          Obx(() => c.visibleRefresh.value
              ? IconButton(icon: Icon(Icons.refresh), onPressed: c.refreshPDF)
              : Container())
        ],
      ),
      // body: Obx(() => c.loading.value
      //     ? Center(
      //         child: CircularProgressIndicator(),
      //       )
      //     : c.error.value ? c.buildError() : PDFViewer(
      //         lazyLoad: false,
      //         document: c.doc,
      //       )),
      body: Obx(() => c.loading.value
          ? Center(
              child: CircularProgressIndicator(),
            )
          : c.error.value
              ? c.buildError()
              : PDFView(
                  filePath: c.filePDF!.path,
                  //nightMode: true,
                  fitPolicy: FitPolicy.BOTH,
                )),
    );
  }
}
