// withHooks
// noPage

import { LibIcon, LibIconStyle } from 'esoftplay/cache/lib/icon/import';
import { LibTextstyle } from 'esoftplay/cache/lib/textstyle/import';
import { MarketStyle } from 'esoftplay/cache/market/style/import';

import React from 'react';
import { ActivityIndicator, TouchableOpacity } from 'react-native';


export interface MarketButtonProps {
  text: string,
  icon?: LibIconStyle,
  iconSize?: number,
  loading?: boolean,
  onPress: () => void,
  full?: boolean,
  color?: string,
  colorBorder?: string,
  colorBackground?: string,
  buttonStyle?: any,
  textStyle?: any
}
export default function m(props: MarketButtonProps): any {
  let { text, loading, onPress, colorBackground, color, icon, iconSize, colorBorder, full, buttonStyle, textStyle } = props

  color = color || "white"
  colorBackground = colorBackground || MarketStyle.colorPrimaryMarket
  colorBorder = colorBorder || colorBackground

  return (
    <TouchableOpacity
      testID='button'
      onPress={onPress}
      disabled={loading}
      style={[styleId_Z21McoH, { flex: full ? 1 : undefined, flexWrap: full ? "wrap" : undefined, backgroundColor: colorBackground, borderColor: colorBorder, ...buttonStyle }]} >
      <>
        {loading && <ActivityIndicator size={"small"} color={color} style={styleId_1hcIwd} />}
        {icon && <LibIcon name={icon} size={iconSize} color={color} style={styleId_1hcIwd} />}
        <LibTextstyle textStyle="body" text={text} style={{ color, ...textStyle }} />
      </>
    </TouchableOpacity>
  )
}
const styleId_Z21McoH: any = { flexDirection: "row", alignItems: "center", justifyContent: "center", borderWidth: 1, paddingVertical: 8, paddingHorizontal: 30, borderRadius: 6 }
const styleId_1hcIwd: any = { marginRight: 10 }