gecko/lib/screens/search_result.dart

184 lines
8.5 KiB
Dart
Raw Normal View History

2022-06-18 01:50:06 +02:00
import 'package:easy_localization/easy_localization.dart';
2021-11-23 04:11:45 +01:00
import 'package:flutter/services.dart';
import 'package:gecko/globals.dart';
import 'package:flutter/material.dart';
import 'package:gecko/models/widgets_keys.dart';
import 'package:gecko/providers/cesium_plus.dart';
import 'package:gecko/models/g1_wallets_list.dart';
2022-06-15 01:14:23 +02:00
import 'package:gecko/providers/duniter_indexer.dart';
import 'package:gecko/providers/home.dart';
2022-05-28 00:17:50 +02:00
import 'package:gecko/providers/substrate_sdk.dart';
2022-05-21 06:47:26 +02:00
import 'package:gecko/providers/wallet_options.dart';
import 'package:gecko/providers/wallets_profiles.dart';
import 'package:gecko/providers/search.dart';
import 'package:gecko/screens/common_elements.dart';
2021-11-30 01:25:48 +01:00
import 'package:gecko/screens/wallet_view.dart';
2021-11-23 04:11:45 +01:00
import 'package:provider/provider.dart';
class SearchResultScreen extends StatelessWidget {
2021-12-23 12:36:09 +01:00
const SearchResultScreen({Key? key}) : super(key: key);
2021-11-23 04:11:45 +01:00
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
SearchProvider searchProvider =
2021-11-30 10:28:13 +01:00
Provider.of<SearchProvider>(context, listen: false);
CesiumPlusProvider cesiumPlusProvider =
2021-11-30 10:28:13 +01:00
Provider.of<CesiumPlusProvider>(context, listen: false);
WalletsProfilesProvider walletsProfilesClass =
2021-11-30 01:25:48 +01:00
Provider.of<WalletsProfilesProvider>(context, listen: false);
HomeProvider homeProvider =
Provider.of<HomeProvider>(context, listen: false);
DuniterIndexer duniterIndexer =
2022-06-15 01:14:23 +02:00
Provider.of<DuniterIndexer>(context, listen: false);
double avatarSize = 55;
2021-11-23 04:11:45 +01:00
return Scaffold(
2022-05-29 00:00:57 +02:00
backgroundColor: backgroundColor,
2021-11-23 04:11:45 +01:00
appBar: AppBar(
2022-05-28 06:12:39 +02:00
elevation: 1,
2021-11-23 04:11:45 +01:00
toolbarHeight: 60 * ratio,
2022-06-18 01:50:06 +02:00
title: SizedBox(
2021-11-23 04:11:45 +01:00
height: 22,
2022-06-18 01:50:06 +02:00
child: Text('researchResults'.tr()),
2021-11-23 04:11:45 +01:00
),
),
bottomNavigationBar: homeProvider.bottomAppBar(context),
2021-11-23 04:11:45 +01:00
body: SafeArea(
child: Stack(children: [
Padding(
2022-09-11 13:14:52 +02:00
padding: const EdgeInsets.only(left: 15, right: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const SizedBox(height: 30),
RichText(
text: TextSpan(
style: TextStyle(
fontSize: 18,
color: Colors.grey[700],
2022-05-30 15:32:00 +02:00
),
children: <TextSpan>[
2022-06-18 01:50:06 +02:00
TextSpan(
text: "resultsFor".tr(),
),
TextSpan(
text: '"${searchProvider.searchController.text}"',
style: const TextStyle(fontStyle: FontStyle.italic),
),
],
),
),
const SizedBox(height: 40),
Text(
2022-06-18 03:01:22 +02:00
'inBlockchainResult'.tr(args: [currencyName]),
style: const TextStyle(fontSize: 20),
2021-11-30 01:25:48 +01:00
),
const SizedBox(height: 20),
FutureBuilder(
future: searchProvider.searchAddress(),
builder: (context, AsyncSnapshot<List?> snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.data?.isEmpty ?? true) {
return duniterIndexer.searchIdentity(
context, searchProvider.searchController.text);
2022-06-15 01:14:23 +02:00
// const Text('Aucun résultat');
} else {
return Expanded(
child: ListView(children: <Widget>[
for (G1WalletsList g1Wallet
in snapshot.data ?? [])
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 5),
child: ListTile(
key: keySearchResult(g1Wallet.address),
horizontalTitleGap: 40,
contentPadding: const EdgeInsets.all(5),
leading: cesiumPlusProvider
.defaultAvatar(avatarSize),
title: Row(children: <Widget>[
Text(getShortPubkey(g1Wallet.address),
style: const TextStyle(
fontSize: 18,
fontFamily: 'Monospace',
fontWeight: FontWeight.w500),
textAlign: TextAlign.center),
]),
trailing: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
2022-09-11 13:14:52 +02:00
SizedBox(
width: 110,
child: Row(
mainAxisAlignment:
MainAxisAlignment.end,
children: [
Column(
mainAxisAlignment:
MainAxisAlignment
.center,
children: [
balance(
context,
g1Wallet.address,
2022-09-11 13:14:52 +02:00
16),
]),
]),
),
]),
subtitle: Row(children: <Widget>[
duniterIndexer.getNameByAddress(
context, g1Wallet.address)
]),
dense: false,
isThreeLine: false,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
walletsProfilesClass.address =
g1Wallet.address;
return WalletViewScreen(
address: g1Wallet.address,
username: g1WalletsBox
.get(g1Wallet.address)
?.id
?.username,
avatar: g1WalletsBox
.get(g1Wallet.address)
?.avatar,
);
}),
);
}),
),
]),
);
}
2022-05-30 15:32:00 +02:00
}
return Center(
heightFactor: 5,
child: CircularProgressIndicator(
strokeWidth: 3,
backgroundColor: yellowC,
color: orangeC,
),
);
},
),
// Text(
// _searchProvider.searchResult.toString(),
// )
]),
),
CommonElements().offlineInfo(context),
]),
2021-11-23 04:11:45 +01:00
),
);
}
}