mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
203 lines
5.4 KiB
Dart
203 lines
5.4 KiB
Dart
/*
|
|
* This file is part of Stack Wallet.
|
|
*
|
|
* Copyright (c) 2023 Cypher Stack
|
|
* All Rights Reserved.
|
|
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
|
* Generated by Cypher Stack on 2023-05-26
|
|
*
|
|
*/
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:isar/isar.dart';
|
|
import '../../db/isar/main_db.dart';
|
|
import '../../models/isar/models/isar_models.dart';
|
|
import '../../themes/stack_colors.dart';
|
|
import '../../utilities/text_styles.dart';
|
|
import '../../utilities/util.dart';
|
|
import '../../widgets/background.dart';
|
|
import '../../widgets/conditional_parent.dart';
|
|
import '../../widgets/custom_buttons/app_bar_icon_button.dart';
|
|
import '../../widgets/custom_buttons/simple_copy_button.dart';
|
|
import '../../widgets/rounded_white_container.dart';
|
|
|
|
class TokenContractDetailsView extends ConsumerStatefulWidget {
|
|
const TokenContractDetailsView({
|
|
super.key,
|
|
required this.contractAddress,
|
|
required this.walletId,
|
|
});
|
|
|
|
static const String routeName = "/tokenContractDetailsView";
|
|
|
|
final String contractAddress;
|
|
final String walletId;
|
|
|
|
@override
|
|
ConsumerState<TokenContractDetailsView> createState() =>
|
|
_TokenContractDetailsViewState();
|
|
}
|
|
|
|
class _TokenContractDetailsViewState
|
|
extends ConsumerState<TokenContractDetailsView> {
|
|
final isDesktop = Util.isDesktop;
|
|
|
|
late EthContract contract;
|
|
|
|
@override
|
|
void initState() {
|
|
contract = MainDB.instance.isar.ethContracts
|
|
.where()
|
|
.addressEqualTo(widget.contractAddress)
|
|
.findFirstSync()!;
|
|
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ConditionalParent(
|
|
condition: !isDesktop,
|
|
builder: (child) => Background(
|
|
child: Scaffold(
|
|
backgroundColor:
|
|
Theme.of(context).extension<StackColors>()!.background,
|
|
appBar: AppBar(
|
|
backgroundColor:
|
|
Theme.of(context).extension<StackColors>()!.backgroundAppBar,
|
|
leading: AppBarBackButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
titleSpacing: 0,
|
|
title: Text(
|
|
"Contract details",
|
|
style: STextStyles.navBarTitle(context),
|
|
),
|
|
),
|
|
body: SafeArea(
|
|
child: LayoutBuilder(
|
|
builder: (builderContext, constraints) {
|
|
return SingleChildScrollView(
|
|
child: ConstrainedBox(
|
|
constraints: BoxConstraints(
|
|
minHeight: constraints.maxHeight,
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: child,
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
_Item(
|
|
title: "Contract address",
|
|
data: contract.address,
|
|
button: SimpleCopyButton(
|
|
data: contract.address,
|
|
),
|
|
),
|
|
const SizedBox(
|
|
height: 12,
|
|
),
|
|
_Item(
|
|
title: "Name",
|
|
data: contract.name,
|
|
button: SimpleCopyButton(
|
|
data: contract.name,
|
|
),
|
|
),
|
|
const SizedBox(
|
|
height: 12,
|
|
),
|
|
_Item(
|
|
title: "Symbol",
|
|
data: contract.symbol,
|
|
button: SimpleCopyButton(
|
|
data: contract.symbol,
|
|
),
|
|
),
|
|
const SizedBox(
|
|
height: 12,
|
|
),
|
|
_Item(
|
|
title: "Type",
|
|
data: contract.type.name,
|
|
button: SimpleCopyButton(
|
|
data: contract.type.name,
|
|
),
|
|
),
|
|
const SizedBox(
|
|
height: 12,
|
|
),
|
|
_Item(
|
|
title: "Decimals",
|
|
data: contract.decimals.toString(),
|
|
button: SimpleCopyButton(
|
|
data: contract.decimals.toString(),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _Item extends StatelessWidget {
|
|
const _Item({
|
|
super.key,
|
|
required this.title,
|
|
required this.data,
|
|
required this.button,
|
|
});
|
|
|
|
final String title;
|
|
final String data;
|
|
final Widget button;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return RoundedWhiteContainer(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: STextStyles.itemSubtitle(context),
|
|
),
|
|
button,
|
|
],
|
|
),
|
|
const SizedBox(
|
|
height: 5,
|
|
),
|
|
data.isNotEmpty
|
|
? SelectableText(
|
|
data,
|
|
style: STextStyles.w500_14(context),
|
|
)
|
|
: Text(
|
|
"$title will appear here",
|
|
style: STextStyles.w500_14(context).copyWith(
|
|
color: Theme.of(context)
|
|
.extension<StackColors>()!
|
|
.textSubtitle3,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|