From 7319878cb8f0be6225dc84b6ebf72b7a64daa492 Mon Sep 17 00:00:00 2001 From: Armand <4831c0@proton.me> Date: Sun, 16 Aug 2026 00:56:37 +0200 Subject: [PATCH] fix(home/tt): one haptic feedback per tap --- .../ui/components/common_bottom_sheets.dart | 40 +-- .../lib/ui/phone/pages/extras/main_error.dart | 4 +- .../ui/phone/pages/home/home_timetable.dart | 45 +-- .../phone/screens/message/message_screen.dart | 259 +++++++++--------- 4 files changed, 184 insertions(+), 164 deletions(-) diff --git a/firka/lib/ui/components/common_bottom_sheets.dart b/firka/lib/ui/components/common_bottom_sheets.dart index 891c1c1f..c435793d 100644 --- a/firka/lib/ui/components/common_bottom_sheets.dart +++ b/firka/lib/ui/components/common_bottom_sheets.dart @@ -52,28 +52,30 @@ Future showFirkaBottomSheet( color: appStyle.colors.background, borderRadius: BorderRadius.vertical(top: Radius.circular(24)), ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Align( - heightFactor: 0, - alignment: Alignment.topCenter, - child: Container( - margin: EdgeInsets.only(top: 18), - width: 40, - height: 4, - foregroundDecoration: ShapeDecoration( - shape: RoundedRectangleBorder( - borderRadius: BorderRadiusGeometry.circular(2), + child: SelectionArea( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Align( + heightFactor: 0, + alignment: Alignment.topCenter, + child: Container( + margin: EdgeInsets.only(top: 18), + width: 40, + height: 4, + foregroundDecoration: ShapeDecoration( + shape: RoundedRectangleBorder( + borderRadius: BorderRadiusGeometry.circular(2), + ), + color: appStyle.colors.shadowColor, ), - color: appStyle.colors.shadowColor, ), ), - ), - SizedBox(height: 40), - ...children, - ], + SizedBox(height: 40), + ...children, + ], + ), ), ), ), diff --git a/firka/lib/ui/phone/pages/extras/main_error.dart b/firka/lib/ui/phone/pages/extras/main_error.dart index 918a506a..1182fda4 100644 --- a/firka/lib/ui/phone/pages/extras/main_error.dart +++ b/firka/lib/ui/phone/pages/extras/main_error.dart @@ -31,7 +31,9 @@ void showErrorBottomSheet(BuildContext context, String err) { ), child: Padding( padding: const EdgeInsets.all(16.0), - child: Center(child: Text(err, style: appStyle.fonts.B_16R)), + child: SelectionArea( + child: Center(child: Text(err, style: appStyle.fonts.B_16R)), + ), ), ), ), diff --git a/firka/lib/ui/phone/pages/home/home_timetable.dart b/firka/lib/ui/phone/pages/home/home_timetable.dart index a8e2ba5b..f70fa009 100644 --- a/firka/lib/ui/phone/pages/home/home_timetable.dart +++ b/firka/lib/ui/phone/pages/home/home_timetable.dart @@ -49,6 +49,7 @@ class _HomeTimetableScreen extends FirkaState late List _tabDays; bool animating = false; + int? _programmaticTargetIndex; _HomeTimetableScreen(); @@ -143,29 +144,43 @@ class _HomeTimetableScreen extends FirkaState void _goToDay(DateTime day, {bool animate = true}) async { if (animating) return; - HapticFeedback.mediumImpact(); final targetIndex = _indexForDate(day); if (targetIndex == _activePageIndex) return; + HapticFeedback.mediumImpact(); + _programmaticTargetIndex = targetIndex; + if (!animate) { + animating = true; _pageController.jumpToPage(targetIndex); + animating = false; return; } animating = true; - await _pageController.animateToPage( - targetIndex, - duration: const Duration(milliseconds: 300), - curve: Curves.easeInOut, - ); - animating = false; + try { + await _pageController.animateToPage( + targetIndex, + duration: const Duration(milliseconds: 300), + curve: Curves.easeInOut, + ); + } finally { + animating = false; + } } void _onPageChanged(int index) { if (!mounted) return; - HapticFeedback.mediumImpact(); + final programmatic = _programmaticTargetIndex != null; + if (programmatic && (index == _programmaticTargetIndex || !animating)) { + _programmaticTargetIndex = null; + } + if (!programmatic) { + HapticFeedback.mediumImpact(); + } + setState(() { _activePageIndex = index; final weekMonday = _activeWeekMonday; @@ -239,9 +254,8 @@ class _HomeTimetableScreen extends FirkaState onPageChanged: _onPageChanged, itemBuilder: (context, index) { final day = _dateForIndex(index); - final lessons = List.from( - _lessonsFor(day), - )..removeWhere(isEvent); + final lessons = List.from(_lessonsFor(day)) + ..removeWhere(isEvent); final events = List.from(_lessonsFor(day)) ..retainWhere(isEvent); return TimeTableDayWidget( @@ -272,9 +286,7 @@ class _HomeTimetableScreen extends FirkaState ), ], ), - child: Center( - child: Wrap(spacing: 16, children: ttWidgets), - ), + child: Center(child: Wrap(spacing: 16, children: ttWidgets)), ), ], ), @@ -373,8 +385,9 @@ class _HomeTimetableScreen extends FirkaState ), ), onTap: () { - final targetMonday = _currentTabWeekMonday - .subtract(Duration(days: 7)); + final targetMonday = _currentTabWeekMonday.subtract( + Duration(days: 7), + ); final offset = _activeDay .difference(_currentTabWeekMonday) .inDays; diff --git a/firka/lib/ui/phone/screens/message/message_screen.dart b/firka/lib/ui/phone/screens/message/message_screen.dart index f2e394fd..6f82f37a 100644 --- a/firka/lib/ui/phone/screens/message/message_screen.dart +++ b/firka/lib/ui/phone/screens/message/message_screen.dart @@ -34,147 +34,150 @@ class MessageScreen extends StatelessWidget { ), child: Padding( padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Transform.translate( - offset: const Offset(-4, 0), - child: GestureDetector( - child: FirkaIconWidget( - FirkaIconType.majesticons, - Majesticon.chevronLeftLine, - color: appStyle.colors.textSecondary, - ), - onTap: () { - Navigator.of(context).pop(); - }, - ), - ), - Transform.translate( - offset: const Offset(-4, 1), - child: Text( - data.l10n.s_a, - style: appStyle.fonts.B_16R.apply( - color: appStyle.colors.textPrimary, + child: SelectionArea( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Transform.translate( + offset: const Offset(-4, 0), + child: GestureDetector( + child: FirkaIconWidget( + FirkaIconType.majesticons, + Majesticon.chevronLeftLine, + color: appStyle.colors.textSecondary, + ), + onTap: () { + Navigator.of(context).pop(); + }, ), ), - ), - ], - ), - SizedBox(height: 56), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox( - width: MediaQuery.of(context).size.width * 0.85, - child: Text( - message.title, - textAlign: TextAlign.center, - style: appStyle.fonts.H_H2.apply( - color: appStyle.colors.textPrimary, - ), - ), - ), - ], - ), - SizedBox(height: 8), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - message.createdAt.format( - data.l10n, - FormatMode.yyyymmdd, - ), - textAlign: TextAlign.center, - style: appStyle.fonts.B_16R.apply( - color: appStyle.colors.textSecondary, - ), - ), - ], - ), - SizedBox(height: 56), - Row( - children: [ - Container( - decoration: ShapeDecoration( - color: appStyle.colors.accent, - shape: CircleBorder(eccentricity: 1), - ), - child: SizedBox( - width: 28, - height: 28, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(bottom: 6), - child: Text( - message.author[0], - style: appStyle.fonts.H_18px.copyWith( - fontSize: 20, - color: appStyle.colors.textPrimary, - ), - ), - ), - ], - ), - ), - ), - SizedBox(width: 8), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: MediaQuery.of(context).size.width / 1.4, - child: Text( - message.author, - style: appStyle.fonts.B_16SB.apply( - color: appStyle.colors.textPrimary, - ), + Transform.translate( + offset: const Offset(-4, 1), + child: Text( + data.l10n.s_a, + style: appStyle.fonts.B_16R.apply( + color: appStyle.colors.textPrimary, ), ), - ], - ), - ], - ), - SizedBox(height: 20), - Flexible( - fit: FlexFit.loose, - child: Padding( - padding: const EdgeInsets.all(4), - child: Container( - decoration: BoxDecoration( - color: appStyle.colors.card, - borderRadius: BorderRadius.all( - Radius.circular(16), + ), + ], + ), + SizedBox(height: 56), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + width: MediaQuery.of(context).size.width * 0.85, + child: Text( + message.title, + textAlign: TextAlign.center, + style: appStyle.fonts.H_H2.apply( + color: appStyle.colors.textPrimary, + ), ), ), - child: Padding( - padding: const EdgeInsets.all(12), - child: SingleChildScrollView( - child: Html( - data: message.contentHtml - .withoutFontFeatureSettings(), - onLinkTap: (url, map, element) => { - if (url != null) launchUrlString(url), - }, - style: { - "*": Style.fromTextStyle( - appStyle.fonts.B_16R.apply( - color: appStyle.colors.textPrimary, + ], + ), + SizedBox(height: 8), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + message.createdAt.format( + data.l10n, + FormatMode.yyyymmdd, + ), + textAlign: TextAlign.center, + style: appStyle.fonts.B_16R.apply( + color: appStyle.colors.textSecondary, + ), + ), + ], + ), + SizedBox(height: 56), + Row( + children: [ + Container( + decoration: ShapeDecoration( + color: appStyle.colors.accent, + shape: CircleBorder(eccentricity: 1), + ), + child: SizedBox( + width: 28, + height: 28, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 6), + child: Text( + message.author[0], + style: appStyle.fonts.H_18px.copyWith( + fontSize: 20, + color: appStyle.colors.textPrimary, + ), ), ), - }, + ], + ), + ), + ), + SizedBox(width: 8), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: + MediaQuery.of(context).size.width / 1.4, + child: Text( + message.author, + style: appStyle.fonts.B_16SB.apply( + color: appStyle.colors.textPrimary, + ), + ), + ), + ], + ), + ], + ), + SizedBox(height: 20), + Flexible( + fit: FlexFit.loose, + child: Padding( + padding: const EdgeInsets.all(4), + child: Container( + decoration: BoxDecoration( + color: appStyle.colors.card, + borderRadius: BorderRadius.all( + Radius.circular(16), + ), + ), + child: Padding( + padding: const EdgeInsets.all(12), + child: SingleChildScrollView( + child: Html( + data: message.contentHtml + .withoutFontFeatureSettings(), + onLinkTap: (url, map, element) => { + if (url != null) launchUrlString(url), + }, + style: { + "*": Style.fromTextStyle( + appStyle.fonts.B_16R.apply( + color: appStyle.colors.textPrimary, + ), + ), + }, + ), ), ), ), ), ), - ), - ], + ], + ), ), ), ),