You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PatientApp-KKUMC/lib/widgets/avatar/large_avatar.dart

93 lines
2.9 KiB
Dart

import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../show_zoom_image_dialog.dart';
/// LargeAvatar
/// [name] the user name
/// [url] the image url
/// [disableProfileView] disable user profile view
/// [radius] the avatar radius
/// [width] the avatar width
/// [height] the avatar height
/// [onTap] on tap function
class LargeAvatar extends StatelessWidget {
LargeAvatar({Key? key, required this.name, this.url, this.disableProfileView= false, this.radius = 70.0, this.width = 70, this.height = 60, this.onTap, this.isAppointmentAvatar= false}) : super(key: key);
final String? name;
final String? url;
final bool disableProfileView;
final bool isAppointmentAvatar;
final double radius;
final double width;
final double height;
final GestureTapCallback? onTap;
Widget _getAvatar() {
if (url != null && url!.isNotEmpty && Uri.parse(url!).isAbsolute) {
return Center(
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(radius)),
child: Stack(
alignment: Alignment.center,
children: [
Image.network(
url!.trim(),
fit: BoxFit.fill,
width: width,
height: height,
),
if (!disableProfileView && !isAppointmentAvatar)
Container(
child: Icon(Icons.search,size: 18,color: Colors.white,),
padding: EdgeInsets.all(6),
decoration: containerRadius(Colors.black.withOpacity(0.3), 200),
)
],
),
),
);
} else
return Center(
child: Texts(
name![0].toUpperCase(),
color: Colors.white,
fontSize: 18,
));
}
@override
Widget build(BuildContext context) {
return InkWell(
onTap: disableProfileView
? null
: isAppointmentAvatar ? onTap : () {
print("ssssss " + url!.trim());
showZoomImageDialog(context, url!.trim() ?? "");
},
child: Container(
decoration: BoxDecoration(
// gradient: LinearGradient(
// begin: Alignment(-1, -1),
// end: Alignment(1, 1),
// colors: [
// Colors.grey[100],
// Colors.grey[800],
// ]),
// boxShadow: [
// BoxShadow(
// color: Color.fromRGBO(0, 0, 0, 0.08),
// offset: Offset(0.0, 5.0),
// blurRadius: 16.0)
// ],
borderRadius: BorderRadius.all(Radius.circular(radius)),
),
width: width,
height: height,
child: _getAvatar()),
);
}
}