import 'dart:io';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:mighty_school/common/widget/custom_image.dart';
import 'package:mighty_school/feature/institute/controller/institute_controller.dart';
import 'package:mighty_school/util/dimensions.dart';


class SelectUserImageWidget extends StatelessWidget {
  const SelectUserImageWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return  GetBuilder<InstituteController>(
      builder: (instituteController) {
        return Align(alignment: Alignment.center, child: Stack(children: [
          ClipRRect(borderRadius: BorderRadius.circular(Dimensions.paddingSizeSmall),
              child: instituteController.userImage != null ?  GetPlatform.isWeb? Image.network((instituteController.userImage!.path),
                width: 150, height: 120, fit: BoxFit.cover,):Image.file(File(instituteController.userImage!.path),
                width: 150, height: 120, fit: BoxFit.cover,):
              const CustomImage(image: '', height: 120, width: 150)),


          Positioned(bottom: 0, right: 0, top: 0, left: 0,
              child: InkWell(onTap: () => instituteController.pickImage(user: true),
                  child: Container(decoration: BoxDecoration(color: Colors.black.withValues(alpha: 0.3),
                      borderRadius: BorderRadius.circular(Dimensions.paddingSizeSmall),
                      border: Border.all(width: 1, color: Theme.of(context).primaryColor)),
                      child: Container(margin: const EdgeInsets.all(25),
                          decoration: BoxDecoration(border: Border.all(width: 2, color: Colors.white), shape: BoxShape.circle),
                          child: const Icon(Icons.camera_alt, color: Colors.white)))))]));
      }
    );
  }
}
