clean up and test fixes

This commit is contained in:
julian 2022-11-25 17:49:47 -06:00
parent 9fce8ca107
commit 56f54ac487
3 changed files with 63 additions and 58 deletions

View file

@ -1,13 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/providers/ui/color_theme_provider.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/theme/color_theme.dart'; import 'package:stackwallet/utilities/theme/color_theme.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/conditional_parent.dart';
class Background extends ConsumerWidget { class Background extends StatelessWidget {
const Background({ const Background({
Key? key, Key? key,
required this.child, required this.child,
@ -16,12 +14,10 @@ class Background extends ConsumerWidget {
final Widget child; final Widget child;
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context) {
final colorTheme = ref.watch(colorThemeProvider.state).state;
Color? color; Color? color;
switch (colorTheme.themeType) { switch (Theme.of(context).extension<StackColors>()!.themeType) {
case ThemeType.light: case ThemeType.light:
case ThemeType.dark: case ThemeType.dark:
color = Theme.of(context).extension<StackColors>()!.background; color = Theme.of(context).extension<StackColors>()!.background;

View file

@ -131,55 +131,58 @@ class _EmojiSelectSheetState extends ConsumerState<EmojiSelectSheet> {
SizedBox( SizedBox(
height: isDesktop ? 16 : 12, height: isDesktop ? 16 : 12,
), ),
ClipRRect( Material(
borderRadius: BorderRadius.circular( color: Colors.transparent,
Constants.size.circularBorderRadius, child: ClipRRect(
), borderRadius: BorderRadius.circular(
child: TextField( Constants.size.circularBorderRadius,
autocorrect: Util.isDesktop ? false : true, ),
enableSuggestions: Util.isDesktop ? false : true, child: TextField(
controller: _searchController, autocorrect: Util.isDesktop ? false : true,
focusNode: _searchFocusNode, enableSuggestions: Util.isDesktop ? false : true,
onChanged: (newString) { controller: _searchController,
setState(() => _searchTerm = newString); focusNode: _searchFocusNode,
}, onChanged: (newString) {
style: STextStyles.field(context), setState(() => _searchTerm = newString);
decoration: standardInputDecoration( },
"Search", style: STextStyles.field(context),
_searchFocusNode, decoration: standardInputDecoration(
context, "Search",
).copyWith( _searchFocusNode,
prefixIcon: Padding( context,
padding: const EdgeInsets.symmetric( ).copyWith(
horizontal: 10, prefixIcon: Padding(
vertical: 16, padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 16,
),
child: SvgPicture.asset(
Assets.svg.search,
width: 16,
height: 16,
),
), ),
child: SvgPicture.asset( suffixIcon: _searchController.text.isNotEmpty
Assets.svg.search, ? Padding(
width: 16, padding: const EdgeInsets.only(right: 0),
height: 16, child: UnconstrainedBox(
), child: Row(
), children: [
suffixIcon: _searchController.text.isNotEmpty TextFieldIconButton(
? Padding( child: const XIcon(),
padding: const EdgeInsets.only(right: 0), onTap: () async {
child: UnconstrainedBox( setState(() {
child: Row( _searchController.text = "";
children: [ _searchTerm = "";
TextFieldIconButton( });
child: const XIcon(), },
onTap: () async { ),
setState(() { ],
_searchController.text = ""; ),
_searchTerm = "";
});
},
),
],
), ),
), )
) : null,
: null, ),
), ),
), ),
), ),

View file

@ -1,8 +1,8 @@
import 'package:emojis/emoji.dart'; import 'package:emojis/emoji.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:mockingjay/mockingjay.dart' as mockingjay;
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:mockingjay/mockingjay.dart' as mockingjay;
import 'package:stackwallet/utilities/theme/light_colors.dart'; import 'package:stackwallet/utilities/theme/light_colors.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/emoji_select_sheet.dart'; import 'package:stackwallet/widgets/emoji_select_sheet.dart';
@ -43,15 +43,21 @@ void main() {
], ],
), ),
home: mockingjay.MockNavigatorProvider( home: mockingjay.MockNavigatorProvider(
navigator: navigator, child: emojiSelectSheet), navigator: navigator,
child: Column(
children: const [
Expanded(child: emojiSelectSheet),
],
),
),
), ),
), ),
); );
final gestureDetector = find.byType(GestureDetector).first; final gestureDetector = find.byType(GestureDetector).at(5);
expect(gestureDetector, findsOneWidget); expect(gestureDetector, findsOneWidget);
final emoji = Emoji.all()[0]; final emoji = Emoji.byChar("😅");
await tester.tap(gestureDetector); await tester.tap(gestureDetector);
await tester.pumpAndSettle(); await tester.pumpAndSettle();