Skip to content

Commit c000cee

Browse files
Fix opening links in feedback chat (#1937)
You couldn't open the links sent in the feedback chat. --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 72ec913 commit c000cee

4 files changed

Lines changed: 35 additions & 3 deletions

File tree

console/lib/main.dart

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@ import 'package:feedback_shared_implementation/feedback_shared_implementation.da
1111
import 'package:firebase_auth/firebase_auth.dart';
1212
import 'package:firebase_core/firebase_core.dart';
1313
import 'package:flutter/material.dart';
14+
import 'package:key_value_store/key_value_store.dart';
1415
import 'package:provider/provider.dart';
1516
import 'package:provider/single_child_widget.dart';
17+
import 'package:shared_preferences/shared_preferences.dart';
1618
import 'package:sharezone_console/firebase_options_dev.g.dart' as dev;
1719
import 'package:sharezone_console/firebase_options_prod.g.dart' as prod;
1820
import 'package:sharezone_console/flavor.dart';
1921
import 'package:sharezone_console/login_signup_page.dart';
2022
import 'package:sharezone_console/pages/feedbacks/feedbacks_page.dart';
2123
import 'package:sharezone_widgets/sharezone_widgets.dart';
24+
import 'package:sharezone_localizations/sharezone_localizations.dart';
2225

2326
import 'home_page.dart';
2427

@@ -28,7 +31,8 @@ Future<void> main() async {
2831
final flavor = Flavor.fromEnvironment();
2932
await _initFirebase(flavor);
3033

31-
runApp(MyApp());
34+
final sharedPreferences = await SharedPreferences.getInstance();
35+
runApp(MyApp(sharedPreferences: sharedPreferences));
3236
}
3337

3438
Future<void> _initFirebase(Flavor flavor) async {
@@ -41,7 +45,9 @@ Future<void> _initFirebase(Flavor flavor) async {
4145
}
4246

4347
class MyApp extends StatefulWidget {
44-
const MyApp({Key? key}) : super(key: key);
48+
const MyApp({Key? key, required this.sharedPreferences}) : super(key: key);
49+
50+
final SharedPreferences sharedPreferences;
4551

4652
@override
4753
State<MyApp> createState() => _MyAppState();
@@ -56,6 +62,9 @@ class _MyAppState extends State<MyApp> {
5662

5763
final feedbackApi = FirebaseFeedbackApi(FirebaseFirestore.instance);
5864
providers = [
65+
Provider<KeyValueStore>.value(
66+
value: FlutterKeyValueStore(widget.sharedPreferences),
67+
),
5968
Provider<FeedbackApi>.value(value: feedbackApi),
6069
Provider(
6170
create:
@@ -77,6 +86,8 @@ class _MyAppState extends State<MyApp> {
7786
debugShowCheckedModeBanner: false,
7887
title: 'Sharezone Console',
7988
theme: getLightTheme(fontFamily: roboto),
89+
localizationsDelegates: SharezoneLocalizations.localizationsDelegates,
90+
supportedLocales: SharezoneLocalizations.supportedLocales,
8091
home: StreamBuilder(
8192
stream: auth.authStateChanges(),
8293
builder: (context, snapshot) {

console/pubspec.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ dependencies:
3333
path: ../lib/common_domain_models
3434
sharezone_widgets:
3535
path: ../lib/sharezone_widgets
36+
sharezone_localizations:
37+
path: ../lib/sharezone_localizations
38+
key_value_store:
39+
path: ../lib/key_value_store
40+
shared_preferences: ^2.5.2
3641

3742
dev_dependencies:
3843
flutter_test:

lib/feedback_shared_implementation/lib/src/pages/feedback_details_page.dart

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import 'package:feedback_shared_implementation/src/pages/feedback_view.dart';
1515
import 'package:flutter/material.dart';
1616
import 'package:flutter/services.dart';
1717
import 'package:flutter_markdown/flutter_markdown.dart';
18+
import 'package:key_value_store/key_value_store.dart';
1819
import 'package:provider/provider.dart';
1920
import 'package:sharezone_localizations/sharezone_localizations.dart';
2021
import 'package:sharezone_widgets/sharezone_widgets.dart';
@@ -511,7 +512,18 @@ class _ChatBubble extends StatelessWidget {
511512
? CrossAxisAlignment.end
512513
: CrossAxisAlignment.start,
513514
children: [
514-
MarkdownBody(data: text, selectable: true, softLineBreak: true),
515+
MarkdownBody(
516+
data: text,
517+
selectable: true,
518+
softLineBreak: true,
519+
onTapLink:
520+
(text, href, _) => launchMarkdownLinkWithWarning(
521+
href: href ?? text,
522+
text: text,
523+
keyValueStore: context.read<KeyValueStore>(),
524+
context: context,
525+
),
526+
),
515527
const SizedBox(height: 4),
516528
Text(
517529
sentAt,

lib/feedback_shared_implementation/pubspec.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,15 @@ dependencies:
3636
path: ../cloud_firestore_helper
3737
sharezone_localizations:
3838
path: ../sharezone_localizations
39+
key_value_store:
40+
path: ../key_value_store
3941
flutter_markdown:
4042
git:
4143
url: https://github.com/SharezoneApp/packages
4244
path: packages/flutter_markdown
4345
ref: 2f680bb80119f6fd037a7bda0984bc811b5dccb8
46+
url_launcher_extended:
47+
path: ../url_launcher_extended
4448

4549
dev_dependencies:
4650
build_runner: ^2.4.14

0 commit comments

Comments
 (0)