Skip to content

Feature add device preview for demo mode #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 10, 2025
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
24 changes: 11 additions & 13 deletions lib/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import 'package:ht_main/shared/localization/en_timeago_messages.dart';
import 'package:ht_shared/ht_shared.dart';
import 'package:timeago/timeago.dart' as timeago;

Future<void> bootstrap(app_config.AppConfig appConfig) async {
Future<Widget> bootstrap(app_config.AppConfig appConfig) async {
WidgetsFlutterBinding.ensureInitialized();
Bloc.observer = const AppBlocObserver();

Expand Down Expand Up @@ -205,17 +205,15 @@ Future<void> bootstrap(app_config.AppConfig appConfig) async {
dataClient: appConfigClient,
);

runApp(
App(
htAuthenticationRepository: authenticationRepository,
htHeadlinesRepository: headlinesRepository,
htCategoriesRepository: categoriesRepository,
htCountriesRepository: countriesRepository,
htSourcesRepository: sourcesRepository,
htUserAppSettingsRepository: userAppSettingsRepository,
htUserContentPreferencesRepository: userContentPreferencesRepository,
htAppConfigRepository: appConfigRepository,
kvStorageService: kvStorage,
),
return App(
htAuthenticationRepository: authenticationRepository,
htHeadlinesRepository: headlinesRepository,
htCategoriesRepository: categoriesRepository,
htCountriesRepository: countriesRepository,
htSourcesRepository: sourcesRepository,
htUserAppSettingsRepository: userAppSettingsRepository,
htUserContentPreferencesRepository: userContentPreferencesRepository,
htAppConfigRepository: appConfigRepository,
kvStorageService: kvStorage,
);
}
19 changes: 18 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:device_preview/device_preview.dart';
import 'package:ht_main/app/config/config.dart';
import 'package:ht_main/bootstrap.dart';

Expand All @@ -12,5 +15,19 @@ void main() async {
AppEnvironment.development => AppConfig.development(),
AppEnvironment.demo => AppConfig.demo(),
};
await bootstrap(appConfig);

final appWidget = await bootstrap(appConfig);

if (appConfig.environment == AppEnvironment.demo) {
runApp(
DevicePreview(
enabled: !kReleaseMode,
builder: (context) => appWidget,
tools: const [DeviceSection()],

),
);
} else {
runApp(appWidget);
}
}
24 changes: 24 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.2"
device_frame:
dependency: transitive
description:
name: device_frame
sha256: d031a06f5d6f4750009672db98a5aa1536aa4a231713852469ce394779a23d75
url: "https://pub.dev"
source: hosted
version: "1.2.0"
device_preview:
dependency: "direct main"
description:
name: device_preview
sha256: a694acdd3894b4c7d600f4ee413afc4ff917f76026b97ab06575fe886429ef19
url: "https://pub.dev"
source: hosted
version: "1.2.0"
diff_match_patch:
dependency: transitive
description:
Expand Down Expand Up @@ -277,6 +293,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
freezed_annotation:
dependency: transitive
description:
name: freezed_annotation
sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2
url: "https://pub.dev"
source: hosted
version: "2.4.4"
frontend_server_client:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ environment:
dependencies:
bloc: ^9.0.0
bloc_concurrency: ^0.3.0
device_preview: ^1.2.0
equatable: ^2.0.7
flex_color_scheme: ^8.1.1
flutter:
Expand Down
Loading