initialise qrcode late

This commit is contained in:
2025-09-10 15:27:34 +02:00
parent a523397261
commit 5baa185211

View File

@@ -35,8 +35,7 @@ class MihBusinessQrCode extends StatefulWidget {
class _MihBusinessQrCodeState extends State<MihBusinessQrCode> { class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
late Future<String> futureImageUrl; late Future<String> futureImageUrl;
PlatformFile? file; PlatformFile? file;
String qrCodedata = late String qrCodedata;
"${AppEnviroment.baseAppUrl}/business-profile/view?business_id=";
int qrSize = 500; int qrSize = 500;
bool _isUserSignedIn = false; bool _isUserSignedIn = false;
@@ -146,6 +145,8 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
_checkUserSession(); _checkUserSession();
futureImageUrl = futureImageUrl =
MihFileApi.getMinioFileUrl(widget.business.logo_path, context); MihFileApi.getMinioFileUrl(widget.business.logo_path, context);
qrCodedata =
"${AppEnviroment.baseAppUrl}/business-profile/view?business_id=";
} }
@override @override
@@ -160,85 +161,71 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
Widget getBody(Size screenSize, BuildContext context) { Widget getBody(Size screenSize, BuildContext context) {
double profilePictureWidth = 150; double profilePictureWidth = 150;
return SizedBox( return Stack(
height: screenSize.height, alignment: Alignment.topCenter,
child: Stack( children: [
alignment: Alignment.topCenter, MihSingleChildScroll(
children: [ child: Padding(
MihSingleChildScroll( padding: const EdgeInsets.symmetric(horizontal: 15.0),
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 15.0), padding:
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
? EdgeInsets.symmetric(horizontal: screenSize.width * 0.2)
: EdgeInsets.symmetric(
horizontal: screenSize.width * 0), //.075),
child: Padding( child: Padding(
padding: MzansiInnovationHub.of(context)!.theme.screenType == padding: const EdgeInsets.only(top: 10.0),
"desktop" child: Material(
? EdgeInsets.symmetric(horizontal: screenSize.width * 0.2) color: MihColors.getSecondaryColor(
: EdgeInsets.symmetric( MzansiInnovationHub.of(context)!.theme.mode == "Dark")
horizontal: screenSize.width * 0), //.075), .withValues(alpha: 0.6),
child: Padding( borderRadius: BorderRadius.circular(25),
padding: const EdgeInsets.only(top: 10.0), elevation: 10,
child: Material( shadowColor: Colors.black,
color: MihColors.getSecondaryColor( child: Container(
MzansiInnovationHub.of(context)!.theme.mode == decoration: BoxDecoration(
"Dark") color: MihColors.getSecondaryColor(
.withValues(alpha: 0.6), MzansiInnovationHub.of(context)!.theme.mode ==
borderRadius: BorderRadius.circular(25), "Dark"),
elevation: 10, borderRadius: BorderRadius.circular(20),
shadowColor: Colors.black, ),
child: Container( child: Padding(
decoration: BoxDecoration( padding: const EdgeInsets.all(20.0),
color: MihColors.getSecondaryColor( child: Column(
MzansiInnovationHub.of(context)!.theme.mode == mainAxisAlignment: MainAxisAlignment.start,
"Dark"), mainAxisSize: MainAxisSize.min,
borderRadius: BorderRadius.circular(20), children: [
), FutureBuilder(
child: Padding( future: futureImageUrl,
padding: const EdgeInsets.all(20.0), builder: (context, asyncSnapshot) {
child: Column( if (asyncSnapshot.connectionState ==
mainAxisAlignment: MainAxisAlignment.start, ConnectionState.done &&
mainAxisSize: MainAxisSize.min, asyncSnapshot.hasData) {
children: [ if (asyncSnapshot.requireData != "") {
FutureBuilder( return MihCircleAvatar(
future: futureImageUrl, imageFile: NetworkImage(
builder: (context, asyncSnapshot) { asyncSnapshot.requireData),
if (asyncSnapshot.connectionState == width: profilePictureWidth,
ConnectionState.done && editable: false,
asyncSnapshot.hasData) { fileNameController:
if (asyncSnapshot.requireData != "") { TextEditingController(),
return MihCircleAvatar( userSelectedfile: file,
imageFile: NetworkImage( frameColor: MihColors.getPrimaryColor(
asyncSnapshot.requireData), MzansiInnovationHub.of(context)!
width: profilePictureWidth, .theme
editable: false, .mode ==
fileNameController: "Dark"),
TextEditingController(), backgroundColor:
userSelectedfile: file, MihColors.getSecondaryColor(
frameColor: MihColors.getPrimaryColor( MzansiInnovationHub.of(context)!
MzansiInnovationHub.of(context)! .theme
.theme .mode ==
.mode == "Dark"),
"Dark"), onChange: () {},
backgroundColor: );
MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
onChange: () {},
);
} else {
return Icon(
MihIcons.iDontKnow,
size: profilePictureWidth,
color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
);
}
} else { } else {
return Icon( return Icon(
MihIcons.mihRing, MihIcons.iDontKnow,
size: profilePictureWidth, size: profilePictureWidth,
color: MihColors.getSecondaryColor( color: MihColors.getSecondaryColor(
MzansiInnovationHub.of(context)! MzansiInnovationHub.of(context)!
@@ -247,103 +234,111 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
"Dark"), "Dark"),
); );
} }
}, } else {
), return Icon(
FittedBox( MihIcons.mihRing,
child: Text( size: profilePictureWidth,
widget.business.Name, color: MihColors.getSecondaryColor(
style: TextStyle(
fontSize: 35,
fontWeight: FontWeight.bold,
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)! MzansiInnovationHub.of(context)!
.theme .theme
.mode == .mode ==
"Dark"), "Dark"),
), );
}
},
),
FittedBox(
child: Text(
widget.business.Name,
style: TextStyle(
fontSize: 35,
fontWeight: FontWeight.bold,
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
), ),
), ),
FittedBox( ),
child: Text( FittedBox(
widget.business.type, child: Text(
style: TextStyle( widget.business.type,
fontSize: 20, style: TextStyle(
fontWeight: FontWeight.w600, fontSize: 20,
color: MihColors.getPrimaryColor( fontWeight: FontWeight.w600,
MzansiInnovationHub.of(context)! color: MihColors.getPrimaryColor(
.theme MzansiInnovationHub.of(context)!
.mode == .theme
"Dark"), .mode ==
), "Dark"),
), ),
), ),
const SizedBox(height: 10), ),
SizedBox( const SizedBox(height: 10),
width: 300, SizedBox(
height: 300, width: 300,
child: CachedNetworkImage( height: 300,
imageUrl: getQrCodeData(qrSize.toInt()), child: CachedNetworkImage(
placeholder: (context, url) => imageUrl: getQrCodeData(qrSize.toInt()),
const Mihloadingcircle(), placeholder: (context, url) =>
errorWidget: (context, url, error) => const Mihloadingcircle(),
const Icon(Icons.error), errorWidget: (context, url, error) =>
const Icon(Icons.error),
),
),
const SizedBox(height: 10),
FittedBox(
child: Text(
"Scan & Connect",
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
), ),
), ),
const SizedBox(height: 10), ),
FittedBox( ],
child: Text( )),
"Scan & Connect",
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
color: MihColors.getPrimaryColor(
MzansiInnovationHub.of(context)!
.theme
.mode ==
"Dark"),
),
),
),
],
)),
),
), ),
), ),
), ),
), ),
), ),
Positioned( ),
right: 10, Positioned(
bottom: 10, right: 10,
child: MihFloatingMenu( bottom: 10,
animatedIcon: AnimatedIcons.menu_close, child: MihFloatingMenu(
children: [ animatedIcon: AnimatedIcons.menu_close,
SpeedDialChild( children: [
child: Icon( SpeedDialChild(
Icons.download_rounded, child: Icon(
color: MihColors.getPrimaryColor( Icons.download_rounded,
MzansiInnovationHub.of(context)!.theme.mode == color: MihColors.getPrimaryColor(
"Dark"),
),
label: "Download QR Code",
labelBackgroundColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"), MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
labelStyle: TextStyle( ),
color: MihColors.getPrimaryColor( label: "Download QR Code",
MzansiInnovationHub.of(context)!.theme.mode == labelBackgroundColor: MihColors.getGreenColor(
"Dark"), MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
fontWeight: FontWeight.bold, labelStyle: TextStyle(
), color: MihColors.getPrimaryColor(
backgroundColor: MihColors.getGreenColor(
MzansiInnovationHub.of(context)!.theme.mode == "Dark"), MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
onTap: () { fontWeight: FontWeight.bold,
downloadQrCode(); ),
}, backgroundColor: MihColors.getGreenColor(
) MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
]), onTap: () {
) downloadQrCode();
], },
), )
]),
)
],
); );
} }
} }