Skip to content

Commit

Permalink
feature: batch calls component improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewwahid committed Aug 4, 2023
1 parent cd977c9 commit 2bdcef6
Showing 1 changed file with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'package:candide_mobile_app/services/transaction_decoder.dart';
import 'package:candide_mobile_app/utils/utils.dart';
import 'package:expandable/expandable.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class DefaultMultiCallDecodeComponent extends StatefulWidget {
final List<dynamic> params;
Expand All @@ -18,10 +17,10 @@ class DefaultMultiCallDecodeComponent extends StatefulWidget {
}

class _DefaultMultiCallDecodeComponentState extends State<DefaultMultiCallDecodeComponent> {
List<Widget> decodedDataLeadings = [];
List<dynamic> decodedDataLeadings = [];

void decodeRequestData() async {
List<Widget> leadings = [];
List<dynamic> leadings = [];
for (var call in widget.params[0]["calls"]){
HexTransactionDetails? transactionDetails = await TransactionDecoder.decodeHexData(call["data"]);
bool showKnownParamsComponent = false;
Expand All @@ -34,30 +33,30 @@ class _DefaultMultiCallDecodeComponentState extends State<DefaultMultiCallDecode
showKnownParamsComponent = true;
break check;
}
leadings.add(WCApproveComponent(
leadings.add([transactionDetails.functionName, WCApproveComponent(
transactionDetails: transactionDetails,
token: token,
margin: EdgeInsets.zero,
elevation: 0,
));
)]);
}
}else{
showKnownParamsComponent = true;
}
}
if (showKnownParamsComponent){
leadings.add(KnownParamsComponent(
leadings.add([transactionDetails.functionName, KnownParamsComponent(
transactionDetails: transactionDetails,
margin: EdgeInsets.zero,
elevation: 0,
));
)]);
}
}else{
leadings.add(DefaultDecodedLeading(
leadings.add(["Unknown call", DefaultDecodedLeading(
data: call["data"],
margin: EdgeInsets.zero,
elevation: 0,
));
)]);
}
}
setState(() {
Expand All @@ -69,10 +68,10 @@ class _DefaultMultiCallDecodeComponentState extends State<DefaultMultiCallDecode
@override
void initState() {
for (var call in widget.params[0]["calls"]){
decodedDataLeadings.add(DefaultDecodedLeading(
decodedDataLeadings.add(["...", DefaultDecodedLeading(
data: call["data"],
margin: EdgeInsets.zero,
));
)]);
}
decodeRequestData();
super.initState();
Expand All @@ -98,23 +97,23 @@ class _DefaultMultiCallDecodeComponentState extends State<DefaultMultiCallDecode
children: [
RichText(
text: TextSpan(
text: "Call ",
style: TextStyle(fontFamily: AppThemes.fonts.gilroyBold, fontSize: 17),
text: "#${i+1} ",
style: TextStyle(fontFamily: AppThemes.fonts.gilroyBold, fontSize: 8, color: Colors.grey),
children: [
TextSpan(
text: (i+1).toString(),
style: TextStyle(color: Get.theme.colorScheme.primary)
text: Utils.truncate(decodedDataLeadings[i][0].toString(), leadingDigits: 20, trailingDigits: 0),
style: TextStyle(fontFamily: AppThemes.fonts.gilroyBold, fontSize: 17, color: Colors.white),
)
]
),
),
const Spacer(),
Text(Utils.truncate(call["to"]), style: TextStyle(fontFamily: AppThemes.fonts.gilroyBold, fontSize: 12, color: Colors.grey),),
Text(Utils.truncate(call["to"], leadingDigits: 4, trailingDigits: 3), style: TextStyle(fontFamily: AppThemes.fonts.gilroyBold, fontSize: 10, color: Colors.grey),),
],
),
collapsed: const SizedBox.shrink(),
//expanded: const SizedBox.shrink(),
expanded: decodedDataLeadings[i],
expanded: decodedDataLeadings[i][1],
theme: const ExpandableThemeData(
hasIcon: true,
iconColor: Colors.white,
Expand Down

0 comments on commit 2bdcef6

Please sign in to comment.