-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2398 from Pylons-tech/feat/AddBlockSlayerItem
Feat/add block slayer item
- Loading branch information
Showing
14 changed files
with
408 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
class PylonItems { | ||
final String owner; | ||
final String cookBookId; | ||
final String id; | ||
final String nodeVersion; | ||
final bool tradeAble; | ||
final String lastUpdate; | ||
final String tradePercentage; | ||
final String createdAt; | ||
final String updatedAt; | ||
final String recipeId; | ||
|
||
final List<KeyValue> doubles; | ||
final List<KeyValue> longs; | ||
final List<KeyValue> Strings; | ||
final List<DenomAmount> transferAmount; | ||
|
||
PylonItems({ | ||
required this.owner, | ||
required this.cookBookId, | ||
required this.id, | ||
required this.nodeVersion, | ||
required this.tradeAble, | ||
required this.lastUpdate, | ||
required this.tradePercentage, | ||
required this.createdAt, | ||
required this.updatedAt, | ||
required this.recipeId, | ||
required this.doubles, | ||
required this.longs, | ||
required this.Strings, | ||
required this.transferAmount, | ||
}); | ||
|
||
factory PylonItems.fromJson(Map<String, dynamic> json) { | ||
final List<KeyValue> doubles = []; | ||
|
||
json["doubles"].map((e) { | ||
final keyValue = KeyValue.fromJson(e as Map<String, dynamic>); | ||
doubles.add(keyValue); | ||
}).toList(); | ||
|
||
final List<KeyValue> longs = []; | ||
|
||
json["longs"].map((e) { | ||
final keyValue = KeyValue.fromJson(e as Map<String, dynamic>); | ||
longs.add(keyValue); | ||
}).toList(); | ||
|
||
final List<KeyValue> Strings = []; | ||
|
||
json["strings"].map((e) { | ||
final keyValue = KeyValue.fromJson(e as Map<String, dynamic>); | ||
Strings.add(keyValue); | ||
}).toList(); | ||
|
||
final List<DenomAmount> transferAmount = []; | ||
|
||
json["transfer_fee"].map((e) { | ||
final denomAmount = DenomAmount.fromJson(e as Map<String, dynamic>); | ||
transferAmount.add(denomAmount); | ||
}).toList(); | ||
|
||
return PylonItems( | ||
owner: json["owner"] as String, | ||
cookBookId: json["cookbook_id"] as String, | ||
id: json["id"] as String, | ||
nodeVersion: json["node_version"] as String, | ||
tradeAble: json["tradeable"] as bool, | ||
lastUpdate: json["last_update"] as String, | ||
tradePercentage: json["trade_percentage"] as String, | ||
createdAt: json["created_at"] as String, | ||
updatedAt: json["updated_at"] as String, | ||
recipeId: json["recipe_id"] as String, | ||
doubles: doubles.toList(), | ||
longs: longs.toList(), | ||
Strings: Strings.toList(), | ||
transferAmount: transferAmount.toList(), | ||
); | ||
} | ||
} | ||
|
||
class KeyValue { | ||
KeyValue({required this.key, required this.value}); | ||
|
||
final String key; | ||
final String value; | ||
|
||
factory KeyValue.fromJson(Map<String, dynamic> json) { | ||
return KeyValue(key: json["key"] as String, value: json["value"] as String); | ||
} | ||
} | ||
|
||
class DenomAmount { | ||
final String denom; | ||
final String amount; | ||
|
||
DenomAmount({required this.denom, required this.amount}); | ||
|
||
factory DenomAmount.fromJson(Map<String, dynamic> json) { | ||
return DenomAmount(denom: json["denom"] as String, amount: json["amount"] as String); | ||
} | ||
} | ||
|
||
|
||
class NonEaselItemModel { | ||
NonEaselItemModel( { | ||
required this.cookBookId, | ||
required this.coins, | ||
required this.currentHp, | ||
required this.shards, | ||
required this.swordLevel, | ||
required this.wins, | ||
required this.maxHp, | ||
}); | ||
|
||
final String cookBookId; | ||
final String coins; | ||
final String currentHp; | ||
final String shards; | ||
final String swordLevel; | ||
final String wins; | ||
final String maxHp; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:pylons_wallet/model/pylon_items.dart'; | ||
import 'package:pylons_wallet/pages/home/home_provider.dart'; | ||
|
||
final _kItemStyle = TextStyle(color: Colors.black, fontSize: 9.sp); | ||
|
||
final _kHeadingStyle = TextStyle(color: Colors.black, fontSize: 9.sp, fontWeight: FontWeight.bold); | ||
|
||
class BlockSlayerScreen extends StatefulWidget { | ||
const BlockSlayerScreen({super.key}); | ||
|
||
@override | ||
State<BlockSlayerScreen> createState() => _BlockSlayerScreenState(); | ||
} | ||
|
||
class _BlockSlayerScreenState extends State<BlockSlayerScreen> { | ||
@override | ||
void initState() { | ||
super.initState(); | ||
context.read<HomeProvider>().getPylonList(); | ||
} | ||
|
||
Widget _getRow({required NonEaselItemModel nonEaselItemModel}) { | ||
return Row( | ||
children: [ | ||
Expanded( | ||
child: Text( | ||
nonEaselItemModel.cookBookId, | ||
style: _kItemStyle, | ||
textAlign: TextAlign.center, | ||
)), | ||
Expanded( | ||
child: Text( | ||
nonEaselItemModel.coins, | ||
style: _kItemStyle, | ||
textAlign: TextAlign.center, | ||
)), | ||
Expanded( | ||
child: Text( | ||
nonEaselItemModel.currentHp, | ||
style: _kItemStyle, | ||
textAlign: TextAlign.center, | ||
)), | ||
Expanded( | ||
child: Text( | ||
nonEaselItemModel.maxHp, | ||
style: _kItemStyle, | ||
textAlign: TextAlign.center, | ||
)), | ||
Expanded( | ||
child: Text( | ||
nonEaselItemModel.shards, | ||
style: _kItemStyle, | ||
textAlign: TextAlign.center, | ||
)), | ||
Expanded( | ||
child: Text( | ||
nonEaselItemModel.swordLevel, | ||
style: _kItemStyle, | ||
textAlign: TextAlign.center, | ||
)), | ||
Expanded( | ||
child: Text( | ||
nonEaselItemModel.wins, | ||
style: _kItemStyle, | ||
textAlign: TextAlign.center, | ||
)), | ||
], | ||
); | ||
} | ||
|
||
Widget _getRowHeading() { | ||
return Row( | ||
children: [ | ||
Expanded( | ||
child: Text( | ||
"CookBook", | ||
style: _kHeadingStyle, | ||
textAlign: TextAlign.center, | ||
)), | ||
Expanded( | ||
child: Text( | ||
"Coins", | ||
style: _kHeadingStyle, | ||
textAlign: TextAlign.center, | ||
)), | ||
Expanded( | ||
child: Text( | ||
"Hp", | ||
style: _kHeadingStyle, | ||
textAlign: TextAlign.center, | ||
)), | ||
Expanded( | ||
child: Text( | ||
"Max Hp", | ||
style: _kHeadingStyle, | ||
textAlign: TextAlign.center, | ||
)), | ||
Expanded( | ||
child: Text( | ||
"Shards", | ||
style: _kHeadingStyle, | ||
textAlign: TextAlign.center, | ||
)), | ||
Expanded( | ||
child: Text( | ||
"Level", | ||
style: _kHeadingStyle, | ||
textAlign: TextAlign.center, | ||
)), | ||
Expanded( | ||
child: Text( | ||
"Wins", | ||
style: _kHeadingStyle, | ||
textAlign: TextAlign.center, | ||
)), | ||
], | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Consumer<HomeProvider>(builder: (context, provider, _) { | ||
final noEaselPylonItemList = provider.getNoNEaselItems(); | ||
|
||
return Padding( | ||
padding: EdgeInsets.symmetric(horizontal: 10.w), | ||
child: Column( | ||
children: [ | ||
SizedBox(height: 20.h), | ||
if (noEaselPylonItemList.isNotEmpty) _getRowHeading(), | ||
SizedBox(height: 20.h), | ||
Expanded( | ||
child: ListView.separated( | ||
itemBuilder: (context, index) { | ||
return _getRow(nonEaselItemModel: noEaselPylonItemList[index]); | ||
}, | ||
separatorBuilder: (_, __) => SizedBox( | ||
height: 30.h, | ||
), | ||
itemCount: noEaselPylonItemList.length, | ||
), | ||
), | ||
], | ||
), | ||
); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.