Skip to content

Commit

Permalink
drop focus from searchtextfield on change view
Browse files Browse the repository at this point in the history
  • Loading branch information
yurydemin committed Jun 9, 2021
1 parent ee82de8 commit 124bbe0
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions lib/content/shelters/shelters_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ class SheltersView extends StatelessWidget {
),
IconButton(
icon: Icon(isLoggedIn ? Icons.home : Icons.login),
onPressed: () => isLoggedIn
? context.read<ContentCubit>().showShelterProfile()
: context.read<ContentCubit>().showAuth(),
onPressed: () {
_dropFocusNode(context);
isLoggedIn
? context.read<ContentCubit>().showShelterProfile()
: context.read<ContentCubit>().showAuth();
},
),
],
),
Expand Down Expand Up @@ -123,9 +126,12 @@ class SheltersView extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
ShelterCard(
onTap: () => context
.read<ContentCubit>()
.showShelterProfile(selectedShelter: shelter),
onTap: () {
_dropFocusNode(context);
context
.read<ContentCubit>()
.showShelterProfile(selectedShelter: shelter);
},
shelter: shelter,
avatarUrl: avatarsKeyUrl.containsKey(shelter.avatarKey)
? avatarsKeyUrl[shelter.avatarKey]
Expand All @@ -143,13 +149,13 @@ class SheltersView extends StatelessWidget {
return Padding(
padding: const EdgeInsets.only(left: 24.0),
child: PetCard(
avatarUrl: avatarUrl,
pet: pet,
onTap: () => context
.read<ContentCubit>()
.showPetProfile(
selectedShelter: shelter, selectedPet: pet),
),
avatarUrl: avatarUrl,
pet: pet,
onTap: () {
_dropFocusNode(context);
context.read<ContentCubit>().showPetProfile(
selectedShelter: shelter, selectedPet: pet);
}),
);
}).toList(),
],
Expand All @@ -159,6 +165,13 @@ class SheltersView extends StatelessWidget {
},
);
}

void _dropFocusNode(BuildContext context) {
FocusScopeNode curentScope = FocusScope.of(context);
if (!curentScope.hasPrimaryFocus && curentScope.hasFocus) {
FocusManager.instance.primaryFocus.unfocus();
}
}
}

class OneTapTooltip extends StatelessWidget {
Expand Down

0 comments on commit 124bbe0

Please sign in to comment.