Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ app.*.map.json
/android/app/profile
/android/app/release
/android/build/reports
/android/gradle/local.properties
/android/.kotlin/
/android/app/.cxx/
/android/app/build/
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ android {
buildTypes {
release {
signingConfig signingConfigs.release

minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-dontwarn androidx.window.extensions.WindowExtensions
-dontwarn androidx.window.extensions.WindowExtensionsProvider
-dontwarn androidx.window.extensions.area.ExtensionWindowAreaPresentation
-dontwarn androidx.window.extensions.layout.DisplayFeature
-dontwarn androidx.window.extensions.layout.FoldingFeature
-dontwarn androidx.window.extensions.layout.WindowLayoutComponent
-dontwarn androidx.window.extensions.layout.WindowLayoutInfo
-dontwarn androidx.window.sidecar.SidecarDeviceState
-dontwarn androidx.window.sidecar.SidecarDisplayFeature
-dontwarn androidx.window.sidecar.SidecarInterface$SidecarCallback
-dontwarn androidx.window.sidecar.SidecarInterface
-dontwarn androidx.window.sidecar.SidecarProvider
-dontwarn androidx.window.sidecar.SidecarWindowLayoutInfo
13 changes: 12 additions & 1 deletion lib/config/paths.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import 'package:hacki/screens/screens.dart';

abstract class Paths {
abstract final class Paths {
static const LogsPaths logs = LogsPaths._();
static const HomePaths home = HomePaths._();
static const ItemPaths item = ItemPaths._();
static const SharePaths share = SharePaths._();
static const QrCodePaths qrCode = QrCodePaths._();
static const WebViewPaths webView = WebViewPaths._();
static const SettingsPaths settings = SettingsPaths._();
}

class HomePaths with RootPaths {
Expand All @@ -21,6 +22,16 @@ class ItemPaths with RootPaths {
String get landing => rootPath(ItemScreen.routeName);

String get submit => rootPath(SubmitScreen.routeName);

String get settings => '$landing$settingsSegment';

static const String settingsSegment = '/${SettingsScreen.routeName}';
}

class SettingsPaths with RootPaths {
const SettingsPaths._();

String get landing => rootPath(SettingsScreen.routeName);
}

class SharePaths with RootPaths {
Expand Down
6 changes: 6 additions & 0 deletions lib/config/custom_router.dart → lib/config/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ final GoRouter router = GoRouter(
}
return ItemScreen.phone(args);
},
routes: <RouteBase>[
GoRoute(
path: SettingsScreen.routeName,
builder: (_, __) => const SettingsScreen(),
),
],
),
GoRoute(
path: '${ItemScreen.routeName}/:itemId',
Expand Down
4 changes: 2 additions & 2 deletions lib/cubits/comments/comments_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import 'package:equatable/equatable.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:hacki/config/constants.dart';
import 'package:hacki/config/custom_router.dart';
import 'package:hacki/config/locator.dart';
import 'package:hacki/config/paths.dart';
import 'package:hacki/config/router.dart';
import 'package:hacki/cubits/cubits.dart';
import 'package:hacki/extensions/extensions.dart';
import 'package:hacki/models/models.dart';
Expand Down Expand Up @@ -879,7 +879,7 @@ comments length is ${state.comments.length}
}
}

await Future<void>.delayed(AppDurations.ms400, () {
await Future<void>.delayed(AppDurations.ms300, () {
final BuildContext? newTargetCommentContext =
targetCommentGlobalKey?.currentContext;
if (targetCommentGlobalKey != null &&
Expand Down
34 changes: 2 additions & 32 deletions lib/extensions/widget_extension.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hacki/config/constants.dart';
import 'package:hacki/cubits/cubits.dart';
import 'package:hacki/models/models.dart';
import 'package:hacki/screens/search/search_screen.dart';
import 'package:hacki/screens/widgets/custom_linkify/custom_linkify.dart';
import 'package:hacki/services/dialog_proxy.dart';
import 'package:hacki/styles/styles.dart';
import 'package:hacki/utils/utils.dart';

Expand Down Expand Up @@ -37,7 +35,7 @@ extension ContextMenuBuilder on Widget {
..insert(
0,
ContextMenuButtonItem(
onPressed: () => _showHackerNewsSearchBottomSheet(
onPressed: () => DialogProxy.showHackerNewsSearchBottomSheet(
context,
selectedText,
),
Expand Down Expand Up @@ -67,34 +65,6 @@ extension ContextMenuBuilder on Widget {
buttonItems: items,
);
}

void _showHackerNewsSearchBottomSheet(
BuildContext context,
String text,
) {
showModalBottomSheet<void>(
context: context,
isScrollControlled: true,
showDragHandle: true,
builder: (BuildContext context) {
return BlocProvider<SearchCubit>(
create: (_) => SearchCubit()..search(text),
child: SizedBox(
height: MediaQuery.of(context).size.height - Dimens.pt120,
child: const Column(
children: <Widget>[
Expanded(
child: SearchScreen(
isInBottomSheet: true,
),
),
],
),
),
);
},
);
}
}

extension WidgetModifier on Widget {
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:hacki/blocs/blocs.dart';
import 'package:hacki/config/constants.dart';
import 'package:hacki/config/custom_router.dart';
import 'package:hacki/config/locator.dart';
import 'package:hacki/config/paths.dart';
import 'package:hacki/config/router.dart';
import 'package:hacki/cubits/cubits.dart';
import 'package:hacki/screens/widgets/widgets.dart';
import 'package:hacki/services/fetcher.dart';
Expand Down
8 changes: 4 additions & 4 deletions lib/models/discoverable_feature.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ enum DiscoverableFeature {
title: 'Fav a Story',
description: '''Add it to your favorites.''',
),
openStoryInWebView(
featureId: 'open_story_in_web_view',
title: 'Open in Browser',
description: '''You can tap here to open this story in browser.''',
settingsShortcutOnItemScreen(
featureId: 'settings_shortcut_on_item_screen',
title: 'Go to Settings',
description: '''You can now go to settings page directly from a thread.''',
),
login(
featureId: 'log_in',
Expand Down
2 changes: 1 addition & 1 deletion lib/models/preference.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:collection/collection.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_material_color_picker/flutter_material_color_picker.dart';
import 'package:hacki/config/custom_router.dart';
import 'package:hacki/config/router.dart';
import 'package:hacki/models/models.dart';
import 'package:hacki/styles/palette.dart';
import 'package:responsive_builder/responsive_builder.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/home/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ class _HomeScreenState extends State<HomeScreen>
FeatureDiscovery.clearPreferences(context, <String>[
DiscoverableFeature.login.featureId,
DiscoverableFeature.addStoryToFavList.featureId,
DiscoverableFeature.openStoryInWebView.featureId,
DiscoverableFeature.settingsShortcutOnItemScreen.featureId,
DiscoverableFeature.pinToTop.featureId,
]);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/item/item_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class _ItemScreenState extends State<ItemScreen>
DiscoverableFeature.searchInThread.featureId,
DiscoverableFeature.pinToTop.featureId,
DiscoverableFeature.addStoryToFavList.featureId,
DiscoverableFeature.openStoryInWebView.featureId,
DiscoverableFeature.settingsShortcutOnItemScreen.featureId,
DiscoverableFeature.jumpUpButton.featureId,
DiscoverableFeature.jumpDownButton.featureId,
},
Expand Down
4 changes: 1 addition & 3 deletions lib/screens/item/widgets/custom_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ class CustomAppBar extends AppBar {
FavIconButton(
storyId: item.id,
),
LinkIconButton(
storyId: item.id,
),
const SettingsButton(),
],
);
}
39 changes: 0 additions & 39 deletions lib/screens/item/widgets/link_icon_button.dart

This file was deleted.

1 change: 1 addition & 0 deletions lib/screens/item/widgets/main_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class MainView extends StatelessWidget {
context.read<CommentsCubit>().itemPositionsListener,
itemCount: state.comments.length + 2,
scrollOffsetListener: scrollOffsetListener,
minCacheExtent: WidgetUtils.calculateCacheExtent(context),
itemBuilder: (BuildContext context, int index) {
if (index == 0) {
return Material(
Expand Down
55 changes: 55 additions & 0 deletions lib/screens/item/widgets/settings_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import 'package:feature_discovery/feature_discovery.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:hacki/config/paths.dart';
import 'package:hacki/config/router.dart';
import 'package:hacki/models/discoverable_feature.dart';
import 'package:hacki/screens/widgets/widgets.dart';
import 'package:hacki/services/services.dart';
import 'package:responsive_builder/responsive_builder.dart';

class SettingsButton extends StatelessWidget {
const SettingsButton({
super.key,
});

static DeviceScreenType? _cachedDeviceType;

@override
Widget build(BuildContext context) {
return IconButton(
tooltip: 'Go to settings',
icon: CustomDescribedFeatureOverlay(
tapTarget: Icon(
Icons.settings,
color: Theme.of(context).colorScheme.onPrimaryContainer,
),
feature: DiscoverableFeature.settingsShortcutOnItemScreen,
contentLocation: ContentLocation.below,
child: Icon(
Icons.settings,
color: Theme.of(context).colorScheme.onSurface,
),
),
onPressed: () {
_cachedDeviceType ??= () {
final BuildContext? context = navigatorKey.currentContext;
if (context != null) {
final Size size = MediaQuery.of(context).size;
final DeviceScreenType type = getDeviceType(size);
return type;
}
return DeviceScreenType.mobile;
}();
final DeviceScreenType deviceType = _cachedDeviceType!;

if (deviceType == DeviceScreenType.mobile) {
context.push(Paths.item.settings);
return;
} else {
DialogProxy.showSettingsBottomSheet(context);
}
},
);
}
}
2 changes: 1 addition & 1 deletion lib/screens/item/widgets/widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ export 'fav_icon_button.dart';
export 'in_thread_search_icon_button.dart';
export 'item_screen_background.dart';
export 'lazy_fetch_load_button.dart';
export 'link_icon_button.dart';
export 'login_dialog.dart';
export 'main_view.dart';
export 'more_popup_menu.dart';
export 'pin_icon_button.dart';
export 'poll_view.dart';
export 'reply_box.dart';
export 'settings_button.dart';
export 'time_machine_dialog.dart';
14 changes: 11 additions & 3 deletions lib/screens/profile/profile_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,17 @@ class _ProfileScreenState extends State<ProfileScreen>
),
),
),
Settings(
authState: authState,
pageType: pageType,
Visibility(
visible: pageType == PageType.settings,
child: Positioned.fill(
top: context
.read<PreferenceCubit>()
.state
.isHackerNewsThemeEnabled
? Dimens.pt64
: Dimens.pt50,
child: const SettingsView(),
),
),
Align(
alignment: Alignment.topLeft,
Expand Down
5 changes: 0 additions & 5 deletions lib/screens/profile/widgets/widgets.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
export 'centered_message_view.dart';
export 'enter_offline_mode_list_tile.dart';
export 'favorites_screen.dart';
export 'inbox_view.dart';
export 'offline_list_tile.dart';
export 'settings.dart';
export 'tab_bar_settings.dart';
export 'text_scale_factor_settings.dart';
1 change: 1 addition & 0 deletions lib/screens/screens.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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 'settings/settings_screen.dart';
export 'share/share_screen.dart';
export 'submit/submit_screen.dart';
export 'web_view/web_view_screen.dart';
Loading