Generic fixes (#1291)

* - Update Camera purpose string for iOS
- Fix address field not passing the correct currency to address book

* Enhance file loading in exception handler

* Fix translation consistency [skip ci]
This commit is contained in:
Omar Hatem
2024-02-06 22:44:21 +02:00
committed by GitHub
parent 3945a3d7b4
commit d0b51cebe3
30 changed files with 192 additions and 47 deletions
+1 -1
View File
@@ -189,7 +189,7 @@ class SendCardState extends State<SendCard> with AutomaticKeepAliveClientMixin<S
output.loadContact(contact);
},
validator: validator,
selectedCurrency: sendViewModel.currency,
selectedCurrency: sendViewModel.selectedCryptoCurrency,
);
}),
if (output.isParsedAddress)
@@ -69,40 +69,44 @@ class SendTemplateCard extends StatelessWidget {
validator: sendTemplateViewModel.templateValidator),
Padding(
padding: EdgeInsets.only(top: 20),
child: AddressTextField(
selectedCurrency: sendTemplateViewModel.cryptoCurrency,
controller: _addressController,
onURIScanned: (uri) {
final paymentRequest = PaymentRequest.fromUri(uri);
_addressController.text = paymentRequest.address;
_cryptoAmountController.text = paymentRequest.amount;
},
options: [
AddressTextFieldOption.paste,
AddressTextFieldOption.qrCode,
AddressTextFieldOption.addressBook
],
onPushPasteButton: (context) async {
template.output.resetParsedAddress();
await template.output.fetchParsedAddress(context);
},
onPushAddressBookButton: (context) async {
template.output.resetParsedAddress();
await template.output.fetchParsedAddress(context);
},
buttonColor: Theme.of(context).extension<SendPageTheme>()!.textFieldButtonColor,
borderColor: Theme.of(context).extension<SendPageTheme>()!.textFieldBorderColor,
textStyle: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.white,
),
hintStyle: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Theme.of(context).extension<SendPageTheme>()!.textFieldHintColor,
),
validator: sendTemplateViewModel.addressValidator,
child: Observer(
builder: (context) {
return AddressTextField(
selectedCurrency: template.selectedCurrency,
controller: _addressController,
onURIScanned: (uri) {
final paymentRequest = PaymentRequest.fromUri(uri);
_addressController.text = paymentRequest.address;
_cryptoAmountController.text = paymentRequest.amount;
},
options: [
AddressTextFieldOption.paste,
AddressTextFieldOption.qrCode,
AddressTextFieldOption.addressBook
],
onPushPasteButton: (context) async {
template.output.resetParsedAddress();
await template.output.fetchParsedAddress(context);
},
onPushAddressBookButton: (context) async {
template.output.resetParsedAddress();
await template.output.fetchParsedAddress(context);
},
buttonColor: Theme.of(context).extension<SendPageTheme>()!.textFieldButtonColor,
borderColor: Theme.of(context).extension<SendPageTheme>()!.textFieldBorderColor,
textStyle: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.white,
),
hintStyle: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Theme.of(context).extension<SendPageTheme>()!.textFieldHintColor,
),
validator: sendTemplateViewModel.addressValidator,
);
}
),
),
Padding(
+16 -10
View File
@@ -16,11 +16,15 @@ import 'package:shared_preferences/shared_preferences.dart';
class ExceptionHandler {
static bool _hasError = false;
static const _coolDownDurationInDays = 7;
static File? _file;
static void _saveException(String? error, StackTrace? stackTrace, {String? library}) async {
final appDocDir = await getApplicationDocumentsDirectory();
if (_file == null) {
final appDocDir = await getApplicationDocumentsDirectory();
_file = File('${appDocDir.path}/error.txt');
}
final file = File('${appDocDir.path}/error.txt');
final exception = {
"${DateTime.now()}": {
"Error": "$error\n\n",
@@ -33,14 +37,14 @@ class ExceptionHandler {
==========================================================\n\n''';
/// don't save existing errors
if (file.existsSync()) {
final String fileContent = await file.readAsString();
if (_file!.existsSync()) {
final String fileContent = await _file!.readAsString();
if (fileContent.contains("${exception.values.first}")) {
return;
}
}
file.writeAsStringSync(
_file!.writeAsStringSync(
"$exception $separator",
mode: FileMode.append,
);
@@ -48,16 +52,18 @@ class ExceptionHandler {
static void _sendExceptionFile() async {
try {
final appDocDir = await getApplicationDocumentsDirectory();
if (_file == null) {
final appDocDir = await getApplicationDocumentsDirectory();
final file = File('${appDocDir.path}/error.txt');
_file = File('${appDocDir.path}/error.txt');
}
await _addDeviceInfo(file);
await _addDeviceInfo(_file!);
final MailOptions mailOptions = MailOptions(
subject: 'Mobile App Issue',
recipients: ['support@cakewallet.com'],
attachments: [file.path],
attachments: [_file!.path],
);
final result = await FlutterMailer.send(mailOptions);
@@ -67,7 +73,7 @@ class ExceptionHandler {
if (result.name == MailerResponse.sent.name ||
result.name == MailerResponse.saved.name ||
result.name == MailerResponse.android.name) {
file.writeAsString("", mode: FileMode.write);
_file!.writeAsString("", mode: FileMode.write);
}
} catch (e, s) {
_saveException(e.toString(), s);