
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:liftmanager/res/resources.dart';
import 'package:liftmanager/utils/image_utils.dart';
import 'package:liftmanager/utils/theme_utils.dart';
import 'package:liftmanager/utils/url.dart';
import 'package:liftmanager/utils/utils.dart';

class SelectedImage extends StatelessWidget {

  const SelectedImage({
    Key key,
    this.size : 80.0,
    this.onTap,
    this.image,
    this.index
  }): super(key: key);

  final double size;
  final GestureTapCallback onTap;
  final String image;
  final int index;

  @override
  Widget build(BuildContext context) {
    return InkWell(
      borderRadius: BorderRadius.circular(16.0),
      onTap: onTap,
      child: Container(
        width: size,
        height: size,
        decoration: BoxDecoration(
          // 图片圆角展示
          borderRadius: BorderRadius.circular(0),
          image: DecorationImage(
              image: image == null ? ImageUtils.getAssetImage("img_add") : NetworkImage(Utils.getImagePath(image)),
              fit: BoxFit.cover,
              colorFilter: image == null ? ColorFilter.mode(ThemeUtils.getDarkColor(context, Colours.dark_unselected_item_color), BlendMode.srcIn) : null
          ),
        ),
      ),
    );
  }
}

