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

82 lines
2.1 KiB
Dart

import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.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})
: super(key: key);
final String name;
final String url;
final bool disableProfileView;
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: Image.network(
url.trim(),
fit: BoxFit.fill,
width: width,
height: height,
),
),
);
} else
return Center(
child: Texts(
name[0].toUpperCase(),
color: Colors.white,
fontSize: 18,
));
}
@override
Widget build(BuildContext context) {
return InkWell(
onTap: disableProfileView ? null : onTap,
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()),
);
}
}