Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add block slayer item #2398

Merged
merged 3 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion wallet/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,5 +402,6 @@
"discord": "Discord",
"twitter": "Twitter",
"connected": "In Verbindung gebracht",
"no_account_found": "Kein Konto gefunden"
"no_account_found": "Kein Konto gefunden",
"items": "Artikel"
}
3 changes: 2 additions & 1 deletion wallet/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,5 +404,6 @@
"discord": "Discord",
"twitter": "Twitter",
"connected": "Connected",
"no_account_found": "No account found"
"no_account_found": "No account found",
"items": "Items"
}
3 changes: 2 additions & 1 deletion wallet/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -401,5 +401,6 @@
"discord": "Discord",
"twitter": "Twitter",
"connected": "Conectada",
"no_account_found": "No se encontró ninguna cuenta"
"no_account_found": "No se encontró ninguna cuenta",
"items": "Elementos"
}
3 changes: 2 additions & 1 deletion wallet/i18n/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,5 +402,6 @@
"discord": "Discord",
"twitter": "Twitter",
"connected": "Terhubung",
"no_account_found": "Tidak ada akun yang ditemukan"
"no_account_found": "Tidak ada akun yang ditemukan",
"items": "Barang"
}
3 changes: 2 additions & 1 deletion wallet/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,5 +402,6 @@
"discord": "Discord",
"twitter": "Twitter",
"connected": "接続済み",
"no_account_found": "アカウントが見つかりません"
"no_account_found": "アカウントが見つかりません",
"items": "アイテム"
}
3 changes: 2 additions & 1 deletion wallet/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -401,5 +401,6 @@
"discord": "Discord",
"twitter": "Twitter",
"connected": "연결됨",
"no_account_found": "계정을 찾을 수 없습니다."
"no_account_found": "계정을 찾을 수 없습니다.",
"items": "품목"
}
3 changes: 2 additions & 1 deletion wallet/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@
"discord": "Discord",
"twitter": "Twitter",
"connected": "Связано",
"no_account_found": "Аккаунт не найден"
"no_account_found": "Аккаунт не найден",
"items": "Предметы"
}

3 changes: 2 additions & 1 deletion wallet/i18n/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,5 +402,6 @@
"discord": "Discord",
"twitter": "Twitter",
"connected": "kết nối",
"no_account_found": "Không có tài khoản nào được tìm thấy"
"no_account_found": "Không có tài khoản nào được tìm thấy",
"items": "Mặt hàng"
}
124 changes: 124 additions & 0 deletions wallet/lib/model/pylon_items.dart
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;
}
151 changes: 151 additions & 0 deletions wallet/lib/pages/home/blockslayer_screen.dart
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,
),
),
],
),
);
});
}
}
11 changes: 10 additions & 1 deletion wallet/lib/pages/home/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:pylons_wallet/components/user_image_widget.dart';
import 'package:pylons_wallet/components/maintenance_mode_widgets.dart';
import 'package:pylons_wallet/gen/assets.gen.dart';
import 'package:pylons_wallet/main_prod.dart';
import 'package:pylons_wallet/pages/home/blockslayer_screen.dart';
import 'package:pylons_wallet/pages/home/collection_screen/collection_view_model.dart';
import 'package:pylons_wallet/pages/home/home_provider.dart';
import 'package:pylons_wallet/pages/home/widget/pylons_drawer.dart';
Expand Down Expand Up @@ -46,7 +47,7 @@ class HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateMi
HomeProvider get homeProvider => GetIt.I.get();

RemoteConfigService get remoteConfigService => GetIt.I.get();
final List<Widget> pages = <Widget>[const CollectionScreen(), const WalletScreen()];
final List<Widget> pages = <Widget>[const CollectionScreen(), const WalletScreen(), const BlockSlayerScreen()];

@override
void initState() {
Expand Down Expand Up @@ -247,6 +248,10 @@ class HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateMi
WalletTab(
tabName: provider.tabs[1],
index: 1,
),
WalletTab(
tabName: provider.tabs[2],
index: 2,
)
]),
SizedBox(height: 5.h),
Expand Down Expand Up @@ -382,6 +387,10 @@ class HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateMi
WalletTab(
tabName: provider.tabs[1],
index: 1,
),
WalletTab(
tabName: provider.tabs[2],
index: 2,
)
],
),
Expand Down
Loading
Loading