update packages, replace barcode_widget with, qr_bar_code & update for new code package
This commit is contained in:
parent
d7e4ac134d
commit
e3766c827e
12 changed files with 925 additions and 823 deletions
|
|
@ -15,6 +15,8 @@ import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
|||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_circle_avatar.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:qr_bar_code/code/src/code_generate.dart';
|
||||
import 'package:qr_bar_code/code/src/code_type.dart';
|
||||
import 'package:screenshot/screenshot.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:supertokens_flutter/supertokens.dart';
|
||||
|
|
@ -33,7 +35,7 @@ class MihBusinessQrCode extends StatefulWidget {
|
|||
class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
||||
late Business business;
|
||||
PlatformFile? file;
|
||||
late String qrCodedata;
|
||||
late String _businessShare;
|
||||
int qrSize = 500;
|
||||
bool _isUserSignedIn = false;
|
||||
ScreenshotController screenshotController = ScreenshotController();
|
||||
|
|
@ -46,19 +48,6 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
|||
});
|
||||
}
|
||||
|
||||
String getQrCodeData(int qrSize) {
|
||||
String color =
|
||||
MihColors.primary().toARGB32().toRadixString(16).substring(2, 8);
|
||||
// KenLogger.warning(color);
|
||||
String bgColor =
|
||||
MihColors.secondary().toARGB32().toRadixString(16).substring(2, 8);
|
||||
// KenLogger.warning(bgColor);
|
||||
String encodedData =
|
||||
Uri.encodeComponent("$qrCodedata${business.business_id}");
|
||||
|
||||
return "https://api.qrserver.com/v1/create-qr-code/?data=$encodedData&size=${qrSize}x$qrSize&bgcolor=$bgColor&color=$color";
|
||||
}
|
||||
|
||||
Future<void> saveImage(Uint8List imageBytes) async {
|
||||
final String filename =
|
||||
"${business.Name}_QR_Code_${DateTime.now().millisecondsSinceEpoch}";
|
||||
|
|
@ -186,53 +175,60 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
|||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
padding: const EdgeInsets.symmetric(vertical: 20.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
widget.business == null
|
||||
? MihCircleAvatar(
|
||||
imageFile: profileprovider.businessProfilePicture,
|
||||
width: profilePictureWidth,
|
||||
expandable: true,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.primary(),
|
||||
backgroundColor: MihColors.secondary(),
|
||||
onChange: () {},
|
||||
)
|
||||
: MihCircleAvatar(
|
||||
imageFile: CachedNetworkImageProvider(
|
||||
MihFileApi.getMinioFileUrlV2(business.logo_path),
|
||||
Center(
|
||||
child: widget.business == null
|
||||
? MihCircleAvatar(
|
||||
imageFile: profileprovider.businessProfilePicture,
|
||||
width: profilePictureWidth,
|
||||
expandable: true,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.primary(),
|
||||
backgroundColor: MihColors.secondary(),
|
||||
onChange: () {},
|
||||
)
|
||||
: MihCircleAvatar(
|
||||
imageFile: CachedNetworkImageProvider(
|
||||
MihFileApi.getMinioFileUrlV2(business.logo_path),
|
||||
),
|
||||
width: profilePictureWidth,
|
||||
expandable: true,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.primary(),
|
||||
backgroundColor: MihColors.secondary(),
|
||||
onChange: () {},
|
||||
),
|
||||
width: profilePictureWidth,
|
||||
expandable: true,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.primary(),
|
||||
backgroundColor: MihColors.secondary(),
|
||||
onChange: () {},
|
||||
),
|
||||
Center(
|
||||
child: FittedBox(
|
||||
child: Text(
|
||||
business.Name,
|
||||
style: TextStyle(
|
||||
fontSize: 45,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.primary(),
|
||||
),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
business.Name,
|
||||
style: TextStyle(
|
||||
fontSize: 35,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.primary(),
|
||||
),
|
||||
),
|
||||
),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
business.type,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: MihColors.primary(),
|
||||
Center(
|
||||
child: FittedBox(
|
||||
child: Text(
|
||||
business.type,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: MihColors.primary(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -244,7 +240,7 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
|||
child: Text(
|
||||
"Powered by MIH",
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: MihColors.primary(),
|
||||
),
|
||||
|
|
@ -259,26 +255,31 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
|||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
width: 300,
|
||||
height: 300,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: getQrCodeData(qrSize.toInt()),
|
||||
placeholder: (context, url) => FittedBox(
|
||||
child: const Mihloadingcircle(),
|
||||
),
|
||||
errorWidget: (context, url, error) =>
|
||||
const Icon(Icons.error),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 35.0),
|
||||
child: LayoutBuilder(builder: (context, constraints) {
|
||||
final double codesize = constraints.maxWidth < qrSize
|
||||
? constraints.maxWidth
|
||||
: qrSize.toDouble();
|
||||
return Code(
|
||||
color: MihColors.primary(),
|
||||
data: "$_businessShare${business.business_id}",
|
||||
codeType: CodeType.qrCode(),
|
||||
width: codesize,
|
||||
height: codesize,
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
"Scan & Connect",
|
||||
style: TextStyle(
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.primary(),
|
||||
Center(
|
||||
child: FittedBox(
|
||||
child: Text(
|
||||
"Scan & Connect",
|
||||
style: TextStyle(
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.primary(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -312,7 +313,7 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
|||
business = profileProvider.business!;
|
||||
}
|
||||
_checkUserSession();
|
||||
qrCodedata = "${AppEnviroment.baseAppUrl}/business-profile/view/";
|
||||
_businessShare = "${AppEnviroment.baseAppUrl}/business-profile/view/";
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -327,12 +328,14 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
|||
}
|
||||
|
||||
Widget getBody(Size screenSize, BuildContext context) {
|
||||
double profilePictureWidth = 150;
|
||||
double profilePictureWidth =
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? 225
|
||||
: 200;
|
||||
return Stack(
|
||||
alignment: Alignment.topCenter,
|
||||
children: [
|
||||
MihSingleChildScroll(
|
||||
scrollbarOn: true,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15.0),
|
||||
child: Padding(
|
||||
|
|
@ -342,7 +345,7 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
|||
: EdgeInsets.symmetric(
|
||||
horizontal: screenSize.width * 0), //.075),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 10.0),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
||||
child: displayBusinessQRCode(profilePictureWidth),
|
||||
),
|
||||
),
|
||||
|
|
@ -386,7 +389,7 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
|||
shareMIHLink(
|
||||
context,
|
||||
"Check out ${business.Name} on the MIH app's Mzansi Directory",
|
||||
"$qrCodedata${business.business_id}",
|
||||
"$_businessShare${business.business_id}",
|
||||
);
|
||||
},
|
||||
),
|
||||
|
|
@ -404,7 +407,8 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
|||
backgroundColor: MihColors.green(),
|
||||
onTap: () async {
|
||||
await Clipboard.setData(
|
||||
ClipboardData(text: "$qrCodedata${business.business_id}"),
|
||||
ClipboardData(
|
||||
text: "$_businessShare${business.business_id}"),
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'package:file_picker/file_picker.dart';
|
|||
import 'package:file_saver/file_saver.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
|
@ -16,6 +17,8 @@ import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart
|
|||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_circle_avatar.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:qr_bar_code/code/src/code_generate.dart';
|
||||
import 'package:qr_bar_code/code/src/code_type.dart';
|
||||
import 'package:screenshot/screenshot.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:supertokens_flutter/supertokens.dart';
|
||||
|
|
@ -38,7 +41,8 @@ class _MihPersonalQrCodeState extends State<MihPersonalQrCode> {
|
|||
ScreenshotController screenshotController = ScreenshotController();
|
||||
Uint8List? personalQRImageFile;
|
||||
bool _isUserSignedIn = false;
|
||||
final String _qrCodedata = "${AppEnviroment.baseAppUrl}/mzansi-profile/view/";
|
||||
final String _userShareLink =
|
||||
"${AppEnviroment.baseAppUrl}/mzansi-profile/view/";
|
||||
|
||||
Future<void> _checkUserSession() async {
|
||||
final doesSessionExist = await SuperTokens.doesSessionExist();
|
||||
|
|
@ -47,18 +51,6 @@ class _MihPersonalQrCodeState extends State<MihPersonalQrCode> {
|
|||
});
|
||||
}
|
||||
|
||||
String getQrCodeData(int qrSize) {
|
||||
String color =
|
||||
MihColors.primary().toARGB32().toRadixString(16).substring(2, 8);
|
||||
// KenLogger.warning(color);
|
||||
String bgColor =
|
||||
MihColors.secondary().toARGB32().toRadixString(16).substring(2, 8);
|
||||
// KenLogger.warning(bgColor);
|
||||
String encodedData =
|
||||
Uri.encodeComponent("$_qrCodedata${user.username.toLowerCase()}");
|
||||
return "https://api.qrserver.com/v1/create-qr-code/?data=$encodedData&size=${qrSize}x$qrSize&bgcolor=$bgColor&color=$color";
|
||||
}
|
||||
|
||||
Future<void> saveImage(Uint8List imageBytes) async {
|
||||
final String filename =
|
||||
"${user.username}_QR_Code_${DateTime.now().millisecondsSinceEpoch}";
|
||||
|
|
@ -177,64 +169,72 @@ class _MihPersonalQrCodeState extends State<MihPersonalQrCode> {
|
|||
context.read<MzansiProfileProvider>();
|
||||
return Screenshot(
|
||||
controller: screenshotController,
|
||||
child: Material(
|
||||
color: MihColors.secondary().withValues(alpha: 0.6),
|
||||
borderRadius: BorderRadius.circular(25),
|
||||
elevation: 10,
|
||||
shadowColor: Colors.black,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.secondary(),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: SizedBox(
|
||||
child: Material(
|
||||
color: MihColors.secondary().withValues(alpha: 0.6),
|
||||
borderRadius: BorderRadius.circular(25),
|
||||
elevation: 10,
|
||||
shadowColor: Colors.black,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.secondary(),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 20.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
widget.user == null
|
||||
? MihCircleAvatar(
|
||||
imageFile: profileProvider.userProfilePicture,
|
||||
width: profilePictureWidth,
|
||||
expandable: true,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.primary(),
|
||||
backgroundColor: MihColors.secondary(),
|
||||
onChange: () {},
|
||||
)
|
||||
: MihCircleAvatar(
|
||||
imageFile: CachedNetworkImageProvider(
|
||||
MihFileApi.getMinioFileUrlV2(user.pro_pic_path),
|
||||
Center(
|
||||
child: widget.user == null
|
||||
? MihCircleAvatar(
|
||||
imageFile: profileProvider.userProfilePicture,
|
||||
width: profilePictureWidth,
|
||||
expandable: true,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.primary(),
|
||||
backgroundColor: MihColors.secondary(),
|
||||
onChange: () {},
|
||||
)
|
||||
: MihCircleAvatar(
|
||||
imageFile: CachedNetworkImageProvider(
|
||||
MihFileApi.getMinioFileUrlV2(user.pro_pic_path),
|
||||
),
|
||||
width: profilePictureWidth,
|
||||
expandable: true,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.primary(),
|
||||
backgroundColor: MihColors.secondary(),
|
||||
onChange: () {},
|
||||
),
|
||||
width: profilePictureWidth,
|
||||
expandable: true,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.primary(),
|
||||
backgroundColor: MihColors.secondary(),
|
||||
onChange: () {},
|
||||
),
|
||||
Center(
|
||||
child: FittedBox(
|
||||
child: Text(
|
||||
user.username,
|
||||
style: TextStyle(
|
||||
fontSize: 45,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.primary(),
|
||||
),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
user.username,
|
||||
style: TextStyle(
|
||||
fontSize: 35,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.primary(),
|
||||
),
|
||||
),
|
||||
),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
"${user.fname} ${user.lname}",
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: MihColors.primary(),
|
||||
Center(
|
||||
child: FittedBox(
|
||||
child: Text(
|
||||
"${user.fname} ${user.lname}",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: MihColors.primary(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -246,7 +246,7 @@ class _MihPersonalQrCodeState extends State<MihPersonalQrCode> {
|
|||
child: Text(
|
||||
"Powered by MIH",
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: MihColors.primary(),
|
||||
),
|
||||
|
|
@ -261,31 +261,39 @@ class _MihPersonalQrCodeState extends State<MihPersonalQrCode> {
|
|||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
width: 300,
|
||||
height: 300,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: getQrCodeData(qrSize.toInt()),
|
||||
placeholder: (context, url) => FittedBox(
|
||||
child: const Mihloadingcircle(),
|
||||
),
|
||||
errorWidget: (context, url, error) =>
|
||||
const Icon(Icons.error),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 35.0),
|
||||
child: LayoutBuilder(builder: (context, constraints) {
|
||||
final double codesize = constraints.maxWidth < qrSize
|
||||
? constraints.maxWidth
|
||||
: qrSize.toDouble();
|
||||
return Code(
|
||||
color: MihColors.primary(),
|
||||
data:
|
||||
"$_userShareLink${profileProvider.user!.username.toLowerCase()}",
|
||||
codeType: CodeType.qrCode(),
|
||||
width: codesize,
|
||||
height: codesize,
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
"Scan & Connect",
|
||||
style: TextStyle(
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.primary(),
|
||||
Center(
|
||||
child: FittedBox(
|
||||
child: Text(
|
||||
"Scan & Connect",
|
||||
style: TextStyle(
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.primary(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
@ -329,22 +337,24 @@ class _MihPersonalQrCodeState extends State<MihPersonalQrCode> {
|
|||
}
|
||||
|
||||
Widget getBody(Size screenSize, BuildContext context) {
|
||||
double profilePictureWidth = 150;
|
||||
double profilePictureWidth =
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? 225
|
||||
: 200;
|
||||
return Stack(
|
||||
alignment: Alignment.topCenter,
|
||||
children: [
|
||||
MihSingleChildScroll(
|
||||
scrollbarOn: true,
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15.0),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15.0),
|
||||
child: Padding(
|
||||
padding:
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? EdgeInsets.symmetric(horizontal: screenSize.width * 0.2)
|
||||
: EdgeInsets.symmetric(
|
||||
horizontal: screenSize.width * 0), //.075),
|
||||
padding:
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? EdgeInsets.symmetric(horizontal: screenSize.width * 0.2)
|
||||
: EdgeInsets.symmetric(
|
||||
horizontal: screenSize.width * 0), //.075),
|
||||
child: MihSingleChildScroll(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 10.0),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
||||
child: displayPersonalQRCode(profilePictureWidth),
|
||||
),
|
||||
),
|
||||
|
|
@ -388,7 +398,7 @@ class _MihPersonalQrCodeState extends State<MihPersonalQrCode> {
|
|||
shareMIHLink(
|
||||
context,
|
||||
"Check out ${user.username} on the MIH app's Mzansi Directory",
|
||||
"$_qrCodedata${user.username.toLowerCase()}",
|
||||
"$_userShareLink${user.username.toLowerCase()}",
|
||||
);
|
||||
},
|
||||
),
|
||||
|
|
@ -407,7 +417,8 @@ class _MihPersonalQrCodeState extends State<MihPersonalQrCode> {
|
|||
onTap: () async {
|
||||
await Clipboard.setData(
|
||||
ClipboardData(
|
||||
text: "$_qrCodedata${user.username.toLowerCase()}"),
|
||||
text:
|
||||
"$_userShareLink${user.username.toLowerCase()}"),
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue