added landing page
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:bang_navigator/features/search_browser/domain/providers.dart';
|
||||
import 'package:bang_navigator/features/search_browser/domain/services/create_tab.dart';
|
||||
import 'package:bang_navigator/features/search_browser/domain/services/session.dart';
|
||||
import 'package:bang_navigator/features/search_browser/presentation/widgets/app_bar_title.dart';
|
||||
import 'package:bang_navigator/features/search_browser/presentation/widgets/landing/content.dart';
|
||||
import 'package:bang_navigator/features/search_browser/presentation/widgets/sheets/shared_content_sheet.dart';
|
||||
import 'package:bang_navigator/features/search_browser/presentation/widgets/sheets/view_tabs_sheet.dart';
|
||||
import 'package:bang_navigator/features/search_browser/presentation/widgets/tabs_action_button.dart';
|
||||
@@ -306,10 +307,11 @@ class KagiScreen extends HookConsumerWidget {
|
||||
),
|
||||
index: (activeWebView != null)
|
||||
? webViews.keys
|
||||
.toList()
|
||||
.indexOf(activeWebView.page.value.key)
|
||||
: null,
|
||||
children: webViews.values.toList(),
|
||||
.toList()
|
||||
.indexOf(activeWebView.page.value.key) +
|
||||
1
|
||||
: 0,
|
||||
children: [const LandingContent(), ...webViews.values],
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
import 'package:bang_navigator/core/routing/routes.dart';
|
||||
import 'package:bang_navigator/features/search_browser/domain/entities/modes.dart';
|
||||
import 'package:bang_navigator/features/search_browser/domain/entities/sheet.dart';
|
||||
import 'package:bang_navigator/features/search_browser/domain/services/create_tab.dart';
|
||||
import 'package:bang_navigator/features/settings/data/repositories/settings_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
import 'package:flutter_material_design_icons/flutter_material_design_icons.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
class LandingAction extends HookConsumerWidget {
|
||||
const LandingAction({super.key});
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
final sessionTokenAvailable = ref.watch(
|
||||
settingsRepositoryProvider.select(
|
||||
(value) => value.valueOrNull?.kagiSession?.isNotEmpty ?? false,
|
||||
),
|
||||
);
|
||||
|
||||
return Visibility(
|
||||
visible: sessionTokenAvailable,
|
||||
replacement: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.errorContainer,
|
||||
borderRadius: BorderRadius.circular(4.0),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Icon(
|
||||
Icons.warning,
|
||||
size: 36,
|
||||
color: theme.colorScheme.onErrorContainer,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Markdown(
|
||||
shrinkWrap: true,
|
||||
onTapLink: (text, href, title) async {
|
||||
if (href == 'settings') {
|
||||
await context.push(SettingsRoute().location);
|
||||
}
|
||||
},
|
||||
data: '## No Kagi Session Provided\n'
|
||||
'Please navigate to [Settings](settings) and enter your Kagi Session Token.\n'
|
||||
"You must provide a valid session in order to use Kagi's features.",
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: Wrap(
|
||||
spacing: 8.0,
|
||||
alignment: WrapAlignment.spaceEvenly,
|
||||
children: [
|
||||
OutlinedButton.icon(
|
||||
onPressed: () {
|
||||
ref.read(createTabStreamProvider.notifier).createTab(
|
||||
CreateTab(preferredTool: KagiTool.search),
|
||||
);
|
||||
},
|
||||
icon: const Icon(MdiIcons.searchWeb),
|
||||
label: const Text('Search'),
|
||||
),
|
||||
OutlinedButton.icon(
|
||||
onPressed: () {
|
||||
ref.read(createTabStreamProvider.notifier).createTab(
|
||||
CreateTab(preferredTool: KagiTool.assistant),
|
||||
);
|
||||
},
|
||||
icon: const Icon(MdiIcons.brain),
|
||||
label: const Text('Assistant'),
|
||||
),
|
||||
OutlinedButton.icon(
|
||||
onPressed: () {
|
||||
ref.read(createTabStreamProvider.notifier).createTab(
|
||||
CreateTab(preferredTool: KagiTool.summarizer),
|
||||
);
|
||||
},
|
||||
icon: const Icon(MdiIcons.text),
|
||||
label: const Text('Summarizer'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import 'package:bang_navigator/features/search_browser/presentation/widgets/landing/action.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart' show rootBundle;
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
class LandingContent extends HookConsumerWidget {
|
||||
const LandingContent({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final textTheme = Theme.of(context).textTheme;
|
||||
|
||||
// ignore: discarded_futures
|
||||
final descriptionAssetFuture = useMemoized(
|
||||
() async => rootBundle.loadString('assets/landing/description.md'),
|
||||
);
|
||||
final descriptionAsset = useFuture(descriptionAssetFuture);
|
||||
|
||||
// ignore: discarded_futures
|
||||
final changelogAssetFuture = useMemoized(
|
||||
() async => rootBundle.loadString('assets/landing/changelog.md'),
|
||||
);
|
||||
final changelogAsset = useFuture(changelogAssetFuture);
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
'BangNavigator',
|
||||
style: textTheme.titleLarge?.copyWith(fontWeight: FontWeight.bold),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Text(
|
||||
'A Privacy-Focused Browser for Kagi',
|
||||
style: textTheme.titleMedium,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
FractionallySizedBox(
|
||||
widthFactor: 0.5,
|
||||
child: Image.asset('assets/icon/icon.png'),
|
||||
),
|
||||
const LandingAction(),
|
||||
Markdown(
|
||||
data: descriptionAsset.data ?? '',
|
||||
selectable: true,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
),
|
||||
Text(
|
||||
'Changelog',
|
||||
style: textTheme.titleLarge?.copyWith(fontWeight: FontWeight.bold),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Markdown(
|
||||
data: changelogAsset.data ?? '',
|
||||
selectable: true,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user