fix comment tile and bottom navigation bar. (#187)

This commit is contained in:
Jiaqi Feng
2023-03-26 19:16:38 -07:00
committed by GitHub
parent 0ca3e96d91
commit ab1e90ccad
15 changed files with 110 additions and 108 deletions

View File

@ -50,7 +50,7 @@ android {
defaultConfig { defaultConfig {
applicationId "com.jiaqifeng.hacki" applicationId "com.jiaqifeng.hacki"
minSdkVersion 30 minSdkVersion 26
targetSdkVersion 33 targetSdkVersion 33
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName

View File

@ -2,6 +2,8 @@ PODS:
- connectivity_plus (0.0.1): - connectivity_plus (0.0.1):
- Flutter - Flutter
- ReachabilitySwift - ReachabilitySwift
- device_info_plus (0.0.1):
- Flutter
- Flutter (1.0.0) - Flutter (1.0.0)
- flutter_email_sender (0.0.1): - flutter_email_sender (0.0.1):
- Flutter - Flutter
@ -53,6 +55,7 @@ PODS:
DEPENDENCIES: DEPENDENCIES:
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`) - connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- Flutter (from `Flutter`) - Flutter (from `Flutter`)
- flutter_email_sender (from `.symlinks/plugins/flutter_email_sender/ios`) - flutter_email_sender (from `.symlinks/plugins/flutter_email_sender/ios`)
- flutter_inappwebview (from `.symlinks/plugins/flutter_inappwebview/ios`) - flutter_inappwebview (from `.symlinks/plugins/flutter_inappwebview/ios`)
@ -81,6 +84,8 @@ SPEC REPOS:
EXTERNAL SOURCES: EXTERNAL SOURCES:
connectivity_plus: connectivity_plus:
:path: ".symlinks/plugins/connectivity_plus/ios" :path: ".symlinks/plugins/connectivity_plus/ios"
device_info_plus:
:path: ".symlinks/plugins/device_info_plus/ios"
Flutter: Flutter:
:path: Flutter :path: Flutter
flutter_email_sender: flutter_email_sender:
@ -120,6 +125,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS: SPEC CHECKSUMS:
connectivity_plus: 413a8857dd5d9f1c399a39130850d02fe0feaf7e connectivity_plus: 413a8857dd5d9f1c399a39130850d02fe0feaf7e
device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_email_sender: 02d7443217d8c41483223627972bfdc09f74276b flutter_email_sender: 02d7443217d8c41483223627972bfdc09f74276b
flutter_inappwebview: bfd58618f49dc62f2676de690fc6dcda1d6c3721 flutter_inappwebview: bfd58618f49dc62f2676de690fc6dcda1d6c3721

View File

@ -26,7 +26,6 @@ class CommentsCubit extends Cubit<CommentsState> {
StoriesRepository? storiesRepository, StoriesRepository? storiesRepository,
SembastRepository? sembastRepository, SembastRepository? sembastRepository,
Logger? logger, Logger? logger,
required bool isScreenReaderEnabled,
required bool isOfflineReading, required bool isOfflineReading,
required Item item, required Item item,
required FetchMode defaultFetchMode, required FetchMode defaultFetchMode,
@ -40,7 +39,6 @@ class CommentsCubit extends Cubit<CommentsState> {
_sembastRepository = _sembastRepository =
sembastRepository ?? locator.get<SembastRepository>(), sembastRepository ?? locator.get<SembastRepository>(),
_logger = logger ?? locator.get<Logger>(), _logger = logger ?? locator.get<Logger>(),
_isScreenReaderEnabled = isScreenReaderEnabled,
super( super(
CommentsState.init( CommentsState.init(
isOfflineReading: isOfflineReading, isOfflineReading: isOfflineReading,
@ -56,7 +54,6 @@ class CommentsCubit extends Cubit<CommentsState> {
final StoriesRepository _storiesRepository; final StoriesRepository _storiesRepository;
final SembastRepository _sembastRepository; final SembastRepository _sembastRepository;
final Logger _logger; final Logger _logger;
final bool _isScreenReaderEnabled;
/// The [StreamSubscription] for stream (both lazy or eager) /// The [StreamSubscription] for stream (both lazy or eager)
/// fetching comments posted directly to the story. /// fetching comments posted directly to the story.
@ -359,9 +356,6 @@ class CommentsCubit extends Cubit<CommentsState> {
emit(state.copyWith(comments: updatedComments)); emit(state.copyWith(comments: updatedComments));
if (state.fetchMode == FetchMode.eager) { if (state.fetchMode == FetchMode.eager) {
/// If screen reader is on, fetch all the comments without paging.
if (_isScreenReaderEnabled) return;
if (updatedComments.length >= if (updatedComments.length >=
_pageSize + _pageSize * state.currentPage && _pageSize + _pageSize * state.currentPage &&
updatedComments.length <= updatedComments.length <=

View File

@ -6,8 +6,6 @@ import 'package:hacki/config/constants.dart';
import 'package:hacki/styles/styles.dart'; import 'package:hacki/styles/styles.dart';
extension ContextExtension on BuildContext { extension ContextExtension on BuildContext {
bool get isScreenReaderEnabled => MediaQuery.of(this).accessibleNavigation;
T? tryRead<T>() { T? tryRead<T>() {
try { try {
return read<T>(); return read<T>();
@ -21,8 +19,6 @@ extension ContextExtension on BuildContext {
VoidCallback? action, VoidCallback? action,
String? label, String? label,
}) { }) {
if (isScreenReaderEnabled) return;
ScaffoldMessenger.of(this).showSnackBar( ScaffoldMessenger.of(this).showSnackBar(
SnackBar( SnackBar(
backgroundColor: Palette.deepOrange, backgroundColor: Palette.deepOrange,

View File

@ -58,10 +58,12 @@ extension StateExtension on State {
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
builder: (BuildContext context) { builder: (BuildContext context) {
return MorePopupMenu( return SafeArea(
child: MorePopupMenu(
item: item, item: item,
isBlocked: isBlocked, isBlocked: isBlocked,
onLoginTapped: onLoginTapped, onLoginTapped: onLoginTapped,
),
); );
}, },
).then((MenuAction? action) { ).then((MenuAction? action) {

View File

@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:adaptive_theme/adaptive_theme.dart'; import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:feature_discovery/feature_discovery.dart'; import 'package:feature_discovery/feature_discovery.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
@ -110,6 +111,11 @@ Future<void> main({bool testing = false}) async {
}, },
); );
} else if (Platform.isAndroid) { } else if (Platform.isAndroid) {
final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
final AndroidDeviceInfo androidInfo = await deviceInfoPlugin.androidInfo;
final int sdk = androidInfo.version.sdkInt;
if (sdk > 28) {
SystemChrome.setSystemUIOverlayStyle( SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle( const SystemUiOverlayStyle(
statusBarColor: Palette.transparent, statusBarColor: Palette.transparent,
@ -117,6 +123,15 @@ Future<void> main({bool testing = false}) async {
systemNavigationBarDividerColor: Palette.transparent, systemNavigationBarDividerColor: Palette.transparent,
), ),
); );
} else {
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(
statusBarBrightness: Brightness.light,
statusBarIconBrightness: Brightness.dark,
statusBarColor: Colors.transparent,
),
);
}
await SystemChrome.setEnabledSystemUIMode( await SystemChrome.setEnabledSystemUIMode(
SystemUiMode.edgeToEdge, SystemUiMode.edgeToEdge,

View File

@ -92,14 +92,12 @@ class _HomeScreenState extends State<HomeScreen>
SchedulerBinding.instance SchedulerBinding.instance
..addPostFrameCallback((_) { ..addPostFrameCallback((_) {
if (context.isScreenReaderEnabled == false) {
FeatureDiscovery.discoverFeatures( FeatureDiscovery.discoverFeatures(
context, context,
<String>{ <String>{
Constants.featureLogIn, Constants.featureLogIn,
}, },
); );
}
}) })
..addPostFrameCallback((_) { ..addPostFrameCallback((_) {
final ModalRoute<dynamic>? route = ModalRoute.of(context); final ModalRoute<dynamic>? route = ModalRoute.of(context);
@ -229,7 +227,6 @@ class _HomeScreenState extends State<HomeScreen>
} else { } else {
final ItemScreenArgs args = ItemScreenArgs( final ItemScreenArgs args = ItemScreenArgs(
item: story, item: story,
isScreenReaderEnabled: context.isScreenReaderEnabled,
); );
context.read<ReminderCubit>().updateLastReadStoryId(story.id); context.read<ReminderCubit>().updateLastReadStoryId(story.id);

View File

@ -23,13 +23,11 @@ class ItemScreenArgs extends Equatable {
required this.item, required this.item,
this.onlyShowTargetComment = false, this.onlyShowTargetComment = false,
this.useCommentCache = false, this.useCommentCache = false,
this.isScreenReaderEnabled = false,
this.targetComments, this.targetComments,
}); });
final Item item; final Item item;
final bool onlyShowTargetComment; final bool onlyShowTargetComment;
final bool isScreenReaderEnabled;
final List<Comment>? targetComments; final List<Comment>? targetComments;
/// when a user is trying to view a sub-thread from a main thread, we don't /// when a user is trying to view a sub-thread from a main thread, we don't
@ -41,7 +39,6 @@ class ItemScreenArgs extends Equatable {
List<Object?> get props => <Object?>[ List<Object?> get props => <Object?>[
item, item,
onlyShowTargetComment, onlyShowTargetComment,
isScreenReaderEnabled,
targetComments, targetComments,
useCommentCache, useCommentCache,
]; ];
@ -75,7 +72,6 @@ class ItemScreen extends StatefulWidget {
context.read<PreferenceCubit>().state.fetchMode, context.read<PreferenceCubit>().state.fetchMode,
defaultCommentsOrder: defaultCommentsOrder:
context.read<PreferenceCubit>().state.order, context.read<PreferenceCubit>().state.order,
isScreenReaderEnabled: args.isScreenReaderEnabled,
)..init( )..init(
onlyShowTargetComment: args.onlyShowTargetComment, onlyShowTargetComment: args.onlyShowTargetComment,
targetAncestors: args.targetComments, targetAncestors: args.targetComments,
@ -118,7 +114,6 @@ class ItemScreen extends StatefulWidget {
context.read<PreferenceCubit>().state.fetchMode, context.read<PreferenceCubit>().state.fetchMode,
defaultCommentsOrder: defaultCommentsOrder:
context.read<PreferenceCubit>().state.order, context.read<PreferenceCubit>().state.order,
isScreenReaderEnabled: args.isScreenReaderEnabled,
)..init( )..init(
onlyShowTargetComment: args.onlyShowTargetComment, onlyShowTargetComment: args.onlyShowTargetComment,
targetAncestors: args.targetComments, targetAncestors: args.targetComments,
@ -178,7 +173,6 @@ class _ItemScreenState extends State<ItemScreen> with RouteAware {
SchedulerBinding.instance SchedulerBinding.instance
..addPostFrameCallback((_) { ..addPostFrameCallback((_) {
if (context.isScreenReaderEnabled == false) {
FeatureDiscovery.discoverFeatures( FeatureDiscovery.discoverFeatures(
context, context,
<String>{ <String>{
@ -187,7 +181,6 @@ class _ItemScreenState extends State<ItemScreen> with RouteAware {
Constants.featureOpenStoryInWebView, Constants.featureOpenStoryInWebView,
}, },
); );
}
}) })
..addPostFrameCallback((_) { ..addPostFrameCallback((_) {
final ModalRoute<dynamic>? route = ModalRoute.of(context); final ModalRoute<dynamic>? route = ModalRoute.of(context);
@ -325,8 +318,6 @@ class _ItemScreenState extends State<ItemScreen> with RouteAware {
context.read<SplitViewCubit>().zoom, context.read<SplitViewCubit>().zoom,
onFontSizeTap: onFontSizeTapped, onFontSizeTap: onFontSizeTapped,
fontSizeIconButtonKey: fontSizeIconButtonKey, fontSizeIconButtonKey: fontSizeIconButtonKey,
isScreenReaderEnabled:
context.isScreenReaderEnabled,
), ),
); );
}, },
@ -362,7 +353,6 @@ class _ItemScreenState extends State<ItemScreen> with RouteAware {
scrollController: scrollController, scrollController: scrollController,
onFontSizeTap: onFontSizeTapped, onFontSizeTap: onFontSizeTapped,
fontSizeIconButtonKey: fontSizeIconButtonKey, fontSizeIconButtonKey: fontSizeIconButtonKey,
isScreenReaderEnabled: context.isScreenReaderEnabled,
), ),
body: MainView( body: MainView(
scrollController: scrollController, scrollController: scrollController,

View File

@ -16,7 +16,6 @@ class CustomAppBar extends AppBar {
bool splitViewEnabled = false, bool splitViewEnabled = false,
VoidCallback? onZoomTap, VoidCallback? onZoomTap,
bool? expanded, bool? expanded,
bool isScreenReaderEnabled = false,
}) : super( }) : super(
elevation: Dimens.zero, elevation: Dimens.zero,
actions: <Widget>[ actions: <Widget>[
@ -38,7 +37,6 @@ class CustomAppBar extends AppBar {
ScrollUpIconButton( ScrollUpIconButton(
scrollController: scrollController, scrollController: scrollController,
), ),
if (isScreenReaderEnabled == false)
IconButton( IconButton(
key: fontSizeIconButtonKey, key: fontSizeIconButtonKey,
icon: Text( icon: Text(

View File

@ -23,8 +23,8 @@ class MorePopupMenu extends StatelessWidget {
final bool isBlocked; final bool isBlocked;
final VoidCallback onLoginTapped; final VoidCallback onLoginTapped;
static const double _storySheetHeight = 500; static const double _storySheetHeight = 485;
static const double _commentSheetHeight = 480; static const double _commentSheetHeight = 470;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -70,7 +70,6 @@ class CommentTile extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Slidable( Slidable(
enabled: context.isScreenReaderEnabled == false,
startActionPane: actionable startActionPane: actionable
? ActionPane( ? ActionPane(
motion: const StretchMotion(), motion: const StretchMotion(),
@ -118,14 +117,6 @@ class CommentTile extends StatelessWidget {
: null, : null,
child: InkWell( child: InkWell(
onTap: () { onTap: () {
if (context.isScreenReaderEnabled) {
onMoreTapped?.call(
comment,
context.rect,
);
return;
}
if (actionable) { if (actionable) {
HapticFeedback.selectionClick(); HapticFeedback.selectionClick();
context.read<CollapseCubit>().collapse(); context.read<CollapseCubit>().collapse();

View File

@ -38,9 +38,7 @@ class ItemText extends StatelessWidget {
), ),
onTap: onTap, onTap: onTap,
textScaleFactor: MediaQuery.of(context).textScaleFactor, textScaleFactor: MediaQuery.of(context).textScaleFactor,
contextMenuBuilder: context.isScreenReaderEnabled contextMenuBuilder: (
? null
: (
BuildContext context, BuildContext context,
EditableTextState editableTextState, EditableTextState editableTextState,
) => ) =>
@ -59,9 +57,7 @@ class ItemText extends StatelessWidget {
linkStyle: linkStyle, linkStyle: linkStyle,
onOpen: (LinkableElement link) => LinkUtil.launch(link.url), onOpen: (LinkableElement link) => LinkUtil.launch(link.url),
onTap: onTap, onTap: onTap,
contextMenuBuilder: context.isScreenReaderEnabled contextMenuBuilder: (
? null
: (
BuildContext context, BuildContext context,
EditableTextState editableTextState, EditableTextState editableTextState,
) => ) =>

View File

@ -13,10 +13,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: adaptive_theme name: adaptive_theme
sha256: "84af26cfc68220df3cd35d9d94cb8953e7182ef560e13d8efb87f32bf1e588fc" sha256: "61bde10390e937d11d05c6cf0d5cf378a73d49f9a442262e43613dae60ed0b3f"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.1" version: "3.2.0"
analyzer: analyzer:
dependency: transitive dependency: transitive
description: description:
@ -201,6 +201,22 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.8" version: "0.7.8"
device_info_plus:
dependency: "direct main"
description:
name: device_info_plus
sha256: "1d6e5a61674ba3a68fb048a7c7b4ff4bebfed8d7379dbe8f2b718231be9a7c95"
url: "https://pub.dev"
source: hosted
version: "8.1.0"
device_info_plus_platform_interface:
dependency: transitive
description:
name: device_info_plus_platform_interface
sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64
url: "https://pub.dev"
source: hosted
version: "7.0.0"
diff_match_patch: diff_match_patch:
dependency: transitive dependency: transitive
description: description:
@ -213,10 +229,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: dio name: dio
sha256: "7d328c4d898a61efc3cd93655a0955858e29a0aa647f0f9e02d59b3bb275e2e8" sha256: "3e5c4a94d112540d0c9a6b7f3969832e1604eb8cde0f88d0808382f9f632100b"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.0.6" version: "5.0.3"
equatable: equatable:
dependency: "direct main" dependency: "direct main"
description: description:
@ -572,10 +588,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: logger name: logger
sha256: "5076f09225f91dc49289a4ccb92df2eeea9ea01cf7c26d49b3a1f04c6a49eec1" sha256: db2ff852ed77090ba9f62d3611e4208a3d11dfa35991a81ae724c113fcb3e3f7
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.0" version: "1.3.0"
logging: logging:
dependency: transitive dependency: transitive
description: description:
@ -1359,4 +1375,4 @@ packages:
version: "3.1.1" version: "3.1.1"
sdks: sdks:
dart: ">=2.19.0 <3.0.0" dart: ">=2.19.0 <3.0.0"
flutter: ">=3.7.6" flutter: ">=3.7.8"

View File

@ -1,21 +1,22 @@
name: hacki name: hacki
description: A Hacker News reader. description: A Hacker News reader.
version: 1.3.3+102 version: 1.3.4+103
publish_to: none publish_to: none
environment: environment:
sdk: ">=2.17.0 <3.0.0" sdk: ">=2.17.0 <3.0.0"
flutter: "3.7.6" flutter: "3.7.8"
dependencies: dependencies:
adaptive_theme: ^3.0.0 adaptive_theme: ^3.2.0
badges: ^3.0.2 badges: ^3.0.2
bloc: ^8.1.1 bloc: ^8.1.1
cached_network_image: ^3.2.3 cached_network_image: ^3.2.3
clipboard: ^0.1.3 clipboard: ^0.1.3
collection: ^1.17.0 collection: ^1.17.0
connectivity_plus: ^3.0.2 connectivity_plus: ^3.0.2
dio: ^4.0.6 device_info_plus: ^8.1.0
dio: ^5.0.3
equatable: ^2.0.5 equatable: ^2.0.5
fast_gbk: ^1.0.0 fast_gbk: ^1.0.0
feature_discovery: feature_discovery:
@ -44,7 +45,7 @@ dependencies:
hydrated_bloc: ^9.1.0 hydrated_bloc: ^9.1.0
intl: ^0.18.0 intl: ^0.18.0
linkify: ^4.1.0 linkify: ^4.1.0
logger: ^1.1.0 logger: ^1.3.0
memoize: ^3.0.0 memoize: ^3.0.0
package_info_plus: ^3.0.3 package_info_plus: ^3.0.3
path: ^1.8.2 path: ^1.8.2