forked from firka/firka
fix(home/tt): one haptic feedback per tap
This commit is contained in:
@@ -52,28 +52,30 @@ Future<void> 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,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -49,6 +49,7 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
|
||||
late List<DateTime> _tabDays;
|
||||
|
||||
bool animating = false;
|
||||
int? _programmaticTargetIndex;
|
||||
|
||||
_HomeTimetableScreen();
|
||||
|
||||
@@ -143,29 +144,43 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
|
||||
|
||||
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<HomeTimetableScreen>
|
||||
onPageChanged: _onPageChanged,
|
||||
itemBuilder: (context, index) {
|
||||
final day = _dateForIndex(index);
|
||||
final lessons = List<LessonCacheModel>.from(
|
||||
_lessonsFor(day),
|
||||
)..removeWhere(isEvent);
|
||||
final lessons = List<LessonCacheModel>.from(_lessonsFor(day))
|
||||
..removeWhere(isEvent);
|
||||
final events = List<LessonCacheModel>.from(_lessonsFor(day))
|
||||
..retainWhere(isEvent);
|
||||
return TimeTableDayWidget(
|
||||
@@ -272,9 +286,7 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Center(
|
||||
child: Wrap(spacing: 16, children: ttWidgets),
|
||||
),
|
||||
child: Center(child: Wrap(spacing: 16, children: ttWidgets)),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -373,8 +385,9 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
final targetMonday = _currentTabWeekMonday
|
||||
.subtract(Duration(days: 7));
|
||||
final targetMonday = _currentTabWeekMonday.subtract(
|
||||
Duration(days: 7),
|
||||
);
|
||||
final offset = _activeDay
|
||||
.difference(_currentTabWeekMonday)
|
||||
.inDays;
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user