Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide bottom bar if on-screen keyboard is visible. Dismiss keyboard on tap #1058

Merged
merged 4 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changes/1058-bottom-bar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [fix] Overflow error of feature sections in quick jump on small screens
- [UX] hide the bottom navigation when the on-screen keyboard is visible (to regain some space)
- [UX] dismiss the on-screen keyboard by tapping anywhere non-interactive
13 changes: 13 additions & 0 deletions app/lib/common/providers/keyboard_visbility_provider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:flutter/rendering.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

final keyboardVisibleProvider = StreamProvider<bool>((ref) async* {
final keyboardVisibilityController = KeyboardVisibilityController();
yield keyboardVisibilityController.isVisible;

await for (final keyboardState in keyboardVisibilityController.onChange) {
debugPrint('keyboard visibility changed to: $keyboardState');
yield keyboardState;
}
});
134 changes: 71 additions & 63 deletions app/lib/features/home/pages/home_shell.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:io';

import 'package:acter/common/dialogs/logout_confirmation.dart';
import 'package:acter/common/providers/keyboard_visbility_provider.dart';
import 'package:acter/common/themes/app_theme.dart';
import 'package:acter/features/activities/providers/notifications_providers.dart';
import 'package:acter/features/home/providers/client_providers.dart';
Expand All @@ -10,6 +11,7 @@ import 'package:acter/common/utils/routes.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
Expand Down Expand Up @@ -64,6 +66,7 @@ class _HomeShellState extends ConsumerState<HomeShell> {
// desktop notifications if configured.
// ignore: unused_local_variable
final notifications = ref.watch(notificationsListProvider);
final keyboardVisibility = ref.watch(keyboardVisibleProvider);

if (errorMsg != null) {
final softLogout = errorMsg == 'SoftLogout';
Expand Down Expand Up @@ -147,73 +150,78 @@ class _HomeShellState extends ConsumerState<HomeShell> {
context.pushNamed(Routes.quickJump.name);
},
},
child: Scaffold(
body: Screenshot(
controller: screenshotController,
child: AdaptiveLayout(
key: _key,
topNavigation: !hasFirstSynced
? SlotLayout(
config: <Breakpoint, SlotLayoutConfig?>{
Breakpoints.smallAndUp: SlotLayout.from(
key: const Key('LoadingIndictor'),
builder: (BuildContext ctx) =>
const LinearProgressIndicator(
semanticsLabel: 'Loading first sync',
child: KeyboardDismissOnTap(
// close keyboard if clicking somewhere else
child: Scaffold(
body: Screenshot(
controller: screenshotController,
child: AdaptiveLayout(
key: _key,
topNavigation: !hasFirstSynced
? SlotLayout(
config: <Breakpoint, SlotLayoutConfig?>{
Breakpoints.smallAndUp: SlotLayout.from(
key: const Key('LoadingIndictor'),
builder: (BuildContext ctx) =>
const LinearProgressIndicator(
semanticsLabel: 'Loading first sync',
),
),
),
},
)
: null,
primaryNavigation: isDesktop
? SlotLayout(
config: <Breakpoint, SlotLayoutConfig?>{
// adapt layout according to platform.
Breakpoints.small: SlotLayout.from(
key: const Key('primaryNavigation'),
builder: (BuildContext ctx) => const SidebarWidget(
labelType: NavigationRailLabelType.selected,
},
)
: null,
primaryNavigation: isDesktop
? SlotLayout(
config: <Breakpoint, SlotLayoutConfig?>{
// adapt layout according to platform.
Breakpoints.small: SlotLayout.from(
key: const Key('primaryNavigation'),
builder: (BuildContext ctx) => const SidebarWidget(
labelType: NavigationRailLabelType.selected,
),
),
),
Breakpoints.mediumAndUp: SlotLayout.from(
key: const Key('primaryNavigation'),
builder: (BuildContext ctx) => const SidebarWidget(
labelType: NavigationRailLabelType.all,
Breakpoints.mediumAndUp: SlotLayout.from(
key: const Key('primaryNavigation'),
builder: (BuildContext ctx) => const SidebarWidget(
labelType: NavigationRailLabelType.all,
),
),
),
},
)
: null,
body: SlotLayout(
config: <Breakpoint, SlotLayoutConfig>{
Breakpoints.smallAndUp: SlotLayout.from(
key: const Key('Body Small'),
builder: (BuildContext ctx) => widget.child,
),
},
),
bottomNavigation: !isDesktop
? SlotLayout(
config: <Breakpoint, SlotLayoutConfig>{
//In desktop, we have ability to adjust windows res,
// adjust to navbar as primary to smaller views.
Breakpoints.smallAndUp: SlotLayout.from(
key: const Key('Bottom Navigation Small'),
inAnimation: AdaptiveScaffold.bottomToTop,
outAnimation: AdaptiveScaffold.topToBottom,
builder: (BuildContext ctx) => BottomNavigationBar(
showSelectedLabels: false,
showUnselectedLabels: false,
currentIndex: bottomBarIdx,
onTap: (index) =>
context.go(bottomBarNav[index].initialLocation),
items: bottomBarNav,
type: BottomNavigationBarType.fixed,
},
)
: null,
body: SlotLayout(
config: <Breakpoint, SlotLayoutConfig>{
Breakpoints.smallAndUp: SlotLayout.from(
key: const Key('Body Small'),
builder: (BuildContext ctx) => widget.child,
),
},
),
bottomNavigation: !isDesktop &&
keyboardVisibility.valueOrNull !=
true // and the keyboard is not visible.
? SlotLayout(
config: <Breakpoint, SlotLayoutConfig>{
//In desktop, we have ability to adjust windows res,
// adjust to navbar as primary to smaller views.
Breakpoints.smallAndUp: SlotLayout.from(
key: const Key('Bottom Navigation Small'),
inAnimation: AdaptiveScaffold.bottomToTop,
outAnimation: AdaptiveScaffold.topToBottom,
builder: (BuildContext ctx) => BottomNavigationBar(
showSelectedLabels: false,
showUnselectedLabels: false,
currentIndex: bottomBarIdx,
onTap: (index) =>
context.go(bottomBarNav[index].initialLocation),
items: bottomBarNav,
type: BottomNavigationBarType.fixed,
),
),
),
},
)
: null,
},
)
: null,
),
),
),
),
Expand Down
95 changes: 58 additions & 37 deletions app/lib/features/search/widgets/quick_jump.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,20 @@ class QuickJump extends ConsumerWidget {
final provider = ref.watch(featuresProvider);
bool isActive(f) => provider.isActive(f);
return [
ButtonBar(
alignment: MainAxisAlignment.spaceEvenly,
Wrap(
alignment: WrapAlignment.center,
crossAxisAlignment: WrapCrossAlignment.center,
spacing: 10,
runSpacing: 10,
children: List.from(
[
IconButton(
iconSize: 48,
icon: const Icon(
Atlas.construction_tools_thin,
size: 32,
icon: const Padding(
padding: EdgeInsets.all(5),
child: Icon(
Atlas.construction_tools_thin,
size: 24,
),
),
style: IconButton.styleFrom(
side: BorderSide(
Expand All @@ -48,7 +53,6 @@ class QuickJump extends ConsumerWidget {
),
isActive(LabsFeature.pins)
? IconButton(
iconSize: 48,
style: IconButton.styleFrom(
side: BorderSide(
color: Theme.of(context)
Expand All @@ -60,12 +64,14 @@ class QuickJump extends ConsumerWidget {
onPressed: () {
navigateTo(route: Routes.pins);
},
icon: const Icon(Atlas.pin_thin, size: 32),
icon: const Padding(
padding: EdgeInsets.all(5),
child: Icon(Atlas.pin_thin, size: 24),
),
)
: null,
isActive(LabsFeature.events)
? IconButton(
iconSize: 48,
style: IconButton.styleFrom(
side: BorderSide(
color: Theme.of(context)
Expand All @@ -77,12 +83,14 @@ class QuickJump extends ConsumerWidget {
onPressed: () {
navigateTo(route: Routes.calendarEvents);
},
icon: const Icon(Atlas.calendar_dots_thin, size: 32),
icon: const Padding(
padding: EdgeInsets.all(5),
child: Icon(Atlas.calendar_dots_thin, size: 24),
),
)
: null,
isActive(LabsFeature.tasks)
? IconButton(
iconSize: 48,
style: IconButton.styleFrom(
side: BorderSide(
color: Theme.of(context)
Expand All @@ -94,20 +102,23 @@ class QuickJump extends ConsumerWidget {
onPressed: () {
navigateTo(route: Routes.tasks);
},
icon: SvgPicture.asset(
'assets/images/tasks.svg',
semanticsLabel: 'tasks',
height: 32,
width: 32,
colorFilter: ColorFilter.mode(
Theme.of(context).colorScheme.onSurface,
BlendMode.srcIn,
// this is slightly differently sized and padded to look the same as the others
icon: Padding(
padding: const EdgeInsets.all(4),
child: SvgPicture.asset(
'assets/images/tasks.svg',
semanticsLabel: 'tasks',
height: 28,
width: 28,
colorFilter: ColorFilter.mode(
Theme.of(context).colorScheme.onSurface,
BlendMode.srcIn,
),
),
),
)
: null,
IconButton(
iconSize: 48,
style: IconButton.styleFrom(
side: BorderSide(
color:
Expand All @@ -117,13 +128,15 @@ class QuickJump extends ConsumerWidget {
onPressed: () {
navigateTo(route: Routes.chat);
},
icon: const Icon(
Atlas.chats_thin,
size: 32,
icon: const Padding(
padding: EdgeInsets.all(5),
child: Icon(
Atlas.chats_thin,
size: 24,
),
),
),
IconButton(
iconSize: 48,
style: IconButton.styleFrom(
side: BorderSide(
color:
Expand All @@ -133,7 +146,10 @@ class QuickJump extends ConsumerWidget {
onPressed: () {
navigateTo(route: Routes.activities);
},
icon: const Icon(Atlas.audio_wave_thin, size: 32),
icon: const Padding(
padding: EdgeInsets.all(5),
child: Icon(Atlas.audio_wave_thin, size: 24),
),
),
].where((element) => element != null),
),
Expand Down Expand Up @@ -168,20 +184,25 @@ class QuickJump extends ConsumerWidget {
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
TextField(
autofocus: true,
decoration: const InputDecoration(
border: InputBorder.none,
focusedBorder: UnderlineInputBorder(),
prefixIcon: Icon(
Atlas.magnifying_glass_thin,
color: Colors.white,
Padding(
padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 10),
child: TextField(
autofocus: true,
decoration: const InputDecoration(
border: InputBorder.none,
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white),
),
prefixIcon: Icon(
Atlas.magnifying_glass_thin,
color: Colors.white,
),
labelText: 'jump to',
),
labelText: 'jump to',
onChanged: (String value) async {
ref.read(searchValueProvider.notifier).state = value;
},
),
onChanged: (String value) async {
ref.read(searchValueProvider.notifier).state = value;
},
),
...body,
],
Expand Down
2 changes: 1 addition & 1 deletion app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies:
image_picker: ^1.0.0
cross_file_image: ^1.0.0
overlay_support: ^2.1.0
flutter_keyboard_visibility: ^5.4.0
flutter_keyboard_visibility: ^5.4.1
expandable_text: ^2.3.0
cached_network_image: ^3.2.1
flutter_mentions:
Expand Down
Loading