Skip to content

Commit

Permalink
Merge pull request #1 from ous50/main
Browse files Browse the repository at this point in the history
feat: alternative implementation to conversation sharing
  • Loading branch information
PeronGH authored Jan 9, 2024
2 parents b9594fd + 9b61a24 commit bdac4b0
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 48 deletions.
4 changes: 3 additions & 1 deletion lib/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ class Controller extends GetxController {
try {
final id = await shareGptService.uploadConversation(messages);
final url = 'https://shareg.pt/$id';
await Get.dialog(ShareConversationDialog(shareGptUrl: url));
await Get.dialog(ShareConversationDialog(
sharegptUrl: url,
));
} catch (e) {
Get.snackbar('Error occurred', 'Failed to share conversation: $e');
}
Expand Down
56 changes: 41 additions & 15 deletions lib/widgets/share_conversation_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,28 +1,54 @@
import 'package:flutter/material.dart';
import 'package:sydney_webui/utils/copy.dart';
import 'package:flutter/services.dart';
import 'package:sydney_webui/utils/url.dart';
import 'package:share_plus/share_plus.dart';

class ShareConversationDialog extends StatelessWidget {
final String shareGptUrl;
final String sharegptUrl;

const ShareConversationDialog({Key? key, required this.shareGptUrl})
: super(key: key);
const ShareConversationDialog({super.key, required this.sharegptUrl});

@override
Widget build(BuildContext context) {
return AlertDialog(
title: const Text("ShareGPT URL"),
content: SelectableText(shareGptUrl),
title: const Text('Share Conversation'),
content: Text(sharegptUrl),
actions: [
IconButton(
icon: const Icon(Icons.copy_rounded),
onPressed: () => copyContent(shareGptUrl),
tooltip: "Copy URL",
),
IconButton(
icon: const Icon(Icons.open_in_browser_rounded),
onPressed: () => openUrl(shareGptUrl),
tooltip: "Open URL",
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
ElevatedButton(
onPressed: () {
Clipboard.setData(ClipboardData(text: sharegptUrl));
},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [Icon(Icons.copy_rounded), Text('Copy')],
)),
const SizedBox(width: 8),
ElevatedButton(
onPressed: () {
openUrl(sharegptUrl);
},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.open_in_browser_rounded),
Text('Open')
],
)),
const SizedBox(width: 8),
ElevatedButton(
onPressed: () {
Share.share(sharegptUrl);
},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [Icon(Icons.share_rounded), Text('Share')],
))
],
),
)
],
);
Expand Down
150 changes: 119 additions & 31 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ packages:
dependency: transitive
description:
name: archive
sha256: "7b875fd4a20b165a3084bd2d210439b22ebc653f21cea4842729c0c30c82596b"
sha256: "22600aa1e926be775fa5fe7e6894e7fb3df9efda8891c73f70fb3262399a432d"
url: "https://pub.dev"
source: hosted
version: "3.4.9"
version: "3.4.10"
args:
dependency: transitive
description:
Expand Down Expand Up @@ -65,6 +65,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.1"
cross_file:
dependency: transitive
description:
name: cross_file
sha256: fedaadfa3a6996f75211d835aaeb8fede285dae94262485698afd832371b9a5e
url: "https://pub.dev"
source: hosted
version: "0.3.3+8"
crypto:
dependency: transitive
description:
Expand All @@ -89,6 +97,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.0"
file:
dependency: transitive
description:
name: file
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
file_picker:
dependency: "direct main"
description:
Expand All @@ -114,26 +130,26 @@ packages:
dependency: "direct dev"
description:
name: flutter_lints
sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7
url: "https://pub.dev"
source: hosted
version: "2.0.3"
version: "3.0.1"
flutter_markdown:
dependency: "direct main"
description:
name: flutter_markdown
sha256: "35108526a233cc0755664d445f8a6b4b61e6f8fe993b3658b80b4a26827fc196"
sha256: "30088ce826b5b9cfbf9e8bece34c716c8a59fa54461dcae1e4ac01a94639e762"
url: "https://pub.dev"
source: hosted
version: "0.6.18+2"
version: "0.6.18+3"
flutter_markdown_latex:
dependency: "direct main"
description:
name: flutter_markdown_latex
sha256: fff914d779c9b30b8b261b4c087bb08b3962ac024e4c6a0a5613b5c12c17725a
sha256: "87ccd52eb0ec39286205a9f355cd0b667e5551531e53fd5b85dd2bfabbe58630"
url: "https://pub.dev"
source: hosted
version: "0.1.3"
version: "0.1.4"
flutter_math_fork:
dependency: transitive
description:
Expand Down Expand Up @@ -236,10 +252,10 @@ packages:
dependency: transitive
description:
name: lints
sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "3.0.0"
markdown:
dependency: "direct main"
description:
Expand Down Expand Up @@ -272,6 +288,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.10.0"
mime:
dependency: transitive
description:
name: mime
sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e
url: "https://pub.dev"
source: hosted
version: "1.0.4"
nested:
dependency: transitive
description:
Expand Down Expand Up @@ -308,18 +332,18 @@ packages:
dependency: transitive
description:
name: path_provider
sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa
sha256: b27217933eeeba8ff24845c34003b003b2b22151de3c908d0e679e8fe1aa078b
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
sha256: e595b98692943b4881b219f0a9e3945118d3c16bd7e2813f98ec6e532d905f72
sha256: "477184d672607c0a3bf68fbbf601805f92ef79c82b64b4d6eb318cbca4c48668"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
version: "2.2.2"
path_provider_foundation:
dependency: transitive
description:
Expand All @@ -340,10 +364,10 @@ packages:
dependency: transitive
description:
name: path_provider_platform_interface
sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c"
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
path_provider_windows:
dependency: transitive
description:
Expand All @@ -364,18 +388,18 @@ packages:
dependency: transitive
description:
name: platform
sha256: "0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59"
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
url: "https://pub.dev"
source: hosted
version: "3.1.3"
version: "3.1.4"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev"
source: hosted
version: "2.1.7"
version: "2.1.8"
pointycastle:
dependency: transitive
description:
Expand All @@ -392,6 +416,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.1.1"
share_plus:
dependency: "direct main"
description:
name: share_plus
sha256: f74fc3f1cbd99f39760182e176802f693fa0ec9625c045561cfad54681ea93dd
url: "https://pub.dev"
source: hosted
version: "7.2.1"
share_plus_platform_interface:
dependency: transitive
description:
name: share_plus_platform_interface
sha256: df08bc3a07d01f5ea47b45d03ffcba1fa9cd5370fb44b3f38c70e42cced0f956
url: "https://pub.dev"
source: hosted
version: "3.3.1"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -405,6 +445,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.10.0"
sprintf:
dependency: transitive
description:
name: sprintf
sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -461,30 +509,70 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.2"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
sha256: ab360eb661f8879369acac07b6bb3ff09d9471155357da8443fd5d3cf7363811
url: "https://pub.dev"
source: hosted
version: "3.1.1"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
sha256: a932c3a8082e118f80a475ce692fde89dc20fddb24c57360b96bc56f7035de1f
url: "https://pub.dev"
source: hosted
version: "2.3.1"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
sha256: fff0932192afeedf63cdd50ecbb1bc825d31aed259f02bb8dba0f3b729a5e88b
url: "https://pub.dev"
source: hosted
version: "2.2.3"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
sha256: ecf9725510600aa2bb6d7ddabe16357691b6d2805f66216a97d1b881e21beff7
url: "https://pub.dev"
source: hosted
version: "3.1.1"
uuid:
dependency: transitive
description:
name: uuid
sha256: "22c94e5ad1e75f9934b766b53c742572ee2677c56bc871d850a57dad0f82127f"
url: "https://pub.dev"
source: hosted
version: "4.2.2"
vector_graphics:
dependency: transitive
description:
name: vector_graphics
sha256: "0f0c746dd2d6254a0057218ff980fc7f5670fd0fcf5e4db38a490d31eed4ad43"
sha256: "18f6690295af52d081f6808f2f7c69f0eed6d7e23a71539d75f4aeb8f0062172"
url: "https://pub.dev"
source: hosted
version: "1.1.9+1"
version: "1.1.9+2"
vector_graphics_codec:
dependency: transitive
description:
name: vector_graphics_codec
sha256: "0edf6d630d1bfd5589114138ed8fada3234deacc37966bec033d3047c29248b7"
sha256: "531d20465c10dfac7f5cd90b60bbe4dd9921f1ec4ca54c83ebb176dbacb7bb2d"
url: "https://pub.dev"
source: hosted
version: "1.1.9+1"
version: "1.1.9+2"
vector_graphics_compiler:
dependency: transitive
description:
name: vector_graphics_compiler
sha256: d24333727332d9bd20990f1483af4e09abdb9b1fc7c3db940b56ab5c42790c26
sha256: "03012b0a33775c5530576b70240308080e1d5050f0faf000118c20e6463bc0ad"
url: "https://pub.dev"
source: hosted
version: "1.1.9+1"
version: "1.1.9+2"
vector_math:
dependency: transitive
description:
Expand All @@ -505,18 +593,18 @@ packages:
dependency: transitive
description:
name: win32
sha256: b0f37db61ba2f2e9b7a78a1caece0052564d1bc70668156cf3a29d676fe4e574
sha256: "464f5674532865248444b4c3daca12bd9bf2d7c47f759ce2617986e7229494a8"
url: "https://pub.dev"
source: hosted
version: "5.1.1"
version: "5.2.0"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
sha256: "589ada45ba9e39405c198fe34eb0f607cddb2108527e658136120892beac46d2"
sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d
url: "https://pub.dev"
source: hosted
version: "1.0.3"
version: "1.0.4"
xml:
dependency: transitive
description:
Expand All @@ -527,4 +615,4 @@ packages:
version: "6.5.0"
sdks:
dart: ">=3.2.3 <4.0.0"
flutter: ">=3.13.0"
flutter: ">=3.16.0"
Loading

0 comments on commit bdac4b0

Please sign in to comment.