- Fix scroll issue

- Add ERC20 tokens placeholder image in picker
This commit is contained in:
OmarHatem 2023-07-06 03:00:01 +03:00
parent eb78d12f9b
commit 6bbe95fa5e
2 changed files with 105 additions and 98 deletions

View file

@ -96,13 +96,16 @@ class HomeSettingsPage extends BasePage {
),
],
),
Observer(
Padding(
padding: const EdgeInsets.only(bottom: 16, left: 16, right: 16),
child: Observer(
builder: (_) => ListView.builder(
itemCount: _homeSettingsViewModel.tokens.length,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
return Container(
margin: EdgeInsets.only(top: 16, left: 16, right: 16),
margin: EdgeInsets.only(top: 16),
child: Observer(
builder: (_) {
final token = _homeSettingsViewModel.tokens.elementAt(index);
@ -153,6 +156,7 @@ class HomeSettingsPage extends BasePage {
},
),
),
),
],
),
);

View file

@ -1,5 +1,7 @@
// ignore_for_file: deprecated_member_use
import 'dart:math';
import 'package:cake_wallet/utils/responsive_layout_util.dart';
import 'package:flutter/material.dart';
import 'package:cw_core/currency.dart';
@ -144,8 +146,7 @@ class _PickerState<Item> extends State<Picker<Item>> {
borderRadius: BorderRadius.all(Radius.circular(30)),
child: Container(
color: Theme.of(context)
.accentTextTheme!
.titleLarge!
.accentTextTheme.titleLarge!
.color!,
child: ConstrainedBox(
constraints: BoxConstraints(
@ -162,8 +163,7 @@ class _PickerState<Item> extends State<Picker<Item>> {
controller: searchController,
style: TextStyle(
color: Theme.of(context)
.primaryTextTheme!
.titleLarge!
.primaryTextTheme.titleLarge!
.color!),
decoration: InputDecoration(
hintText: widget.hintText,
@ -171,8 +171,7 @@ class _PickerState<Item> extends State<Picker<Item>> {
Image.asset("assets/images/search_icon.png"),
filled: true,
fillColor: Theme.of(context)
.accentTextTheme!
.displaySmall!
.accentTextTheme.displaySmall!
.color!,
alignLabelWithHint: false,
contentPadding: const EdgeInsets.symmetric(
@ -192,8 +191,7 @@ class _PickerState<Item> extends State<Picker<Item>> {
),
Divider(
color: Theme.of(context)
.accentTextTheme!
.titleLarge!
.accentTextTheme.titleLarge!
.backgroundColor!,
height: 1,
),
@ -223,8 +221,7 @@ class _PickerState<Item> extends State<Picker<Item>> {
fontFamily: 'Lato',
decoration: TextDecoration.none,
color: Theme.of(context)
.primaryTextTheme!
.titleLarge!
.primaryTextTheme.titleLarge!
.color!,
),
),
@ -246,8 +243,7 @@ class _PickerState<Item> extends State<Picker<Item>> {
Widget itemsList() {
return Container(
color: Theme.of(context)
.accentTextTheme!
.titleLarge!
.accentTextTheme.titleLarge!
.backgroundColor!,
child: widget.isGridView
? GridView.builder(
@ -269,8 +265,7 @@ class _PickerState<Item> extends State<Picker<Item>> {
separatorBuilder: (context, index) => widget.isSeparated
? Divider(
color: Theme.of(context)
.accentTextTheme!
.titleLarge!
.accentTextTheme.titleLarge!
.backgroundColor!,
height: 1,
)
@ -283,15 +278,9 @@ class _PickerState<Item> extends State<Picker<Item>> {
Widget buildItem(int index) {
final item = filteredItems[index];
final tag = item is Currency ? item.tag : null;
final icon = item is Currency && item.iconPath != null
? Image.asset(
item.iconPath!,
height: 20.0,
width: 20.0,
)
: null;
final tag = item is Currency ? item.tag : null;
final icon = _getItemIcon(item);
final image = images.isNotEmpty ? filteredImages[index] : icon;
@ -303,8 +292,7 @@ class _PickerState<Item> extends State<Picker<Item>> {
child: Container(
height: 55,
color: Theme.of(context)
.accentTextTheme!
.titleLarge!
.accentTextTheme.titleLarge!
.color!,
padding: EdgeInsets.symmetric(horizontal: 24),
child: Row(
@ -327,8 +315,7 @@ class _PickerState<Item> extends State<Picker<Item>> {
fontFamily: 'Lato',
fontWeight: FontWeight.w600,
color: Theme.of(context)
.primaryTextTheme!
.titleLarge!
.primaryTextTheme.titleLarge!
.color!,
decoration: TextDecoration.none,
),
@ -347,8 +334,7 @@ class _PickerState<Item> extends State<Picker<Item>> {
fontSize: 7.0,
fontFamily: 'Lato',
color: Theme.of(context)
.textTheme!
.bodyMedium!
.textTheme.bodyMedium!
.color!),
),
),
@ -356,8 +342,7 @@ class _PickerState<Item> extends State<Picker<Item>> {
borderRadius: BorderRadius.circular(6.0),
//border: Border.all(color: ),
color: Theme.of(context)
.textTheme!
.bodyMedium!
.textTheme.bodyMedium!
.decorationColor!,
),
),
@ -374,15 +359,9 @@ class _PickerState<Item> extends State<Picker<Item>> {
Widget buildSelectedItem(int index) {
final item = items[index];
final tag = item is Currency ? item.tag : null;
final icon = item is Currency && item.iconPath != null
? Image.asset(
item.iconPath!,
height: 20.0,
width: 20.0,
)
: null;
final tag = item is Currency ? item.tag : null;
final icon = _getItemIcon(item);
final image = images.isNotEmpty ? images[index] : icon;
@ -393,8 +372,7 @@ class _PickerState<Item> extends State<Picker<Item>> {
child: Container(
height: 55,
color: Theme.of(context)
.accentTextTheme!
.titleLarge!
.accentTextTheme.titleLarge!
.color!,
padding: EdgeInsets.symmetric(horizontal: 24),
child: Row(
@ -417,8 +395,7 @@ class _PickerState<Item> extends State<Picker<Item>> {
fontFamily: 'Lato',
fontWeight: FontWeight.w700,
color: Theme.of(context)
.primaryTextTheme!
.titleLarge!
.primaryTextTheme.titleLarge!
.color!,
decoration: TextDecoration.none,
),
@ -437,8 +414,7 @@ class _PickerState<Item> extends State<Picker<Item>> {
fontSize: 7.0,
fontFamily: 'Lato',
color: Theme.of(context)
.textTheme!
.bodyMedium!
.textTheme.bodyMedium!
.color!),
),
),
@ -446,8 +422,7 @@ class _PickerState<Item> extends State<Picker<Item>> {
borderRadius: BorderRadius.circular(6.0),
//border: Border.all(color: ),
color: Theme.of(context)
.textTheme!
.bodyMedium!
.textTheme.bodyMedium!
.decorationColor!,
),
),
@ -458,12 +433,40 @@ class _PickerState<Item> extends State<Picker<Item>> {
),
Icon(Icons.check_circle,
color: Theme.of(context)
.accentTextTheme!
.bodyLarge!
.accentTextTheme.bodyLarge!
.color!),
],
),
),
);
}
Widget? _getItemIcon(Item item) {
if (item is Currency) {
if (item.iconPath != null) {
return Image.asset(
item.iconPath!,
height: 20.0,
width: 20.0,
);
} else {
return Container(
height: 20.0,
width: 20.0,
child: Center(
child: Text(
item.name.substring(0, min(item.name.length, 2)).toUpperCase(),
style: TextStyle(fontSize: 11),
),
),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.grey.shade400,
),
);
}
}
return null;
}
}