Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
ec065c0122 | |||
2960c6e59e | |||
92dac6b932 | |||
20365393a3 | |||
8d238744c7 | |||
e33ff417fb | |||
d8922c2641 | |||
c6e0461857 | |||
30ca356dc8 |
@ -29,6 +29,7 @@ Features:
|
||||
- Download stories and comments for offline reading.
|
||||
- Pick up where you left off.
|
||||
- Synced favorites and pins across devices. (iOS only)
|
||||
- Export or import your favorites.
|
||||
- Launch from system share sheet.
|
||||
- And more...
|
||||
|
||||
|
@ -2,4 +2,5 @@
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@mipmap/ic_launcher_adaptive_back"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_adaptive_fore"/>
|
||||
<monochrome android:drawable="@mipmap/ic_launcher_monochrome"/>
|
||||
</adaptive-icon>
|
BIN
android/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
android/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png
Normal file
After Width: | Height: | Size: 940 B |
BIN
android/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.4 KiB |
@ -24,6 +24,6 @@ subprojects {
|
||||
project.evaluationDependsOn(':app')
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
tasks.register("clean", Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
|
BIN
assets/hacki-github.xcf
Normal file
BIN
assets/hacki.xcf
Normal file
BIN
assets/screenshots/hacki-1.png
Normal file
After Width: | Height: | Size: 890 KiB |
BIN
assets/screenshots/hacki-2.png
Normal file
After Width: | Height: | Size: 873 KiB |
BIN
assets/screenshots/hacki-3.png
Normal file
After Width: | Height: | Size: 770 KiB |
BIN
assets/screenshots/hacki-4.png
Normal file
After Width: | Height: | Size: 517 KiB |
@ -27,12 +27,16 @@ PODS:
|
||||
- Flutter
|
||||
- integration_test (0.0.1):
|
||||
- Flutter
|
||||
- MTBBarcodeScanner (5.0.11)
|
||||
- OrderedSet (5.0.0)
|
||||
- package_info_plus (0.4.5):
|
||||
- Flutter
|
||||
- path_provider_foundation (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
- qr_code_scanner (0.2.0):
|
||||
- Flutter
|
||||
- MTBBarcodeScanner
|
||||
- ReachabilitySwift (5.0.0)
|
||||
- receive_sharing_intent (0.0.1):
|
||||
- Flutter
|
||||
@ -68,6 +72,7 @@ DEPENDENCIES:
|
||||
- integration_test (from `.symlinks/plugins/integration_test/ios`)
|
||||
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
|
||||
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
|
||||
- qr_code_scanner (from `.symlinks/plugins/qr_code_scanner/ios`)
|
||||
- receive_sharing_intent (from `.symlinks/plugins/receive_sharing_intent/ios`)
|
||||
- share_plus (from `.symlinks/plugins/share_plus/ios`)
|
||||
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
|
||||
@ -81,6 +86,7 @@ DEPENDENCIES:
|
||||
SPEC REPOS:
|
||||
trunk:
|
||||
- FMDB
|
||||
- MTBBarcodeScanner
|
||||
- OrderedSet
|
||||
- ReachabilitySwift
|
||||
|
||||
@ -109,6 +115,8 @@ EXTERNAL SOURCES:
|
||||
:path: ".symlinks/plugins/package_info_plus/ios"
|
||||
path_provider_foundation:
|
||||
:path: ".symlinks/plugins/path_provider_foundation/darwin"
|
||||
qr_code_scanner:
|
||||
:path: ".symlinks/plugins/qr_code_scanner/ios"
|
||||
receive_sharing_intent:
|
||||
:path: ".symlinks/plugins/receive_sharing_intent/ios"
|
||||
share_plus:
|
||||
@ -140,9 +148,11 @@ SPEC CHECKSUMS:
|
||||
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
|
||||
in_app_review: 318597b3a06c22bb46dc454d56828c85f444f99d
|
||||
integration_test: 13825b8a9334a850581300559b8839134b124670
|
||||
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
|
||||
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
|
||||
package_info_plus: fd030dabf36271f146f1f3beacd48f564b0f17f7
|
||||
path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8
|
||||
qr_code_scanner: bb67d64904c3b9658ada8c402e8b4d406d5d796e
|
||||
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
|
||||
receive_sharing_intent: c0d87310754e74c0f9542947e7cbdf3a0335a3b1
|
||||
share_plus: 599aa54e4ea31d4b4c0e9c911bcc26c55e791028
|
||||
|
@ -76,5 +76,9 @@
|
||||
<false/>
|
||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||
<true/>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>This app needs camera access to scan QR codes</string>
|
||||
<key>io.flutter.embedded_views_preview</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@ -78,3 +78,15 @@ abstract class RegExpConstants {
|
||||
static const String linkSuffix = r'(\)|]|,|\*)(.)*$';
|
||||
static const String number = '[0-9]+';
|
||||
}
|
||||
|
||||
abstract class Durations {
|
||||
static const Duration ms100 = Duration(milliseconds: 100);
|
||||
static const Duration ms200 = Duration(milliseconds: 200);
|
||||
static const Duration ms300 = Duration(milliseconds: 300);
|
||||
static const Duration ms400 = Duration(milliseconds: 400);
|
||||
static const Duration ms500 = Duration(milliseconds: 500);
|
||||
static const Duration ms600 = Duration(milliseconds: 600);
|
||||
static const Duration oneSecond = Duration(seconds: 1);
|
||||
static const Duration twoSeconds = Duration(seconds: 2);
|
||||
static const Duration tenSeconds = Duration(seconds: 10);
|
||||
}
|
||||
|
@ -11,10 +11,14 @@ class CustomRouter {
|
||||
switch (settings.name) {
|
||||
case HomeScreen.routeName:
|
||||
return HomeScreen.route();
|
||||
case ItemScreen.routeName:
|
||||
return ItemScreen.route(settings.arguments! as ItemScreenArgs);
|
||||
case SubmitScreen.routeName:
|
||||
return SubmitScreen.route();
|
||||
case QrCodeScannerScreen.routeName:
|
||||
return QrCodeScannerScreen.route();
|
||||
case ItemScreen.routeName:
|
||||
return ItemScreen.route(settings.arguments! as ItemScreenArgs);
|
||||
case QrCodeViewScreen.routeName:
|
||||
return QrCodeViewScreen.route(data: settings.arguments! as String);
|
||||
default:
|
||||
return _errorRoute();
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import 'package:bloc/bloc.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hacki/config/constants.dart';
|
||||
import 'package:hacki/config/locator.dart';
|
||||
import 'package:hacki/cubits/cubits.dart';
|
||||
import 'package:hacki/main.dart';
|
||||
@ -348,6 +349,7 @@ class CommentsCubit extends Cubit<CommentsState> {
|
||||
init(useCommentCache: true);
|
||||
}
|
||||
|
||||
/// Jump to next root level comment.
|
||||
void jump(
|
||||
ItemScrollController itemScrollController,
|
||||
ItemPositionsListener itemPositionsListener,
|
||||
@ -378,13 +380,14 @@ class CommentsCubit extends Cubit<CommentsState> {
|
||||
itemScrollController.scrollTo(
|
||||
index: i + 1,
|
||||
alignment: 0.15,
|
||||
duration: const Duration(milliseconds: 400),
|
||||
duration: Durations.ms400,
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Jump to previous root level comment.
|
||||
void jumpUp(
|
||||
ItemScrollController itemScrollController,
|
||||
ItemPositionsListener itemPositionsListener,
|
||||
@ -416,7 +419,7 @@ class CommentsCubit extends Cubit<CommentsState> {
|
||||
itemScrollController.scrollTo(
|
||||
index: i + 1,
|
||||
alignment: 0.15,
|
||||
duration: const Duration(milliseconds: 400),
|
||||
duration: Durations.ms400,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:hacki/config/constants.dart';
|
||||
import 'package:hacki/config/locator.dart';
|
||||
import 'package:hacki/extensions/extensions.dart';
|
||||
import 'package:hacki/models/models.dart';
|
||||
@ -11,7 +12,7 @@ part 'edit_state.dart';
|
||||
class EditCubit extends HydratedCubit<EditState> {
|
||||
EditCubit({DraftCache? draftCache})
|
||||
: _draftCache = draftCache ?? locator.get<DraftCache>(),
|
||||
_debouncer = Debouncer(delay: const Duration(seconds: 1)),
|
||||
_debouncer = Debouncer(delay: Durations.oneSecond),
|
||||
super(const EditState.init());
|
||||
|
||||
final DraftCache _draftCache;
|
||||
|
@ -4,6 +4,7 @@ import 'dart:math';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:hacki/blocs/blocs.dart';
|
||||
import 'package:hacki/config/constants.dart';
|
||||
import 'package:hacki/config/locator.dart';
|
||||
import 'package:hacki/cubits/cubits.dart';
|
||||
import 'package:hacki/models/models.dart';
|
||||
@ -31,7 +32,7 @@ class NotificationCubit extends Cubit<NotificationState> {
|
||||
if (authState.isLoggedIn && authState.username != _username) {
|
||||
// Get the user setting.
|
||||
if (_preferenceCubit.state.notificationEnabled) {
|
||||
Future<void>.delayed(const Duration(seconds: 2), init);
|
||||
Future<void>.delayed(Durations.twoSeconds, init);
|
||||
}
|
||||
|
||||
// Listen for setting changes in the future.
|
||||
|
@ -20,9 +20,6 @@ class PostCubit extends Cubit<PostState> {
|
||||
text: text,
|
||||
);
|
||||
|
||||
// final successful =
|
||||
// await Future<bool>.delayed(const Duration(seconds: 2), () => true);
|
||||
|
||||
if (successful) {
|
||||
emit(state.copyWith(status: PostStatus.successful));
|
||||
} else {
|
||||
|
@ -68,6 +68,8 @@ class PreferenceState extends Equatable {
|
||||
|
||||
bool get swipeGestureEnabled => _isOn<SwipeGesturePreference>();
|
||||
|
||||
bool get autoScrollEnabled => _isOn<AutoScrollModePreference>();
|
||||
|
||||
List<StoryType> get tabs {
|
||||
final String result =
|
||||
preferences.singleWhereType<TabOrderPreference>().val.toString();
|
||||
|
@ -23,6 +23,12 @@ class SearchState extends Equatable {
|
||||
final SearchStatus status;
|
||||
final SearchParams params;
|
||||
|
||||
bool get hasDateFilter =>
|
||||
params.filters.whereType<DateTimeRangeFilter>().isNotEmpty;
|
||||
|
||||
DateTimeRangeFilter? get dateFilter =>
|
||||
params.filters.whereType<DateTimeRangeFilter>().singleOrNull;
|
||||
|
||||
SearchState copyWith({
|
||||
List<Item>? results,
|
||||
SearchStatus? status,
|
||||
@ -42,3 +48,11 @@ class SearchState extends Equatable {
|
||||
params,
|
||||
];
|
||||
}
|
||||
|
||||
extension SearchStateExtension on SearchState {
|
||||
bool get showDateRangeShortcutChips {
|
||||
return hasDateFilter &&
|
||||
dateFilter?.startTime != null &&
|
||||
dateFilter?.endTime != null;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import 'package:equatable/equatable.dart';
|
||||
import 'package:feature_discovery/feature_discovery.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
@ -268,8 +269,8 @@ class HackiApp extends StatelessWidget {
|
||||
AsyncSnapshot<AdaptiveThemeMode?> snapshot,
|
||||
) {
|
||||
final AdaptiveThemeMode? mode = snapshot.data;
|
||||
ThemeUtil.updateAndroidStatusBarSetting(
|
||||
Theme.of(context).brightness,
|
||||
ThemeUtil.updateStatusBarSetting(
|
||||
SchedulerBinding.instance.platformDispatcher.platformBrightness,
|
||||
mode,
|
||||
);
|
||||
return BlocBuilder<PreferenceCubit, PreferenceState>(
|
||||
|
14
lib/models/export_destination.dart
Normal file
@ -0,0 +1,14 @@
|
||||
import 'package:flutter/material.dart' show IconData, Icons;
|
||||
|
||||
enum ExportDestination {
|
||||
qrCode('QR code', icon: Icons.qr_code),
|
||||
clipBoard('ClipBoard', icon: Icons.copy);
|
||||
|
||||
const ExportDestination(
|
||||
this.label, {
|
||||
required this.icon,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final IconData icon;
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
export 'comments_order.dart';
|
||||
export 'export_destination.dart';
|
||||
export 'fetch_mode.dart';
|
||||
export 'font.dart';
|
||||
export 'font_size.dart';
|
||||
|
@ -30,6 +30,7 @@ abstract class Preference<T> extends Equatable with SettingsDisplayable {
|
||||
const StoryUrlModePreference(),
|
||||
const NotificationModePreference(),
|
||||
const SwipeGesturePreference(),
|
||||
const AutoScrollModePreference(),
|
||||
const CollapseModePreference(),
|
||||
const ReaderModePreference(),
|
||||
const MarkReadStoriesModePreference(),
|
||||
@ -54,12 +55,13 @@ const bool _notificationModeDefaultValue = true;
|
||||
const bool _swipeGestureModeDefaultValue = false;
|
||||
const bool _displayModeDefaultValue = true;
|
||||
const bool _eyeCandyModeDefaultValue = false;
|
||||
const bool _trueDarkModeDefaultValue = false;
|
||||
const bool _trueDarkModeDefaultValue = true;
|
||||
const bool _readerModeDefaultValue = true;
|
||||
const bool _markReadStoriesModeDefaultValue = true;
|
||||
const bool _metadataModeDefaultValue = true;
|
||||
const bool _storyUrlModeDefaultValue = true;
|
||||
const bool _collapseModeDefaultValue = true;
|
||||
const bool _autoScrollModeDefaultValue = true;
|
||||
final int _fetchModeDefaultValue = FetchMode.eager.index;
|
||||
final int _commentsOrderDefaultValue = CommentsOrder.natural.index;
|
||||
final int _fontSizeDefaultValue = FontSize.regular.index;
|
||||
@ -127,6 +129,26 @@ class CollapseModePreference extends BooleanPreference {
|
||||
'''if disabled, tap on the top of comment tile to collapse.''';
|
||||
}
|
||||
|
||||
class AutoScrollModePreference extends BooleanPreference {
|
||||
const AutoScrollModePreference({bool? val})
|
||||
: super(val: val ?? _autoScrollModeDefaultValue);
|
||||
|
||||
@override
|
||||
AutoScrollModePreference copyWith({required bool? val}) {
|
||||
return AutoScrollModePreference(val: val);
|
||||
}
|
||||
|
||||
@override
|
||||
String get key => 'autoScrollMode';
|
||||
|
||||
@override
|
||||
String get title => 'Auto-scroll on collapsing';
|
||||
|
||||
@override
|
||||
String get subtitle =>
|
||||
'''automatically scroll to next comment when you collapse a comment.''';
|
||||
}
|
||||
|
||||
/// The value deciding whether or not the story
|
||||
/// tile should display link preview. Defaults to true.
|
||||
class DisplayModePreference extends BooleanPreference {
|
||||
|
@ -30,14 +30,27 @@ class DateTimeRangeFilter implements NumericFilter {
|
||||
|
||||
@override
|
||||
String get query {
|
||||
if (startTime == null || endTime == null) return '';
|
||||
|
||||
final int? startTimestamp = startTime == null
|
||||
? null
|
||||
: startTime!.toUtc().millisecondsSinceEpoch ~/ 1000;
|
||||
final int? endTimestamp = endTime == null
|
||||
int? endTimestamp = endTime == null
|
||||
? null
|
||||
: endTime!.toUtc().millisecondsSinceEpoch ~/ 1000;
|
||||
|
||||
if (startTimestamp == endTimestamp) {
|
||||
endTimestamp = startTime!
|
||||
.add(const Duration(hours: 24))
|
||||
.toUtc()
|
||||
.millisecondsSinceEpoch ~/
|
||||
1000;
|
||||
}
|
||||
|
||||
if (startTimestamp == null || endTimestamp == null) return '';
|
||||
|
||||
final String query =
|
||||
'''${startTimestamp == null ? '' : 'created_at_i>$startTimestamp'},${endTimestamp == null ? '' : 'created_at_i<$endTimestamp'}''';
|
||||
'''created_at_i>=$startTimestamp, created_at_i<=$endTimestamp''';
|
||||
|
||||
if (query.endsWith(',')) {
|
||||
return query.replaceFirst(',', '');
|
||||
|
@ -57,7 +57,7 @@ class _HomeScreenState extends State<HomeScreen>
|
||||
DeviceScreenType.mobile) {
|
||||
locator.get<Logger>().i('resetting comments in CommentCache');
|
||||
Future<void>.delayed(
|
||||
const Duration(milliseconds: 500),
|
||||
Durations.ms500,
|
||||
locator.get<CommentCache>().resetComments,
|
||||
);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart' hide Badge;
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:hacki/config/constants.dart';
|
||||
import 'package:hacki/cubits/cubits.dart';
|
||||
import 'package:hacki/screens/screens.dart';
|
||||
import 'package:hacki/screens/widgets/widgets.dart';
|
||||
@ -36,7 +37,7 @@ class TabletHomeScreen extends StatelessWidget {
|
||||
top: Dimens.zero,
|
||||
bottom: Dimens.zero,
|
||||
width: homeScreenWidth,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
duration: Durations.ms300,
|
||||
curve: Curves.elasticOut,
|
||||
child: homeScreen,
|
||||
),
|
||||
@ -52,7 +53,7 @@ class TabletHomeScreen extends StatelessWidget {
|
||||
top: Dimens.zero,
|
||||
bottom: Dimens.zero,
|
||||
left: state.expanded ? Dimens.zero : homeScreenWidth,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
duration: Durations.ms300,
|
||||
curve: Curves.elasticOut,
|
||||
child: const _TabletStoryView(),
|
||||
),
|
||||
|
@ -153,9 +153,9 @@ class _ItemScreenState extends State<ItemScreen> with RouteAware {
|
||||
);
|
||||
final GlobalKey fontSizeIconButtonKey = GlobalKey();
|
||||
|
||||
static const Duration _storyLinkTapThrottleDelay = Duration(seconds: 2);
|
||||
static const Duration _storyLinkTapThrottleDelay = Durations.twoSeconds;
|
||||
static const Duration _featureDiscoveryDismissThrottleDelay =
|
||||
Duration(seconds: 1);
|
||||
Durations.oneSecond;
|
||||
|
||||
@override
|
||||
void didPop() {
|
||||
|
@ -139,6 +139,7 @@ class MainView extends StatelessWidget {
|
||||
},
|
||||
onMoreTapped: onMoreTapped,
|
||||
onRightMoreTapped: onRightMoreTapped,
|
||||
itemScrollController: itemScrollController,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
@ -2,6 +2,7 @@ import 'package:clipboard/clipboard.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:hacki/config/constants.dart';
|
||||
import 'package:hacki/cubits/cubits.dart';
|
||||
import 'package:hacki/extensions/extensions.dart';
|
||||
import 'package:hacki/models/item/item.dart';
|
||||
@ -60,7 +61,7 @@ class _ReplyBoxState extends State<ReplyBox> {
|
||||
),
|
||||
child: AnimatedContainer(
|
||||
height: expanded ? expandedHeight : _collapsedHeight,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
duration: Durations.ms200,
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: <BoxShadow>[
|
||||
if (!context.read<SplitViewCubit>().state.enabled)
|
||||
@ -79,7 +80,7 @@ class _ReplyBoxState extends State<ReplyBox> {
|
||||
),
|
||||
AnimatedContainer(
|
||||
height: expanded ? Dimens.pt36 : Dimens.zero,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
duration: Durations.ms200,
|
||||
),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
@ -107,7 +108,7 @@ class _ReplyBoxState extends State<ReplyBox> {
|
||||
AnimatedOpacity(
|
||||
opacity:
|
||||
expanded ? NumSwitch.on : NumSwitch.off,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
duration: Durations.ms300,
|
||||
child: IconButton(
|
||||
key: const Key('quote'),
|
||||
icon: const Icon(
|
||||
|
@ -29,7 +29,7 @@ class _ProfileScreenState extends State<ProfileScreen>
|
||||
final RefreshController refreshControllerFav = RefreshController();
|
||||
final RefreshController refreshControllerNotification = RefreshController();
|
||||
final ScrollController scrollController = ScrollController();
|
||||
final Throttle throttle = Throttle(delay: const Duration(seconds: 2));
|
||||
final Throttle throttle = Throttle(delay: Durations.twoSeconds);
|
||||
|
||||
PageType pageType = PageType.notification;
|
||||
|
||||
|
78
lib/screens/profile/qr_code_scanner_screen.dart
Normal file
@ -0,0 +1,78 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hacki/main.dart';
|
||||
import 'package:hacki/styles/styles.dart';
|
||||
import 'package:qr_code_scanner/qr_code_scanner.dart';
|
||||
|
||||
class QrCodeScannerScreen extends StatefulWidget {
|
||||
const QrCodeScannerScreen({super.key});
|
||||
|
||||
static const String routeName = '/qr-code-scanner';
|
||||
|
||||
static Route<dynamic> route() {
|
||||
return MaterialPageRoute<String?>(
|
||||
settings: const RouteSettings(name: routeName),
|
||||
builder: (_) => const QrCodeScannerScreen(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
State<QrCodeScannerScreen> createState() => _QrCodeScannerScreenState();
|
||||
}
|
||||
|
||||
class _QrCodeScannerScreenState extends State<QrCodeScannerScreen> {
|
||||
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
|
||||
QRViewController? controller;
|
||||
bool isFlashOn = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
elevation: 0,
|
||||
backgroundColor: Palette.transparent,
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
icon: Icon(isFlashOn ? Icons.flash_off : Icons.flash_on),
|
||||
onPressed: () {
|
||||
controller?.toggleFlash();
|
||||
setState(() {
|
||||
isFlashOn = !isFlashOn;
|
||||
});
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.cameraswitch_outlined),
|
||||
onPressed: controller?.flipCamera,
|
||||
),
|
||||
],
|
||||
),
|
||||
extendBodyBehindAppBar: true,
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: QRView(
|
||||
key: qrKey,
|
||||
onQRViewCreated: onQRViewCreated,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void onQRViewCreated(QRViewController controller) {
|
||||
setState(() {
|
||||
this.controller = controller;
|
||||
});
|
||||
controller.scannedDataStream.listen((Barcode scanData) {
|
||||
controller.stopCamera();
|
||||
HackiApp.navigatorKey.currentState?.pop(scanData.code);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
controller?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
55
lib/screens/profile/qr_code_view_screen.dart
Normal file
@ -0,0 +1,55 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hacki/styles/palette.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
|
||||
class QrCodeViewScreen extends StatelessWidget {
|
||||
const QrCodeViewScreen({
|
||||
required this.data,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String data;
|
||||
|
||||
static const String routeName = '/qr-code-view';
|
||||
|
||||
static Route<dynamic> route({required String data}) {
|
||||
return MaterialPageRoute<QrCodeViewScreen>(
|
||||
settings: const RouteSettings(name: routeName),
|
||||
builder: (_) => QrCodeViewScreen(
|
||||
data: data,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static const int qrCodeVersion = 4;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
elevation: 0,
|
||||
backgroundColor: Palette.transparent,
|
||||
),
|
||||
body: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Center(
|
||||
child: QrImageView(
|
||||
data: data,
|
||||
dataModuleStyle: QrDataModuleStyle(
|
||||
dataModuleShape: QrDataModuleShape.square,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
eyeStyle: QrEyeStyle(
|
||||
eyeShape: QrEyeShape.square,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
version: qrCodeVersion,
|
||||
size: 300,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:adaptive_theme/adaptive_theme.dart';
|
||||
import 'package:clipboard/clipboard.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||
import 'package:flutter_email_sender/flutter_email_sender.dart';
|
||||
@ -13,9 +15,12 @@ import 'package:hacki/config/constants.dart';
|
||||
import 'package:hacki/config/locator.dart';
|
||||
import 'package:hacki/cubits/cubits.dart';
|
||||
import 'package:hacki/extensions/extensions.dart';
|
||||
import 'package:hacki/main.dart';
|
||||
import 'package:hacki/models/models.dart';
|
||||
import 'package:hacki/repositories/repositories.dart';
|
||||
import 'package:hacki/screens/profile/models/page_type.dart';
|
||||
import 'package:hacki/screens/profile/qr_code_scanner_screen.dart';
|
||||
import 'package:hacki/screens/profile/qr_code_view_screen.dart';
|
||||
import 'package:hacki/screens/profile/widgets/offline_list_tile.dart';
|
||||
import 'package:hacki/screens/profile/widgets/tab_bar_settings.dart';
|
||||
import 'package:hacki/screens/widgets/widgets.dart';
|
||||
@ -243,6 +248,13 @@ class _SettingsState extends State<Settings> {
|
||||
),
|
||||
onTap: onExportFavoritesTapped,
|
||||
),
|
||||
ListTile(
|
||||
title: const Text(
|
||||
'Import Favorites',
|
||||
),
|
||||
onTap: () =>
|
||||
onImportFavoritesTapped(context.read<FavCubit>()),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text(
|
||||
'Clear Favorites',
|
||||
@ -404,8 +416,9 @@ class _SettingsState extends State<Settings> {
|
||||
AdaptiveTheme.of(context).setSystem();
|
||||
}
|
||||
|
||||
final Brightness brightness = Theme.of(context).brightness;
|
||||
ThemeUtil.updateAndroidStatusBarSetting(brightness, val);
|
||||
final Brightness brightness =
|
||||
SchedulerBinding.instance.platformDispatcher.platformBrightness;
|
||||
ThemeUtil.updateStatusBarSetting(brightness, val);
|
||||
}
|
||||
|
||||
void showClearCacheDialog() {
|
||||
@ -752,20 +765,68 @@ class _SettingsState extends State<Settings> {
|
||||
}
|
||||
|
||||
Future<void> onExportFavoritesTapped() async {
|
||||
final List<int> allFavorites = context.read<FavCubit>().state.favIds;
|
||||
return showModalBottomSheet<ExportDestination>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SafeArea(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
...ExportDestination.values.map(
|
||||
(ExportDestination e) => ListTile(
|
||||
leading: Icon(e.icon),
|
||||
title: Text(e.label),
|
||||
onTap: () => Navigator.pop<ExportDestination>(context, e),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
).then(
|
||||
(ExportDestination? destination) => exportFavorites(to: destination),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> onImportFavoritesTapped(FavCubit favCubit) async {
|
||||
final String? res = await HackiApp.navigatorKey.currentState
|
||||
?.pushNamed(QrCodeScannerScreen.routeName) as String?;
|
||||
final List<int>? ids =
|
||||
res?.split('\n').map(int.tryParse).whereType<int>().toList();
|
||||
if (ids == null) return;
|
||||
for (final int id in ids) {
|
||||
await favCubit.addFav(id);
|
||||
}
|
||||
showSnackBar(content: 'Favorites imported successfully.');
|
||||
}
|
||||
|
||||
Future<void> exportFavorites({required ExportDestination? to}) async {
|
||||
final ExportDestination? destination = to;
|
||||
if (destination == null) return;
|
||||
|
||||
final List<int> allFavorites = context.read<FavCubit>().state.favIds;
|
||||
if (allFavorites.isEmpty) {
|
||||
showSnackBar(content: "You don't have any favorite item.");
|
||||
return;
|
||||
}
|
||||
final String allFavoritesStr = allFavorites.join('\n');
|
||||
|
||||
try {
|
||||
await FlutterClipboard.copy(
|
||||
allFavorites.join('\n'),
|
||||
).whenComplete(HapticFeedbackUtil.selection);
|
||||
showSnackBar(content: 'Ids of favorites have been copied to clipboard.');
|
||||
} catch (error, stackTrace) {
|
||||
error.logError(stackTrace: stackTrace);
|
||||
switch (destination) {
|
||||
case ExportDestination.qrCode:
|
||||
await HackiApp.navigatorKey.currentState?.pushNamed(
|
||||
QrCodeViewScreen.routeName,
|
||||
arguments: allFavoritesStr,
|
||||
);
|
||||
case ExportDestination.clipBoard:
|
||||
try {
|
||||
await FlutterClipboard.copy(allFavoritesStr)
|
||||
.whenComplete(HapticFeedbackUtil.selection);
|
||||
showSnackBar(
|
||||
content: 'Ids of favorites have been copied to clipboard.',
|
||||
);
|
||||
} catch (error, stackTrace) {
|
||||
error.logError(stackTrace: stackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
export 'home/home_screen.dart';
|
||||
export 'item/item_screen.dart';
|
||||
export 'profile/profile_screen.dart';
|
||||
export 'profile/qr_code_scanner_screen.dart';
|
||||
export 'profile/qr_code_view_screen.dart';
|
||||
export 'search/search_screen.dart';
|
||||
export 'submit/submit_screen.dart';
|
||||
export 'web_view/web_view_screen.dart';
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_fadein/flutter_fadein.dart';
|
||||
import 'package:hacki/config/constants.dart';
|
||||
import 'package:hacki/cubits/cubits.dart';
|
||||
import 'package:hacki/extensions/extensions.dart';
|
||||
import 'package:hacki/models/models.dart';
|
||||
@ -28,7 +29,17 @@ class SearchScreen extends StatefulWidget {
|
||||
|
||||
class _SearchScreenState extends State<SearchScreen> {
|
||||
final RefreshController refreshController = RefreshController();
|
||||
final Debouncer debouncer = Debouncer(delay: const Duration(seconds: 1));
|
||||
final ScrollController scrollController = ScrollController();
|
||||
final Debouncer debouncer = Debouncer(delay: Durations.oneSecond);
|
||||
|
||||
static const Duration chipsAnimationDuration = Durations.ms300;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
refreshController.dispose();
|
||||
scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -72,6 +83,85 @@ class _SearchScreenState extends State<SearchScreen> {
|
||||
const SizedBox(
|
||||
height: Dimens.pt6,
|
||||
),
|
||||
AnimatedCrossFade(
|
||||
duration: chipsAnimationDuration,
|
||||
crossFadeState: state.showDateRangeShortcutChips
|
||||
? CrossFadeState.showSecond
|
||||
: CrossFadeState.showFirst,
|
||||
firstChild: SizedBox.fromSize(),
|
||||
secondChild: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
const SizedBox(
|
||||
width: Dimens.pt8,
|
||||
),
|
||||
DateTimeShortcutChip.dayBefore(
|
||||
onDateTimeRangeUpdated: context
|
||||
.read<SearchCubit>()
|
||||
.onDateTimeRangeUpdated,
|
||||
startDate: state.dateFilter?.startTime,
|
||||
endDate: state.dateFilter?.endTime,
|
||||
),
|
||||
const SizedBox(
|
||||
width: Dimens.pt8,
|
||||
),
|
||||
DateTimeShortcutChip.dayAfter(
|
||||
onDateTimeRangeUpdated: context
|
||||
.read<SearchCubit>()
|
||||
.onDateTimeRangeUpdated,
|
||||
startDate: state.dateFilter?.startTime,
|
||||
endDate: state.dateFilter?.endTime,
|
||||
),
|
||||
const SizedBox(
|
||||
width: Dimens.pt8,
|
||||
),
|
||||
DateTimeShortcutChip.weekBefore(
|
||||
onDateTimeRangeUpdated: context
|
||||
.read<SearchCubit>()
|
||||
.onDateTimeRangeUpdated,
|
||||
startDate: state.dateFilter?.startTime,
|
||||
endDate: state.dateFilter?.endTime,
|
||||
),
|
||||
const SizedBox(
|
||||
width: Dimens.pt8,
|
||||
),
|
||||
DateTimeShortcutChip.weekAfter(
|
||||
onDateTimeRangeUpdated: context
|
||||
.read<SearchCubit>()
|
||||
.onDateTimeRangeUpdated,
|
||||
startDate: state.dateFilter?.startTime,
|
||||
endDate: state.dateFilter?.endTime,
|
||||
),
|
||||
const SizedBox(
|
||||
width: Dimens.pt8,
|
||||
),
|
||||
DateTimeShortcutChip.monthBefore(
|
||||
onDateTimeRangeUpdated: context
|
||||
.read<SearchCubit>()
|
||||
.onDateTimeRangeUpdated,
|
||||
startDate: state.dateFilter?.startTime,
|
||||
endDate: state.dateFilter?.endTime,
|
||||
),
|
||||
const SizedBox(
|
||||
width: Dimens.pt8,
|
||||
),
|
||||
DateTimeShortcutChip.monthAfter(
|
||||
onDateTimeRangeUpdated: context
|
||||
.read<SearchCubit>()
|
||||
.onDateTimeRangeUpdated,
|
||||
startDate: state.dateFilter?.startTime,
|
||||
endDate: state.dateFilter?.endTime,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
@ -80,7 +170,9 @@ class _SearchScreenState extends State<SearchScreen> {
|
||||
width: Dimens.pt8,
|
||||
),
|
||||
DateTimeRangeFilterChip(
|
||||
filter: state.params.get<DateTimeRangeFilter>(),
|
||||
filter: state.dateFilter,
|
||||
initialStartDate: state.dateFilter?.startTime,
|
||||
initialEndDate: state.dateFilter?.endTime,
|
||||
onDateTimeRangeUpdated: context
|
||||
.read<SearchCubit>()
|
||||
.onDateTimeRangeUpdated,
|
||||
@ -200,11 +292,15 @@ class _SearchScreenState extends State<SearchScreen> {
|
||||
},
|
||||
),
|
||||
controller: refreshController,
|
||||
scrollController: scrollController,
|
||||
onRefresh: () {},
|
||||
onLoading: () {
|
||||
context.read<SearchCubit>().loadMore();
|
||||
},
|
||||
child: ListView(
|
||||
physics: state.results.isEmpty
|
||||
? const NeverScrollableScrollPhysics()
|
||||
: null,
|
||||
children: <Widget>[
|
||||
...state.results
|
||||
.map(
|
||||
|
@ -6,12 +6,16 @@ import 'package:intl/intl.dart';
|
||||
class DateTimeRangeFilterChip extends StatelessWidget {
|
||||
const DateTimeRangeFilterChip({
|
||||
required this.filter,
|
||||
required this.initialStartDate,
|
||||
required this.initialEndDate,
|
||||
required this.onDateTimeRangeUpdated,
|
||||
required this.onDateTimeRangeRemoved,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final DateTimeRangeFilter? filter;
|
||||
final DateTime? initialStartDate;
|
||||
final DateTime? initialEndDate;
|
||||
final void Function(DateTime, DateTime) onDateTimeRangeUpdated;
|
||||
final VoidCallback onDateTimeRangeRemoved;
|
||||
|
||||
@ -25,6 +29,9 @@ class DateTimeRangeFilterChip extends StatelessWidget {
|
||||
context: context,
|
||||
firstDate: DateTime.now().subtract(const Duration(days: 20 * 365)),
|
||||
lastDate: DateTime.now(),
|
||||
initialDateRange: initialStartDate != null && initialEndDate != null
|
||||
? DateTimeRange(start: initialStartDate!, end: initialEndDate!)
|
||||
: null,
|
||||
).then((DateTimeRange? range) {
|
||||
if (range != null) {
|
||||
onDateTimeRangeUpdated(range.start, range.end);
|
||||
@ -34,11 +41,22 @@ class DateTimeRangeFilterChip extends StatelessWidget {
|
||||
});
|
||||
},
|
||||
selected: filter != null,
|
||||
label:
|
||||
'''from ${_formatDateTime(filter?.startTime) ?? 'X'} to ${_formatDateTime(filter?.endTime) ?? 'Y'}''',
|
||||
label: _label,
|
||||
);
|
||||
}
|
||||
|
||||
String get _label {
|
||||
final DateTime? start = filter?.startTime;
|
||||
final DateTime? end = filter?.endTime;
|
||||
if (start == null && end == null) {
|
||||
return '''from X to Y''';
|
||||
} else if (start == end) {
|
||||
return '''from ${_formatDateTime(start)}''';
|
||||
} else {
|
||||
return '''from ${_formatDateTime(start)} to ${_formatDateTime(end)}''';
|
||||
}
|
||||
}
|
||||
|
||||
static String? _formatDateTime(DateTime? dateTime) {
|
||||
if (dateTime == null) return null;
|
||||
|
||||
|
89
lib/screens/search/widgets/date_time_shortcut_chip.dart
Normal file
@ -0,0 +1,89 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hacki/screens/search/widgets/date_time_range_filter_chip.dart';
|
||||
import 'package:hacki/screens/widgets/widgets.dart' show CustomChip;
|
||||
|
||||
typedef Calculator = DateTime Function(DateTime);
|
||||
|
||||
/// A set of chips that perform addition or subtraction on the date selected
|
||||
/// by [DateTimeRangeFilterChip]
|
||||
class DateTimeShortcutChip extends StatelessWidget {
|
||||
const DateTimeShortcutChip({
|
||||
required this.onDateTimeRangeUpdated,
|
||||
required this.startDate,
|
||||
required this.endDate,
|
||||
required this.label,
|
||||
required Calculator calculator,
|
||||
super.key,
|
||||
}) : _calculator = calculator;
|
||||
|
||||
DateTimeShortcutChip.dayBefore({
|
||||
required this.onDateTimeRangeUpdated,
|
||||
required this.startDate,
|
||||
required this.endDate,
|
||||
super.key,
|
||||
}) : label = '- day',
|
||||
_calculator =
|
||||
((DateTime date) => date.subtract(const Duration(hours: 24)));
|
||||
|
||||
DateTimeShortcutChip.dayAfter({
|
||||
required this.onDateTimeRangeUpdated,
|
||||
required this.startDate,
|
||||
required this.endDate,
|
||||
super.key,
|
||||
}) : label = '+ day',
|
||||
_calculator = ((DateTime date) => date.add(const Duration(hours: 24)));
|
||||
|
||||
DateTimeShortcutChip.weekBefore({
|
||||
required this.onDateTimeRangeUpdated,
|
||||
required this.startDate,
|
||||
required this.endDate,
|
||||
super.key,
|
||||
}) : label = '- week',
|
||||
_calculator =
|
||||
((DateTime date) => date.subtract(const Duration(days: 7)));
|
||||
|
||||
DateTimeShortcutChip.weekAfter({
|
||||
required this.onDateTimeRangeUpdated,
|
||||
required this.startDate,
|
||||
required this.endDate,
|
||||
super.key,
|
||||
}) : label = '+ week',
|
||||
_calculator = ((DateTime date) => date.add(const Duration(days: 7)));
|
||||
|
||||
DateTimeShortcutChip.monthBefore({
|
||||
required this.onDateTimeRangeUpdated,
|
||||
required this.startDate,
|
||||
required this.endDate,
|
||||
super.key,
|
||||
}) : label = '- 30 days',
|
||||
_calculator =
|
||||
((DateTime date) => date.subtract(const Duration(days: 30)));
|
||||
|
||||
DateTimeShortcutChip.monthAfter({
|
||||
required this.onDateTimeRangeUpdated,
|
||||
required this.startDate,
|
||||
required this.endDate,
|
||||
super.key,
|
||||
}) : label = '+ 30 days',
|
||||
_calculator = ((DateTime date) => date.add(const Duration(days: 30)));
|
||||
|
||||
final void Function(DateTime, DateTime) onDateTimeRangeUpdated;
|
||||
final DateTime? startDate;
|
||||
final DateTime? endDate;
|
||||
final String label;
|
||||
final Calculator _calculator;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomChip(
|
||||
onSelected: (bool value) {
|
||||
if (startDate == null || endDate == null) return;
|
||||
final DateTime updatedStartDate = _calculator(startDate!);
|
||||
final DateTime updatedEndDate = _calculator(endDate!);
|
||||
onDateTimeRangeUpdated(updatedStartDate, updatedEndDate);
|
||||
},
|
||||
selected: false,
|
||||
label: label,
|
||||
);
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
export 'custom_range_filter_chip.dart';
|
||||
export 'date_time_range_filter_chip.dart';
|
||||
export 'date_time_shortcut_chip.dart';
|
||||
export 'posted_by_filter_chip.dart';
|
||||
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:hacki/blocs/blocs.dart';
|
||||
import 'package:hacki/config/constants.dart';
|
||||
import 'package:hacki/cubits/cubits.dart';
|
||||
import 'package:hacki/extensions/extensions.dart';
|
||||
import 'package:hacki/models/models.dart';
|
||||
@ -9,6 +10,7 @@ import 'package:hacki/screens/widgets/widgets.dart';
|
||||
import 'package:hacki/services/services.dart';
|
||||
import 'package:hacki/styles/styles.dart';
|
||||
import 'package:hacki/utils/utils.dart';
|
||||
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
||||
|
||||
class CommentTile extends StatelessWidget {
|
||||
const CommentTile({
|
||||
@ -23,6 +25,7 @@ class CommentTile extends StatelessWidget {
|
||||
this.actionable = true,
|
||||
this.level = 0,
|
||||
this.onTap,
|
||||
this.itemScrollController,
|
||||
});
|
||||
|
||||
final String? opUsername;
|
||||
@ -30,6 +33,7 @@ class CommentTile extends StatelessWidget {
|
||||
final int level;
|
||||
final bool actionable;
|
||||
final FetchMode fetchMode;
|
||||
final ItemScrollController? itemScrollController;
|
||||
|
||||
final void Function(Comment)? onReplyTapped;
|
||||
final void Function(Comment, Rect?)? onMoreTapped;
|
||||
@ -116,8 +120,7 @@ class CommentTile extends StatelessWidget {
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
if (actionable) {
|
||||
HapticFeedbackUtil.selection();
|
||||
context.read<CollapseCubit>().collapse();
|
||||
_collapse(context);
|
||||
} else {
|
||||
onTap?.call();
|
||||
}
|
||||
@ -159,7 +162,7 @@ class CommentTile extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
AnimatedSize(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
duration: Durations.ms200,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
@ -339,8 +342,27 @@ class CommentTile extends StatelessWidget {
|
||||
|
||||
void _onTextTapped(BuildContext context) {
|
||||
if (context.read<PreferenceCubit>().state.tapAnywhereToCollapseEnabled) {
|
||||
HapticFeedbackUtil.selection();
|
||||
context.read<CollapseCubit>().collapse();
|
||||
_collapse(context);
|
||||
}
|
||||
}
|
||||
|
||||
void _collapse(BuildContext context) {
|
||||
HapticFeedbackUtil.selection();
|
||||
context.read<CollapseCubit>().collapse();
|
||||
if (context.read<CollapseCubit>().state.collapsed &&
|
||||
context.read<PreferenceCubit>().state.autoScrollEnabled) {
|
||||
Future<void>.delayed(
|
||||
Durations.ms300,
|
||||
() {
|
||||
itemScrollController?.scrollTo(
|
||||
index:
|
||||
context.read<CommentsCubit>().state.comments.indexOf(comment) +
|
||||
1,
|
||||
alignment: 0.1,
|
||||
duration: Durations.ms300,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ class _CustomTabBarState extends State<CustomTabBar> {
|
||||
currentIndex == i ? TextDimens.pt14 : TextDimens.pt10,
|
||||
color: currentIndex == i ? Palette.orange : Palette.grey,
|
||||
),
|
||||
duration: const Duration(milliseconds: 200),
|
||||
duration: Durations.ms200,
|
||||
child: Text(
|
||||
state.tabs.elementAt(i).label,
|
||||
key: ValueKey<String>(
|
||||
|
@ -17,7 +17,7 @@ class DeviceGestureWrapper extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return MediaQuery(
|
||||
data: const MediaQueryData(
|
||||
gestureSettings: DeviceGestureSettings(touchSlop: 7.9),
|
||||
gestureSettings: DeviceGestureSettings(touchSlop: 12),
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
|
@ -233,7 +233,7 @@ class _LinkPreviewState extends State<LinkPreview> {
|
||||
secondChild: loadedWidget,
|
||||
crossFadeState:
|
||||
_loading ? CrossFadeState.showFirst : CrossFadeState.showSecond,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
duration: Durations.ms500,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ class LinkView extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
height: isUsingSerifFont! ? Dimens.pt2 : Dimens.pt4,
|
||||
height: isUsingSerifFont! ? Dimens.zero : Dimens.pt4,
|
||||
),
|
||||
Text(
|
||||
title,
|
||||
|
@ -15,7 +15,7 @@ class _OnboardingViewState extends State<OnboardingView> {
|
||||
final PageController pageController = PageController();
|
||||
final Throttle throttle = Throttle(delay: _throttleDelay);
|
||||
|
||||
static const Duration _throttleDelay = Duration(milliseconds: 100);
|
||||
static const Duration _throttleDelay = Durations.ms100;
|
||||
static const double _screenshotHeight = 550;
|
||||
|
||||
@override
|
||||
@ -80,7 +80,7 @@ class _OnboardingViewState extends State<OnboardingView> {
|
||||
} else {
|
||||
throttle.run(() {
|
||||
pageController.nextPage(
|
||||
duration: const Duration(milliseconds: 600),
|
||||
duration: Durations.ms600,
|
||||
curve: SpringCurve.underDamped,
|
||||
);
|
||||
});
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hacki/config/constants.dart';
|
||||
|
||||
class TapDownWrapper extends StatefulWidget {
|
||||
const TapDownWrapper({
|
||||
@ -22,7 +23,7 @@ class _TapDownWrapperState extends State<TapDownWrapper>
|
||||
@override
|
||||
void initState() {
|
||||
controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 100),
|
||||
duration: Durations.ms100,
|
||||
vsync: this,
|
||||
);
|
||||
|
||||
|
@ -5,6 +5,7 @@ import 'dart:io';
|
||||
import 'package:collection/collection.dart' show IterableExtension;
|
||||
import 'package:fast_gbk/fast_gbk.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hacki/config/constants.dart';
|
||||
import 'package:hacki/config/locator.dart';
|
||||
import 'package:hacki/extensions/extensions.dart';
|
||||
import 'package:hacki/models/models.dart';
|
||||
@ -321,7 +322,7 @@ class WebAnalyzer {
|
||||
final Uri uri = Uri.parse(url);
|
||||
final HttpClient ioClient = HttpClient()
|
||||
..badCertificateCallback = _certificateCheck
|
||||
..connectionTimeout = const Duration(seconds: 2);
|
||||
..connectionTimeout = Durations.twoSeconds;
|
||||
final IOClient client = IOClient(ioClient);
|
||||
final BaseRequest request = Request('GET', uri)
|
||||
..followRedirects = true
|
||||
@ -337,7 +338,7 @@ class WebAnalyzer {
|
||||
|
||||
try {
|
||||
final IOStreamedResponse stream =
|
||||
await client.send(request).timeout(const Duration(seconds: 10));
|
||||
await client.send(request).timeout(Durations.tenSeconds);
|
||||
|
||||
if (stream.statusCode == HttpStatus.movedTemporarily ||
|
||||
stream.statusCode == HttpStatus.movedPermanently) {
|
||||
|
@ -1,61 +1,92 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:adaptive_theme/adaptive_theme.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:hacki/styles/styles.dart';
|
||||
|
||||
abstract class ThemeUtil {
|
||||
/// Temp fix for the issue:
|
||||
/// https://github.com/flutter/flutter/issues/119465
|
||||
static Future<void> updateAndroidStatusBarSetting(
|
||||
static Future<void> updateStatusBarSetting(
|
||||
Brightness brightness,
|
||||
AdaptiveThemeMode? mode,
|
||||
) async {
|
||||
if (Platform.isAndroid == false) return;
|
||||
|
||||
final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
|
||||
final AndroidDeviceInfo androidInfo = await deviceInfoPlugin.androidInfo;
|
||||
final int sdk = androidInfo.version.sdkInt;
|
||||
|
||||
if (sdk > 28) return;
|
||||
switch (mode) {
|
||||
case AdaptiveThemeMode.light:
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
statusBarBrightness: Brightness.dark,
|
||||
statusBarIconBrightness: Brightness.dark,
|
||||
statusBarColor: Palette.transparent,
|
||||
),
|
||||
);
|
||||
case AdaptiveThemeMode.dark:
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
statusBarBrightness: Brightness.light,
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
statusBarColor: Palette.transparent,
|
||||
),
|
||||
);
|
||||
case AdaptiveThemeMode.system:
|
||||
case null:
|
||||
switch (brightness) {
|
||||
case Brightness.light:
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
statusBarBrightness: Brightness.dark,
|
||||
statusBarIconBrightness: Brightness.dark,
|
||||
statusBarColor: Palette.transparent,
|
||||
),
|
||||
);
|
||||
case Brightness.dark:
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
statusBarBrightness: Brightness.light,
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
statusBarColor: Palette.transparent,
|
||||
),
|
||||
);
|
||||
}
|
||||
if (Platform.isAndroid) {
|
||||
switch (mode) {
|
||||
case AdaptiveThemeMode.light:
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
statusBarBrightness: Brightness.dark,
|
||||
statusBarIconBrightness: Brightness.dark,
|
||||
statusBarColor: Palette.transparent,
|
||||
),
|
||||
);
|
||||
case AdaptiveThemeMode.dark:
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
statusBarBrightness: Brightness.light,
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
statusBarColor: Palette.transparent,
|
||||
),
|
||||
);
|
||||
case AdaptiveThemeMode.system:
|
||||
case null:
|
||||
switch (brightness) {
|
||||
case Brightness.light:
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
statusBarBrightness: Brightness.dark,
|
||||
statusBarIconBrightness: Brightness.dark,
|
||||
statusBarColor: Palette.transparent,
|
||||
),
|
||||
);
|
||||
case Brightness.dark:
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
statusBarBrightness: Brightness.light,
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
statusBarColor: Palette.transparent,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch (mode) {
|
||||
case AdaptiveThemeMode.light:
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
statusBarBrightness: Brightness.light,
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
statusBarColor: Palette.transparent,
|
||||
),
|
||||
);
|
||||
case AdaptiveThemeMode.dark:
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
statusBarBrightness: Brightness.dark,
|
||||
statusBarIconBrightness: Brightness.dark,
|
||||
statusBarColor: Palette.transparent,
|
||||
),
|
||||
);
|
||||
case AdaptiveThemeMode.system:
|
||||
case null:
|
||||
switch (brightness) {
|
||||
case Brightness.light:
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
statusBarBrightness: Brightness.light,
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
statusBarColor: Palette.transparent,
|
||||
),
|
||||
);
|
||||
case Brightness.dark:
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
statusBarBrightness: Brightness.dark,
|
||||
statusBarIconBrightness: Brightness.dark,
|
||||
statusBarColor: Palette.transparent,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
26
pubspec.lock
@ -840,6 +840,30 @@ packages:
|
||||
url: "https://github.com/livinglist/flutter_pulltorefresh"
|
||||
source: git
|
||||
version: "2.0.0"
|
||||
qr:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: qr
|
||||
sha256: "64957a3930367bf97cc211a5af99551d630f2f4625e38af10edd6b19131b64b3"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
qr_code_scanner:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: qr_code_scanner
|
||||
sha256: f23b68d893505a424f0bd2e324ebea71ed88465d572d26bb8d2e78a4749591fd
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
qr_flutter:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: qr_flutter
|
||||
sha256: "5095f0fc6e3f71d08adef8feccc8cea4f12eec18a2e31c2e8d82cb6019f4b097"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.1.0"
|
||||
receive_sharing_intent:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -1390,4 +1414,4 @@ packages:
|
||||
version: "3.1.2"
|
||||
sdks:
|
||||
dart: ">=3.0.0 <4.0.0"
|
||||
flutter: ">=3.10.1"
|
||||
flutter: ">=3.10.5"
|
||||
|
@ -1,11 +1,11 @@
|
||||
name: hacki
|
||||
description: A Hacker News reader.
|
||||
version: 1.6.0+110
|
||||
version: 1.8.0+116
|
||||
publish_to: none
|
||||
|
||||
environment:
|
||||
sdk: ">=3.0.0 <4.0.0"
|
||||
flutter: "3.10.1"
|
||||
flutter: "3.10.5"
|
||||
|
||||
dependencies:
|
||||
adaptive_theme: ^3.2.0
|
||||
@ -58,6 +58,8 @@ dependencies:
|
||||
git:
|
||||
url: https://github.com/livinglist/flutter_pulltorefresh
|
||||
ref: master
|
||||
qr_code_scanner: ^1.0.1
|
||||
qr_flutter: ^4.1.0
|
||||
receive_sharing_intent: ^1.4.5
|
||||
responsive_builder: ^0.7.0
|
||||
rxdart: ^0.27.7
|
||||
|