Componente appbar y primary buttom
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PopAppbar extends StatelessWidget implements PreferredSizeWidget {
|
||||
final VoidCallback onPressed;
|
||||
final String label;
|
||||
|
||||
const PopAppbar({
|
||||
super.key,
|
||||
required this.onPressed,
|
||||
required this.label,
|
||||
});
|
||||
|
||||
@override
|
||||
Size get preferredSize => Size.fromHeight(kToolbarHeight);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: onPressed,
|
||||
),
|
||||
iconTheme: const IconThemeData(
|
||||
color: Colors.black,
|
||||
),
|
||||
title: Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
import 'package:firebase_storage/firebase_storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
const double photoSize = 100;
|
||||
|
||||
class ProfessionalPhoto extends StatelessWidget {
|
||||
Reference? ref;
|
||||
double size;
|
||||
ProfessionalPhoto({super.key, required this.ref, this.size = photoSize});
|
||||
|
||||
Future<Widget> downloadImage() async {
|
||||
try {
|
||||
if (ref != null) {
|
||||
final imageData = await ref!.getData();
|
||||
if (imageData != null) {
|
||||
return ClipOval(
|
||||
child: Image.memory(
|
||||
imageData,
|
||||
width: size,
|
||||
height: size,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
// ignore: empty_catches
|
||||
} catch (e) {}
|
||||
|
||||
return const DefaultProfessionalPhoto();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<Widget>(
|
||||
future: downloadImage(),
|
||||
builder: (BuildContext context, AsyncSnapshot<Widget> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
// mientras la llamada asíncrona está en proceso, muestra un mensaje de carga
|
||||
return const SizedBox(
|
||||
width: photoSize,
|
||||
height: photoSize,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
));
|
||||
} else if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
return snapshot.data!;
|
||||
} else {
|
||||
return const DefaultProfessionalPhoto();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class DefaultProfessionalPhoto extends StatelessWidget {
|
||||
const DefaultProfessionalPhoto({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: photoSize,
|
||||
height: photoSize,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF2BA4EC),
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.person,
|
||||
color: Color.fromARGB(255, 255, 255, 255),
|
||||
size: 55,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user