GiffyModel.image constructor

GiffyModel.image(
  1. BuildContext context,
  2. Map<String, dynamic> viewJson
)

Implementation

factory GiffyModel.image(
    BuildContext context, Map<String, dynamic> viewJson) {
  String image = viewJson['Component']['image'];
  String title = viewJson['Component']['title'].toString();
  String content = viewJson['Component']['content'].toString();
  String cta = viewJson['Component']['cta']??'OK';
  Uri deeplink = Uri.parse(viewJson['Component']['deeplink']??'');

  return GiffyModel(
    giffy: Image.network(
      image,
      width: 2000,
      fit: BoxFit.fitWidth,
    ),
    title: Text(
      title,
      textAlign: TextAlign.center,
    ),
    content: Text(
      content,
      textAlign: TextAlign.center,
    ),
    actions: [
      TextButton(
        onPressed: () {
          ViewPref.getInstance().logClicks(viewJson);
          Navigator.pop(context, 'CANCEL');
        },
        child: const Text('CANCEL'),
      ),
      TextButton(
        onPressed: () {
          ViewPref.getInstance().logClicks(viewJson);
          Navigator.pop(context, 'OK');
          if(Instadiv.getInstance().inAppCTA!=null) {
            Instadiv.getInstance().inAppCTA!(deeplink);
          } else {
            openUrl(deeplink);
          }
        },
        child: Text(cta),
      ),
    ],
  );
}