2023-07-18 16:15:05 +00:00
|
|
|
/*
|
|
|
|
* 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:flutter_svg/svg.dart';
|
|
|
|
import 'package:stackwallet/models/ordinal.dart';
|
2023-07-18 17:48:15 +00:00
|
|
|
import 'package:stackwallet/pages/ordinals/ordinals_filter_view.dart';
|
2023-07-18 17:26:43 +00:00
|
|
|
import 'package:stackwallet/pages/ordinals/widgets/ordinals_list.dart';
|
2023-07-20 21:30:39 +00:00
|
|
|
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
|
|
|
// import 'package:stackwallet/services/litescribe_api.dart';
|
|
|
|
// import 'package:stackwallet/services/ordinals_api.dart';
|
2023-07-19 20:58:34 +00:00
|
|
|
import 'package:stackwallet/services/mixins/ordinals_interface.dart';
|
2023-07-18 16:15:05 +00:00
|
|
|
import 'package:stackwallet/themes/stack_colors.dart';
|
|
|
|
import 'package:stackwallet/utilities/assets.dart';
|
|
|
|
import 'package:stackwallet/utilities/constants.dart';
|
|
|
|
import 'package:stackwallet/utilities/text_styles.dart';
|
|
|
|
import 'package:stackwallet/utilities/util.dart';
|
|
|
|
import 'package:stackwallet/widgets/background.dart';
|
|
|
|
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
|
|
|
import 'package:stackwallet/widgets/icon_widgets/x_icon.dart';
|
|
|
|
import 'package:stackwallet/widgets/stack_text_field.dart';
|
|
|
|
import 'package:stackwallet/widgets/textfield_icon_button.dart';
|
|
|
|
|
2023-07-20 21:30:39 +00:00
|
|
|
|
2023-07-18 16:15:05 +00:00
|
|
|
class OrdinalsView extends ConsumerStatefulWidget {
|
|
|
|
const OrdinalsView({
|
|
|
|
super.key,
|
|
|
|
required this.walletId,
|
|
|
|
});
|
|
|
|
|
|
|
|
static const routeName = "/ordinalsView";
|
|
|
|
|
|
|
|
final String walletId;
|
|
|
|
|
|
|
|
@override
|
|
|
|
ConsumerState<OrdinalsView> createState() => _OrdinalsViewState();
|
|
|
|
}
|
|
|
|
|
2023-07-19 20:58:34 +00:00
|
|
|
class _OrdinalsViewState extends ConsumerState<OrdinalsView> with OrdinalsInterface {
|
2023-07-18 16:15:05 +00:00
|
|
|
late final TextEditingController searchController;
|
|
|
|
late final FocusNode searchFocus;
|
|
|
|
|
|
|
|
String _searchTerm = "";
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
searchController = TextEditingController();
|
|
|
|
searchFocus = FocusNode();
|
2023-07-19 20:58:34 +00:00
|
|
|
|
2023-07-18 16:15:05 +00:00
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
searchController.dispose();
|
|
|
|
searchFocus.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Background(
|
|
|
|
child: SafeArea(
|
|
|
|
child: Scaffold(
|
|
|
|
backgroundColor:
|
|
|
|
Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
appBar: AppBar(
|
|
|
|
automaticallyImplyLeading: false,
|
|
|
|
leading: const AppBarBackButton(),
|
|
|
|
title: Text(
|
|
|
|
"Ordinals",
|
|
|
|
style: STextStyles.navBarTitle(context),
|
|
|
|
),
|
|
|
|
titleSpacing: 0,
|
|
|
|
actions: [
|
|
|
|
AspectRatio(
|
|
|
|
aspectRatio: 1,
|
|
|
|
child: AppBarIconButton(
|
|
|
|
size: 36,
|
|
|
|
icon: SvgPicture.asset(
|
|
|
|
Assets.svg.arrowRotate,
|
|
|
|
width: 20,
|
|
|
|
height: 20,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.topNavIconPrimary,
|
|
|
|
),
|
2023-07-20 20:32:39 +00:00
|
|
|
onPressed: () async {
|
|
|
|
refreshInscriptions();
|
2023-07-18 16:15:05 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
AspectRatio(
|
|
|
|
aspectRatio: 1,
|
|
|
|
child: AppBarIconButton(
|
|
|
|
size: 36,
|
|
|
|
icon: SvgPicture.asset(
|
|
|
|
Assets.svg.filter,
|
|
|
|
width: 20,
|
|
|
|
height: 20,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.topNavIconPrimary,
|
|
|
|
),
|
|
|
|
onPressed: () {
|
2023-07-18 17:48:15 +00:00
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
OrdinalsFilterView.routeName,
|
|
|
|
);
|
2023-07-18 16:15:05 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
body: Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
left: 16,
|
|
|
|
right: 16,
|
|
|
|
top: 8,
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
ClipRRect(
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
Constants.size.circularBorderRadius,
|
|
|
|
),
|
|
|
|
child: TextField(
|
|
|
|
autocorrect: Util.isDesktop ? false : true,
|
|
|
|
enableSuggestions: Util.isDesktop ? false : true,
|
|
|
|
controller: searchController,
|
|
|
|
focusNode: searchFocus,
|
|
|
|
onChanged: (value) {
|
|
|
|
setState(() {
|
|
|
|
_searchTerm = value;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
style: STextStyles.field(context),
|
|
|
|
decoration: standardInputDecoration(
|
|
|
|
"Search",
|
|
|
|
searchFocus,
|
|
|
|
context,
|
|
|
|
).copyWith(
|
|
|
|
prefixIcon: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
horizontal: 10,
|
|
|
|
vertical: 16,
|
|
|
|
),
|
|
|
|
child: SvgPicture.asset(
|
|
|
|
Assets.svg.search,
|
|
|
|
width: 16,
|
|
|
|
height: 16,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
suffixIcon: searchController.text.isNotEmpty
|
|
|
|
? Padding(
|
|
|
|
padding: const EdgeInsets.only(right: 0),
|
|
|
|
child: UnconstrainedBox(
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
TextFieldIconButton(
|
|
|
|
child: const XIcon(),
|
|
|
|
onTap: () async {
|
|
|
|
setState(() {
|
|
|
|
searchController.text = "";
|
|
|
|
_searchTerm = "";
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: null,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 16,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: OrdinalsList(
|
2023-07-18 17:03:57 +00:00
|
|
|
walletId: widget.walletId,
|
2023-07-18 16:15:05 +00:00
|
|
|
ordinals: [
|
|
|
|
for (int i = 0; i < 13; i++)
|
|
|
|
Ordinal(
|
|
|
|
name: "dummy name $i",
|
|
|
|
inscription: "insc$i",
|
|
|
|
rank: "r$i",
|
2023-07-20 19:05:51 +00:00
|
|
|
collection: OrdCollection.moonbirds,
|
|
|
|
utxoTXID: 'txid',
|
|
|
|
utxoVOUT: 1
|
2023-07-18 16:15:05 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|