// withHooks
import esp from 'esoftplay/esp';

import { LibCapture } from 'esoftplay/cache/lib/capture/import';
import { LibIcon } from 'esoftplay/cache/lib/icon/import';
import { LibNavigation } from 'esoftplay/cache/lib/navigation/import';
import { LibPan } from 'esoftplay/cache/lib/pan/import';
import { LibStyle } from 'esoftplay/cache/lib/style/import';
import { LibWebview } from 'esoftplay/cache/lib/webview/import';
import { MarketHeader } from 'esoftplay/cache/market/header/import';

import React, { useRef } from 'react';
import { ScrollView, TouchableOpacity, View } from 'react-native';

export interface MarketOrder_detail_invoiceArgs {
  url: string
  invoice: string
}
export interface MarketOrder_detail_invoiceProps {

}
export default function m(props: MarketOrder_detail_invoiceProps): any {
  const { url, invoice } = LibNavigation.getArgsAll<any>(props)
  const downloadView = useRef<LibWebview>(null)
  const invoiceReplace = invoice.replace(/\//g, '-')

  return (
    <View style={{ flex: 1 }}>
      <MarketHeader
        title={esp.lang("market/order_detail_invoice", "header_title")}
        rightView={() => (
          <TouchableOpacity onPress={() => { LibCapture.capture(downloadView, esp.lang("market/order_detail_invoice", "print", invoiceReplace)) }} style={{ height: 50, justifyContent: 'center', paddingRight: 17 }} >
            <LibIcon.AntDesign name='download' size={18} />
          </TouchableOpacity>
        )}
        leftIcon={{ name: "close", onPress: () => LibNavigation.back() }}
      />
      <ScrollView style={{ flex: 1 }} >
        <LibPan>
          <View pointerEvents='none' >
            <LibWebview
              ref={downloadView}
              maxWidth={LibStyle.width}
              onFinishLoad={() => { }}
              needAnimate
              source={{ uri: url }}
            />
          </View>
        </LibPan>
      </ScrollView>
      {/* {
          esp.isDebug() &&
          <MarketButton text="CETAK"
            icon={"printer"}
            iconSize={24}
            buttonStyle={{ margin: 20 }}
            onPress={() => { LibPrint.printAsync(url) }}
          />
        } */}
    </View>
  )
}