Compare commits
59 Commits
b70d3795d1
...
1.2.1+2
| Author | SHA1 | Date | |
|---|---|---|---|
| 19eabfaba1 | |||
| ec2eadad6d | |||
| 54e176e75d | |||
| 0a7ccaeefa | |||
| a5f093e185 | |||
| a4f68dd175 | |||
| 8067c35c70 | |||
| ebe381053e | |||
| 03f2470dae | |||
| ea434815cf | |||
| bbea4b4359 | |||
| e0b485cc81 | |||
| 87bb37ac01 | |||
| 989b5babd9 | |||
| 9ea364640d | |||
| a9f55a489d | |||
| 4616f3a3e2 | |||
| 425bae9d13 | |||
| 07771e8979 | |||
| 0ad4854443 | |||
| 4238ea6fdc | |||
| 7d45c06302 | |||
| 7e8993fbd2 | |||
| c88fcc84da | |||
| 11fb79623e | |||
| 98cc313a91 | |||
| bc3401a897 | |||
| 5b6a5d9046 | |||
| 6cbd78e836 | |||
| aefcbad02f | |||
| 70617be687 | |||
| cccb3d5c16 | |||
| a0a3a8d182 | |||
| c6b2ef8459 | |||
| 34a2fe3988 | |||
| 0a5604d0ff | |||
| 5e754ad233 | |||
| 5b9c92e4d3 | |||
| b2a6ca7244 | |||
| 27c60fc8cb | |||
| 8b3c45ab29 | |||
| adb415700a | |||
| 1e4b44a78b | |||
| 9765b200b9 | |||
| 47d03ce1e5 | |||
| c41a71388d | |||
| 7655dfdf37 | |||
| 190bb34958 | |||
| d02ed68afa | |||
| 2bc4513bb6 | |||
| f10393f6d0 | |||
| ecef8dab0c | |||
| 52e58fce3d | |||
| 31d50bfb1f | |||
| ca8ad12d93 | |||
| f799900450 | |||
| dfdf7b23c8 | |||
| 771b2029b0 | |||
| cc9c99f375 |
2
.github/workflows/nightly.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
channel: stable
|
||||
cache: true
|
||||
- run: flutter pub get
|
||||
- run: flutter build web
|
||||
- run: flutter build web --release --base-href=/
|
||||
- name: Archive production artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
|
||||
@@ -70,6 +70,12 @@
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.yalantis.ucrop.UCropActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
|
||||
|
||||
<!-- Don't delete the meta-data below.
|
||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||
<meta-data
|
||||
|
||||
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 24 KiB |
BIN
assets/fonts/Comfortaa-Bold.ttf
Executable file
BIN
assets/fonts/Comfortaa-Regular.ttf
Executable file
BIN
assets/fonts/NotoColorEmoji-Regular.ttf
Executable file
BIN
assets/fonts/NotoSansHK-Bold.ttf
Executable file
BIN
assets/fonts/NotoSansHK-Regular.ttf
Executable file
BIN
assets/fonts/NotoSansJP-Bold.ttf
Executable file
BIN
assets/fonts/NotoSansJP-Regular.ttf
Executable file
BIN
assets/fonts/NotoSansSC-Bold.ttf
Executable file
BIN
assets/fonts/NotoSansSC-Regular.ttf
Executable file
|
Before Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 166 KiB After Width: | Height: | Size: 406 KiB |
BIN
assets/icon.png
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 360 KiB |
BIN
assets/logo.png
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 360 KiB |
@@ -1,3 +1,4 @@
|
||||
description: This file stores settings for Dart & Flutter DevTools.
|
||||
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
|
||||
extensions:
|
||||
- provider: true
|
||||
@@ -38,19 +38,19 @@ PODS:
|
||||
- file_picker (0.0.1):
|
||||
- DKImagePickerController/PhotoGallery
|
||||
- Flutter
|
||||
- Firebase/CoreOnly (10.28.0):
|
||||
- FirebaseCore (= 10.28.0)
|
||||
- Firebase/Messaging (10.28.0):
|
||||
- Firebase/CoreOnly (10.29.0):
|
||||
- FirebaseCore (= 10.29.0)
|
||||
- Firebase/Messaging (10.29.0):
|
||||
- Firebase/CoreOnly
|
||||
- FirebaseMessaging (~> 10.28.0)
|
||||
- firebase_core (3.2.0):
|
||||
- Firebase/CoreOnly (= 10.28.0)
|
||||
- FirebaseMessaging (~> 10.29.0)
|
||||
- firebase_core (3.3.0):
|
||||
- Firebase/CoreOnly (= 10.29.0)
|
||||
- Flutter
|
||||
- firebase_messaging (15.0.3):
|
||||
- Firebase/Messaging (= 10.28.0)
|
||||
- firebase_messaging (15.0.4):
|
||||
- Firebase/Messaging (= 10.29.0)
|
||||
- firebase_core
|
||||
- Flutter
|
||||
- FirebaseCore (10.28.0):
|
||||
- FirebaseCore (10.29.0):
|
||||
- FirebaseCoreInternal (~> 10.0)
|
||||
- GoogleUtilities/Environment (~> 7.12)
|
||||
- GoogleUtilities/Logger (~> 7.12)
|
||||
@@ -61,7 +61,7 @@ PODS:
|
||||
- GoogleUtilities/Environment (~> 7.8)
|
||||
- GoogleUtilities/UserDefaults (~> 7.8)
|
||||
- PromisesObjC (~> 2.1)
|
||||
- FirebaseMessaging (10.28.0):
|
||||
- FirebaseMessaging (10.29.0):
|
||||
- FirebaseCore (~> 10.0)
|
||||
- FirebaseInstallations (~> 10.0)
|
||||
- GoogleDataTransport (~> 9.3)
|
||||
@@ -76,6 +76,9 @@ PODS:
|
||||
- flutter_webrtc (0.11.3):
|
||||
- Flutter
|
||||
- WebRTC-SDK (= 125.6422.04)
|
||||
- gal (1.0.0):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
- GoogleDataTransport (9.4.1):
|
||||
- GoogleUtilities/Environment (~> 7.7)
|
||||
- nanopb (< 2.30911.0, >= 2.30908.0)
|
||||
@@ -105,9 +108,12 @@ PODS:
|
||||
- GoogleUtilities/UserDefaults (7.13.3):
|
||||
- GoogleUtilities/Logger
|
||||
- GoogleUtilities/Privacy
|
||||
- image_cropper (0.0.4):
|
||||
- Flutter
|
||||
- TOCropViewController (~> 2.7.4)
|
||||
- image_picker_ios (0.0.1):
|
||||
- Flutter
|
||||
- livekit_client (2.2.2):
|
||||
- livekit_client (2.2.3):
|
||||
- Flutter
|
||||
- WebRTC-SDK (= 125.6422.04)
|
||||
- media_kit_libs_ios_video (1.0.4):
|
||||
@@ -139,7 +145,7 @@ PODS:
|
||||
- SDWebImage/Core (= 5.19.4)
|
||||
- SDWebImage/Core (5.19.4)
|
||||
- Sentry/HybridSDK (8.32.0)
|
||||
- sentry_flutter (8.5.0):
|
||||
- sentry_flutter (8.6.0):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
- Sentry/HybridSDK (= 8.32.0)
|
||||
@@ -152,6 +158,7 @@ PODS:
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
- SwiftyGif (5.4.5)
|
||||
- TOCropViewController (2.7.4)
|
||||
- url_launcher_ios (0.0.1):
|
||||
- Flutter
|
||||
- volume_controller (0.0.1):
|
||||
@@ -169,6 +176,8 @@ DEPENDENCIES:
|
||||
- Flutter (from `Flutter`)
|
||||
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
|
||||
- flutter_webrtc (from `.symlinks/plugins/flutter_webrtc/ios`)
|
||||
- gal (from `.symlinks/plugins/gal/darwin`)
|
||||
- image_cropper (from `.symlinks/plugins/image_cropper/ios`)
|
||||
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
|
||||
- livekit_client (from `.symlinks/plugins/livekit_client/ios`)
|
||||
- media_kit_libs_ios_video (from `.symlinks/plugins/media_kit_libs_ios_video/ios`)
|
||||
@@ -204,6 +213,7 @@ SPEC REPOS:
|
||||
- SDWebImage
|
||||
- Sentry
|
||||
- SwiftyGif
|
||||
- TOCropViewController
|
||||
- WebRTC-SDK
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
@@ -223,6 +233,10 @@ EXTERNAL SOURCES:
|
||||
:path: ".symlinks/plugins/flutter_secure_storage/ios"
|
||||
flutter_webrtc:
|
||||
:path: ".symlinks/plugins/flutter_webrtc/ios"
|
||||
gal:
|
||||
:path: ".symlinks/plugins/gal/darwin"
|
||||
image_cropper:
|
||||
:path: ".symlinks/plugins/image_cropper/ios"
|
||||
image_picker_ios:
|
||||
:path: ".symlinks/plugins/image_picker_ios/ios"
|
||||
livekit_client:
|
||||
@@ -266,20 +280,22 @@ SPEC CHECKSUMS:
|
||||
DKImagePickerController: 946cec48c7873164274ecc4624d19e3da4c1ef3c
|
||||
DKPhotoGallery: b3834fecb755ee09a593d7c9e389d8b5d6deed60
|
||||
file_picker: 09aa5ec1ab24135ccd7a1621c46c84134bfd6655
|
||||
Firebase: 5121c624121af81cbc81df3bda414b3c28c4f3c3
|
||||
firebase_core: a9d0180d5285527884d07a41eb4a9ec9ed12cdb6
|
||||
firebase_messaging: ccc82a143a74de75f440a4e413dbbb37ec3fddbc
|
||||
FirebaseCore: 857dc1c6dd1255675047404d8466f7dfaac5d779
|
||||
Firebase: cec914dab6fd7b1bd8ab56ea07ce4e03dd251c2d
|
||||
firebase_core: 57aeb91680e5d5e6df6b888064be7c785f146efb
|
||||
firebase_messaging: c862b3d2b973ecc769194dc8de09bd22c77ae757
|
||||
FirebaseCore: 30e9c1cbe3d38f5f5e75f48bfcea87d7c358ec16
|
||||
FirebaseCoreInternal: df84dd300b561c27d5571684f389bf60b0a5c934
|
||||
FirebaseInstallations: 913cf60d0400ebd5d6b63a28b290372ab44590dd
|
||||
FirebaseMessaging: 087a7c7cadef7b9239f005bc4db823894844f323
|
||||
FirebaseMessaging: 7b5d8033e183ab59eb5b852a53201559e976d366
|
||||
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
|
||||
flutter_secure_storage: d33dac7ae2ea08509be337e775f6b59f1ff45f12
|
||||
flutter_webrtc: 75b868e4f9e817c7a9a42ca4b6169063de4eec9f
|
||||
gal: 61e868295d28fe67ffa297fae6dacebf56fd53e1
|
||||
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
|
||||
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
|
||||
image_cropper: 37d40f62177c101ff4c164906d259ea2c3aa70cf
|
||||
image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1
|
||||
livekit_client: c767049a635d5b6d43de3273dca3c439b8a6e970
|
||||
livekit_client: bad83a7776a41abc42e1f26d903eeac9164c8a9f
|
||||
media_kit_libs_ios_video: a5fe24bc7875ccd6378a0978c13185e1344651c1
|
||||
media_kit_native_event_loop: e6b2ab20cf0746eb1c33be961fcf79667304fa2a
|
||||
media_kit_video: 5da63f157170e5bf303bf85453b7ef6971218a2e
|
||||
@@ -293,11 +309,12 @@ SPEC CHECKSUMS:
|
||||
screen_brightness_ios: 715ca807df953bf676d339f11464e438143ee625
|
||||
SDWebImage: 066c47b573f408f18caa467d71deace7c0f8280d
|
||||
Sentry: 96ae1dcdf01a644bc3a3b1dc279cecaf48a833fb
|
||||
sentry_flutter: f1d86adcb93a959bc47a40d8d55059bdf7569bc5
|
||||
sentry_flutter: 090351ce1ff5f96a4b33ef9455b7e3b28185387d
|
||||
share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad
|
||||
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
|
||||
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
|
||||
SwiftyGif: 706c60cf65fa2bc5ee0313beece843c8eb8194d4
|
||||
TOCropViewController: 80b8985ad794298fb69d3341de183f33d1853654
|
||||
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
|
||||
volume_controller: 531ddf792994285c9b17f9d8a7e4dcdd29b3eae9
|
||||
wakelock_plus: 78ec7c5b202cab7761af8e2b2b3d0671be6c4ae1
|
||||
|
||||
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 320 KiB |
|
Before Width: | Height: | Size: 541 B After Width: | Height: | Size: 822 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 815 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 20 KiB |
@@ -1,10 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_animate/flutter_animate.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:solian/exts.dart';
|
||||
import 'package:solian/platform.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/providers/content/channel.dart';
|
||||
import 'package:solian/providers/content/realm.dart';
|
||||
import 'package:solian/providers/relation.dart';
|
||||
import 'package:solian/providers/stickers.dart';
|
||||
import 'package:solian/providers/theme_switcher.dart';
|
||||
import 'package:solian/providers/websocket.dart';
|
||||
import 'package:solian/services.dart';
|
||||
import 'package:solian/widgets/sized_container.dart';
|
||||
@@ -21,6 +26,7 @@ class BootstrapperShell extends StatefulWidget {
|
||||
class _BootstrapperShellState extends State<BootstrapperShell> {
|
||||
bool _isBusy = true;
|
||||
bool _isErrored = false;
|
||||
bool _isDismissable = true;
|
||||
String? _subtitle;
|
||||
|
||||
Color get _unFocusColor =>
|
||||
@@ -29,6 +35,38 @@ class _BootstrapperShellState extends State<BootstrapperShell> {
|
||||
int _periodCursor = 0;
|
||||
|
||||
late final List<({String label, Future<void> Function() action})> _periods = [
|
||||
(
|
||||
label: 'bsLoadingTheme',
|
||||
action: () async {
|
||||
await context.read<ThemeSwitcher>().restoreTheme();
|
||||
},
|
||||
),
|
||||
(
|
||||
label: 'bsCheckForUpdate',
|
||||
action: () async {
|
||||
if (PlatformInfo.isWeb) return;
|
||||
try {
|
||||
final info = await PackageInfo.fromPlatform();
|
||||
final localVersionString = '${info.version}+${info.buildNumber}';
|
||||
final resp = await GetConnect().get(
|
||||
'https://git.solsynth.dev/api/v1/repos/hydrogen/solian/tags?limit=1',
|
||||
);
|
||||
if (resp.body[0]['name'] != localVersionString) {
|
||||
setState(() {
|
||||
_isErrored = true;
|
||||
_subtitle = PlatformInfo.isIOS || PlatformInfo.isMacOS
|
||||
? 'bsCheckForUpdateDescApple'.tr
|
||||
: 'bsCheckForUpdateDescCommon'.tr;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
_isErrored = true;
|
||||
_subtitle = 'bsCheckForUpdateFailed'.tr;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
(
|
||||
label: 'bsCheckingServer',
|
||||
action: () async {
|
||||
@@ -38,12 +76,14 @@ class _BootstrapperShellState extends State<BootstrapperShell> {
|
||||
setState(() {
|
||||
_isErrored = true;
|
||||
_subtitle = 'bsCheckingServerDown'.tr;
|
||||
_isDismissable = false;
|
||||
});
|
||||
throw Exception('unable connect to server');
|
||||
} else if (resp.statusCode == null) {
|
||||
setState(() {
|
||||
_isErrored = true;
|
||||
_subtitle = 'bsCheckingServerFail'.tr;
|
||||
_isDismissable = false;
|
||||
});
|
||||
throw Exception('unable connect to server');
|
||||
}
|
||||
@@ -72,12 +112,15 @@ class _BootstrapperShellState extends State<BootstrapperShell> {
|
||||
label: 'bsPreparingData',
|
||||
action: () async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isTrue) {
|
||||
await Future.wait([
|
||||
await Future.wait([
|
||||
Get.find<StickerProvider>().refreshAvailableStickers(),
|
||||
if (auth.isAuthorized.isTrue)
|
||||
Get.find<ChannelProvider>().refreshAvailableChannel(),
|
||||
Get.find<RelationshipProvider>().refreshFriendList(),
|
||||
]);
|
||||
}
|
||||
if (auth.isAuthorized.isTrue)
|
||||
Get.find<RelationshipProvider>().refreshRelativeList(),
|
||||
if (auth.isAuthorized.isTrue)
|
||||
Get.find<RealmProvider>().refreshAvailableRealms(),
|
||||
]);
|
||||
},
|
||||
),
|
||||
(
|
||||
@@ -101,7 +144,7 @@ class _BootstrapperShellState extends State<BootstrapperShell> {
|
||||
try {
|
||||
for (var idx = 0; idx < _periods.length; idx++) {
|
||||
await _periods[idx].action();
|
||||
if (_isErrored) break;
|
||||
if (_isErrored && !_isDismissable) break;
|
||||
if (_periodCursor < _periods.length - 1) {
|
||||
setState(() => _periodCursor++);
|
||||
}
|
||||
@@ -130,17 +173,20 @@ class _BootstrapperShellState extends State<BootstrapperShell> {
|
||||
height: 280,
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Image.asset('assets/logo.png', width: 80, height: 80)
|
||||
.animate(onPlay: (c) => c.repeat())
|
||||
.rotate(duration: 850.ms, curve: Curves.easeInOut),
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||
child: Image.asset('assets/logo.png', width: 80, height: 80),
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
child: Column(
|
||||
children: [
|
||||
if (_isErrored)
|
||||
const Icon(Icons.cancel, size: 24)
|
||||
else
|
||||
if (_isErrored && !_isDismissable && !_isBusy)
|
||||
const Icon(Icons.cancel, size: 24),
|
||||
if (_isErrored && _isDismissable && !_isBusy)
|
||||
const Icon(Icons.warning, size: 24),
|
||||
if ((_isErrored && _isDismissable && _isBusy) || _isBusy)
|
||||
const SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
@@ -151,15 +197,24 @@ class _BootstrapperShellState extends State<BootstrapperShell> {
|
||||
maxWidth: 280,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
_subtitle ??
|
||||
'${_periods[_periodCursor].label.tr} (${_periodCursor + 1}/${_periods.length})',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: _unFocusColor,
|
||||
if (_subtitle == null)
|
||||
Text(
|
||||
'${_periods[_periodCursor].label.tr} (${_periodCursor + 1}/${_periods.length})',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: _unFocusColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_subtitle != null)
|
||||
Text(
|
||||
_subtitle!,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: _unFocusColor,
|
||||
),
|
||||
).paddingOnly(bottom: 4),
|
||||
Text(
|
||||
'2024 © Solsynth LLC',
|
||||
textAlign: TextAlign.center,
|
||||
@@ -175,12 +230,19 @@ class _BootstrapperShellState extends State<BootstrapperShell> {
|
||||
),
|
||||
onTap: () {
|
||||
if (_isBusy) return;
|
||||
setState(() {
|
||||
_isBusy = true;
|
||||
_isErrored = false;
|
||||
_periodCursor = 0;
|
||||
});
|
||||
_runPeriods();
|
||||
if (_isDismissable) {
|
||||
setState(() {
|
||||
_isBusy = false;
|
||||
_isErrored = false;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
_isBusy = true;
|
||||
_isErrored = false;
|
||||
_periodCursor = 0;
|
||||
});
|
||||
_runPeriods();
|
||||
}
|
||||
},
|
||||
)
|
||||
],
|
||||
|
||||
@@ -16,7 +16,7 @@ class ChatEventController {
|
||||
Channel? channel;
|
||||
String? scope;
|
||||
|
||||
initialize() async {
|
||||
Future<void> initialize() async {
|
||||
if (!PlatformInfo.isWeb) {
|
||||
database = await createHistoryDb();
|
||||
}
|
||||
@@ -131,6 +131,8 @@ class ChatEventController {
|
||||
}
|
||||
|
||||
insertEvent(LocalEvent entry) {
|
||||
if (entry.channelId != channel?.id) return;
|
||||
|
||||
final idx = currentEvents.indexWhere((x) => x.data.uuid == entry.data.uuid);
|
||||
if (idx != -1) {
|
||||
currentEvents[idx] = entry;
|
||||
|
||||
@@ -7,7 +7,9 @@ import 'package:solian/models/post.dart';
|
||||
import 'package:solian/models/realm.dart';
|
||||
import 'package:solian/widgets/attachments/attachment_editor.dart';
|
||||
import 'package:solian/widgets/posts/editor/post_editor_categories_tags.dart';
|
||||
import 'package:solian/widgets/posts/editor/post_editor_date.dart';
|
||||
import 'package:solian/widgets/posts/editor/post_editor_overview.dart';
|
||||
import 'package:solian/widgets/posts/editor/post_editor_publish_zone.dart';
|
||||
import 'package:solian/widgets/posts/editor/post_editor_visibility.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
@@ -25,6 +27,8 @@ class PostEditorController extends GetxController {
|
||||
Rx<Post?> replyTo = Rx(null);
|
||||
Rx<Post?> repostTo = Rx(null);
|
||||
Rx<Realm?> realmZone = Rx(null);
|
||||
Rx<DateTime?> publishedAt = Rx(null);
|
||||
Rx<DateTime?> publishedUntil = Rx(null);
|
||||
RxList<int> attachments = RxList<int>.empty(growable: true);
|
||||
RxList<String> tags = RxList<String>.empty(growable: true);
|
||||
|
||||
@@ -41,7 +45,6 @@ class PostEditorController extends GetxController {
|
||||
PostEditorController() {
|
||||
SharedPreferences.getInstance().then((inst) {
|
||||
_prefs = inst;
|
||||
localRead();
|
||||
_saveTimer = Timer.periodic(
|
||||
const Duration(seconds: 3),
|
||||
(Timer t) {
|
||||
@@ -88,16 +91,35 @@ class PostEditorController extends GetxController {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> editPublishZone(BuildContext context) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => PostEditorPublishZoneDialog(
|
||||
controller: this,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> editPublishDate(BuildContext context) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => PostEditorDateDialog(
|
||||
controller: this,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> editAttachment(BuildContext context) {
|
||||
return showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
builder: (context) => AttachmentEditorPopup(
|
||||
usage: 'i.attachment',
|
||||
current: attachments,
|
||||
onUpdate: (value) {
|
||||
attachments.value = value;
|
||||
attachments.refresh();
|
||||
initialAttachments: attachments,
|
||||
onAdd: (int value) {
|
||||
attachments.add(value);
|
||||
},
|
||||
onRemove: (int value) {
|
||||
attachments.remove(value);
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -122,10 +144,12 @@ class PostEditorController extends GetxController {
|
||||
}
|
||||
|
||||
void localRead() {
|
||||
if (_prefs.containsKey('post_editor_local_save')) {
|
||||
isRestoreFromLocal.value = true;
|
||||
payload = jsonDecode(_prefs.getString('post_editor_local_save')!);
|
||||
}
|
||||
SharedPreferences.getInstance().then((inst) {
|
||||
if (inst.containsKey('post_editor_local_save')) {
|
||||
isRestoreFromLocal.value = true;
|
||||
payload = jsonDecode(inst.getString('post_editor_local_save')!);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void localClear() {
|
||||
@@ -141,6 +165,8 @@ class PostEditorController extends GetxController {
|
||||
visibleUsers.clear();
|
||||
invisibleUsers.clear();
|
||||
visibility.value = 0;
|
||||
publishedAt.value = null;
|
||||
publishedUntil.value = null;
|
||||
isDraft.value = false;
|
||||
isRestoreFromLocal.value = false;
|
||||
lastSaveTime.value = null;
|
||||
@@ -163,6 +189,11 @@ class PostEditorController extends GetxController {
|
||||
titleController.text = value.body['title'] ?? '';
|
||||
descriptionController.text = value.body['description'] ?? '';
|
||||
contentController.text = value.body['content'] ?? '';
|
||||
publishedAt.value = value.publishedAt;
|
||||
publishedUntil.value = value.publishedUntil;
|
||||
tags.value =
|
||||
value.body['tags']?.map((x) => x['alias']).toList() ?? List.empty();
|
||||
tags.refresh();
|
||||
attachments.value = value.body['attachments']?.cast<int>() ?? List.empty();
|
||||
attachments.refresh();
|
||||
|
||||
@@ -215,11 +246,14 @@ class PostEditorController extends GetxController {
|
||||
'title': title,
|
||||
'description': description,
|
||||
'content': contentController.text,
|
||||
'tags': tags,
|
||||
'tags': tags.map((x) => {'alias': x}).toList(),
|
||||
'attachments': attachments,
|
||||
'visible_users': visibleUsers,
|
||||
'invisible_users': invisibleUsers,
|
||||
'visibility': visibility.value,
|
||||
'published_at': publishedAt.value?.toUtc().toIso8601String() ??
|
||||
DateTime.now().toUtc().toIso8601String(),
|
||||
'published_until': publishedUntil.value?.toUtc().toIso8601String(),
|
||||
'is_draft': isDraft.value,
|
||||
if (replyTo.value != null) 'reply_to': replyTo.value!.id,
|
||||
if (repostTo.value != null) 'repost_to': repostTo.value!.id,
|
||||
@@ -229,6 +263,7 @@ class PostEditorController extends GetxController {
|
||||
|
||||
set payload(Map<String, dynamic> value) {
|
||||
type = value['type'];
|
||||
tags.value = value['tags'].map((x) => x['alias']).toList().cast<String>();
|
||||
titleController.text = value['title'] ?? '';
|
||||
descriptionController.text = value['description'] ?? '';
|
||||
contentController.text = value['content'] ?? '';
|
||||
@@ -242,6 +277,12 @@ class PostEditorController extends GetxController {
|
||||
if (value['invisible_users'] != null) {
|
||||
invisibleUsers.value = value['invisible_users'].cast<int>();
|
||||
}
|
||||
if (value['published_at'] != null) {
|
||||
publishedAt.value = DateTime.parse(value['published_at']).toLocal();
|
||||
}
|
||||
if (value['published_until'] != null) {
|
||||
publishedAt.value = DateTime.parse(value['published_until']).toLocal();
|
||||
}
|
||||
if (value['reply_to'] != null) {
|
||||
replyTo.value = Post.fromJson(value['reply_to']);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
extension SolianExtenions on BuildContext {
|
||||
void showSnackbar(String content) {
|
||||
void showSnackbar(String content, {SnackBarAction? action}) {
|
||||
ScaffoldMessenger.of(this).showSnackBar(SnackBar(
|
||||
content: Text(content),
|
||||
action: action,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -29,6 +30,23 @@ extension SolianExtenions on BuildContext {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> showInfoDialog(String title, body) {
|
||||
return showDialog<void>(
|
||||
useRootNavigator: true,
|
||||
context: this,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text(title),
|
||||
content: Text(body),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx),
|
||||
child: Text('okay'.tr),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> showErrorDialog(dynamic exception) {
|
||||
var stack = StackTrace.current;
|
||||
var stackTrace = '$stack';
|
||||
|
||||
@@ -5,10 +5,14 @@ import 'package:get/get.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:media_kit/media_kit.dart';
|
||||
import 'package:protocol_handler/protocol_handler.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
import 'package:solian/bootstrapper.dart';
|
||||
import 'package:solian/firebase_options.dart';
|
||||
import 'package:solian/platform.dart';
|
||||
import 'package:solian/providers/attachment_uploader.dart';
|
||||
import 'package:solian/providers/stickers.dart';
|
||||
import 'package:solian/providers/theme_switcher.dart';
|
||||
import 'package:solian/providers/websocket.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/providers/content/attachment.dart';
|
||||
@@ -71,33 +75,45 @@ Future<void> _initializePlatformComponents() async {
|
||||
}
|
||||
}
|
||||
|
||||
final themeSwitcher = ThemeSwitcher(
|
||||
lightThemeData: SolianTheme.build(Brightness.light),
|
||||
darkThemeData: SolianTheme.build(Brightness.dark),
|
||||
);
|
||||
|
||||
class SolianApp extends StatelessWidget {
|
||||
const SolianApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetMaterialApp.router(
|
||||
title: 'Solian',
|
||||
theme: SolianTheme.build(Brightness.light),
|
||||
darkTheme: SolianTheme.build(Brightness.dark),
|
||||
themeMode: ThemeMode.system,
|
||||
routerDelegate: AppRouter.instance.routerDelegate,
|
||||
routeInformationParser: AppRouter.instance.routeInformationParser,
|
||||
routeInformationProvider: AppRouter.instance.routeInformationProvider,
|
||||
backButtonDispatcher: AppRouter.instance.backButtonDispatcher,
|
||||
translations: SolianMessages(),
|
||||
locale: Get.deviceLocale,
|
||||
fallbackLocale: const Locale('en', 'US'),
|
||||
onInit: () => _initializeProviders(context),
|
||||
builder: (context, child) {
|
||||
return SystemShell(
|
||||
child: ScaffoldMessenger(
|
||||
child: BootstrapperShell(
|
||||
child: child ?? const SizedBox(),
|
||||
),
|
||||
),
|
||||
return ChangeNotifierProvider.value(
|
||||
value: themeSwitcher,
|
||||
child: Builder(builder: (context) {
|
||||
final theme = Provider.of<ThemeSwitcher>(context);
|
||||
|
||||
return GetMaterialApp.router(
|
||||
title: 'Solian',
|
||||
theme: theme.lightThemeData,
|
||||
darkTheme: theme.darkThemeData,
|
||||
themeMode: ThemeMode.system,
|
||||
routerDelegate: AppRouter.instance.routerDelegate,
|
||||
routeInformationParser: AppRouter.instance.routeInformationParser,
|
||||
routeInformationProvider: AppRouter.instance.routeInformationProvider,
|
||||
backButtonDispatcher: AppRouter.instance.backButtonDispatcher,
|
||||
translations: SolianMessages(),
|
||||
locale: Get.deviceLocale,
|
||||
fallbackLocale: const Locale('en', 'US'),
|
||||
onInit: () => _initializeProviders(context),
|
||||
builder: (context, child) {
|
||||
return SystemShell(
|
||||
child: ScaffoldMessenger(
|
||||
child: BootstrapperShell(
|
||||
child: child ?? const SizedBox(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -105,11 +121,13 @@ class SolianApp extends StatelessWidget {
|
||||
Get.lazyPut(() => AuthProvider());
|
||||
Get.lazyPut(() => RelationshipProvider());
|
||||
Get.lazyPut(() => PostProvider());
|
||||
Get.lazyPut(() => StickerProvider());
|
||||
Get.lazyPut(() => AttachmentProvider());
|
||||
Get.lazyPut(() => WebSocketProvider());
|
||||
Get.lazyPut(() => StatusProvider());
|
||||
Get.lazyPut(() => ChannelProvider());
|
||||
Get.lazyPut(() => RealmProvider());
|
||||
Get.lazyPut(() => ChatCallProvider());
|
||||
Get.lazyPut(() => AttachmentUploaderController());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ class Call {
|
||||
String externalId;
|
||||
int founderId;
|
||||
int channelId;
|
||||
List<dynamic> participants;
|
||||
Channel channel;
|
||||
|
||||
Call({
|
||||
@@ -21,6 +22,7 @@ class Call {
|
||||
required this.externalId,
|
||||
required this.founderId,
|
||||
required this.channelId,
|
||||
required this.participants,
|
||||
required this.channel,
|
||||
});
|
||||
|
||||
@@ -34,6 +36,7 @@ class Call {
|
||||
externalId: json['external_id'],
|
||||
founderId: json['founder_id'],
|
||||
channelId: json['channel_id'],
|
||||
participants: json['participants'] ?? List.empty(),
|
||||
channel: Channel.fromJson(json['channel']),
|
||||
);
|
||||
|
||||
@@ -46,6 +49,7 @@ class Call {
|
||||
'external_id': externalId,
|
||||
'founder_id': founderId,
|
||||
'channel_id': channelId,
|
||||
'participants': participants,
|
||||
'channel': channel.toJson(),
|
||||
};
|
||||
}
|
||||
@@ -63,6 +67,7 @@ class ParticipantTrack {
|
||||
{required this.participant,
|
||||
required this.videoTrack,
|
||||
required this.isScreenShare});
|
||||
|
||||
VideoTrack? videoTrack;
|
||||
Participant participant;
|
||||
bool isScreenShare;
|
||||
|
||||
@@ -20,6 +20,7 @@ class Post {
|
||||
Post? repostTo;
|
||||
Realm? realm;
|
||||
DateTime? publishedAt;
|
||||
DateTime? publishedUntil;
|
||||
DateTime? pinnedAt;
|
||||
bool? isDraft;
|
||||
int authorId;
|
||||
@@ -44,6 +45,7 @@ class Post {
|
||||
required this.repostTo,
|
||||
required this.realm,
|
||||
required this.publishedAt,
|
||||
required this.publishedUntil,
|
||||
required this.pinnedAt,
|
||||
required this.isDraft,
|
||||
required this.authorId,
|
||||
@@ -80,6 +82,9 @@ class Post {
|
||||
publishedAt: json['published_at'] != null
|
||||
? DateTime.parse(json['published_at'])
|
||||
: null,
|
||||
publishedUntil: json['published_until'] != null
|
||||
? DateTime.parse(json['published_until'])
|
||||
: null,
|
||||
pinnedAt: json['pinned_at'] != null
|
||||
? DateTime.parse(json['pinned_at'])
|
||||
: null,
|
||||
@@ -108,6 +113,7 @@ class Post {
|
||||
'repost_to': repostTo?.toJson(),
|
||||
'realm': realm?.toJson(),
|
||||
'published_at': publishedAt?.toIso8601String(),
|
||||
'published_until': publishedUntil?.toIso8601String(),
|
||||
'pinned_at': pinnedAt?.toIso8601String(),
|
||||
'is_draft': isDraft,
|
||||
'author_id': authorId,
|
||||
|
||||
122
lib/models/stickers.dart
Normal file
@@ -0,0 +1,122 @@
|
||||
import 'package:solian/models/account.dart';
|
||||
import 'package:solian/models/attachment.dart';
|
||||
|
||||
class Sticker {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
DateTime updatedAt;
|
||||
DateTime? deletedAt;
|
||||
String alias;
|
||||
String name;
|
||||
int attachmentId;
|
||||
Attachment attachment;
|
||||
int packId;
|
||||
StickerPack? pack;
|
||||
int accountId;
|
||||
Account account;
|
||||
|
||||
Sticker({
|
||||
required this.id,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.deletedAt,
|
||||
required this.alias,
|
||||
required this.name,
|
||||
required this.attachmentId,
|
||||
required this.attachment,
|
||||
required this.packId,
|
||||
required this.pack,
|
||||
required this.accountId,
|
||||
required this.account,
|
||||
});
|
||||
|
||||
factory Sticker.fromJson(Map<String, dynamic> json) => Sticker(
|
||||
id: json['id'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'] != null
|
||||
? DateTime.parse(json['deleted_at'])
|
||||
: json['deleted_at'],
|
||||
alias: json['alias'],
|
||||
name: json['name'],
|
||||
attachmentId: json['attachment_id'],
|
||||
attachment: Attachment.fromJson(json['attachment']),
|
||||
packId: json['pack_id'],
|
||||
pack: json['pack'] != null ? StickerPack.fromJson(json['pack']) : null,
|
||||
accountId: json['account_id'],
|
||||
account: Account.fromJson(json['account']),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt?.toIso8601String(),
|
||||
'alias': alias,
|
||||
'name': name,
|
||||
'attachment_id': attachmentId,
|
||||
'attachment': attachment.toJson(),
|
||||
'pack_id': packId,
|
||||
'account_id': accountId,
|
||||
'account': account.toJson(),
|
||||
};
|
||||
}
|
||||
|
||||
class StickerPack {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
DateTime updatedAt;
|
||||
DateTime? deletedAt;
|
||||
String prefix;
|
||||
String name;
|
||||
String description;
|
||||
List<Sticker>? stickers;
|
||||
int accountId;
|
||||
Account account;
|
||||
|
||||
StickerPack({
|
||||
required this.id,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.deletedAt,
|
||||
required this.prefix,
|
||||
required this.name,
|
||||
required this.description,
|
||||
required this.stickers,
|
||||
required this.accountId,
|
||||
required this.account,
|
||||
});
|
||||
|
||||
factory StickerPack.fromJson(Map<String, dynamic> json) => StickerPack(
|
||||
id: json['id'],
|
||||
createdAt: DateTime.parse(json['created_at']),
|
||||
updatedAt: DateTime.parse(json['updated_at']),
|
||||
deletedAt: json['deleted_at'] != null
|
||||
? DateTime.parse(json['deleted_at'])
|
||||
: json['deleted_at'],
|
||||
prefix: json['prefix'],
|
||||
name: json['name'],
|
||||
description: json['description'],
|
||||
stickers: json['stickers'] == null
|
||||
? []
|
||||
: List<Sticker>.from(
|
||||
json['stickers']!.map((x) => Sticker.fromJson(x))),
|
||||
accountId: json['account_id'],
|
||||
account: Account.fromJson(json['account']),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
'deleted_at': deletedAt?.toIso8601String(),
|
||||
'prefix': prefix,
|
||||
'name': name,
|
||||
'description': description,
|
||||
'stickers': stickers == null
|
||||
? []
|
||||
: List<dynamic>.from(stickers!.map((x) => x.toJson())),
|
||||
'account_id': accountId,
|
||||
'account': account.toJson(),
|
||||
};
|
||||
}
|
||||
214
lib/providers/attachment_uploader.dart
Normal file
@@ -0,0 +1,214 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/models/attachment.dart';
|
||||
import 'package:solian/providers/content/attachment.dart';
|
||||
|
||||
class AttachmentUploadTask {
|
||||
File file;
|
||||
String usage;
|
||||
Map<String, dynamic>? metadata;
|
||||
|
||||
double progress = 0;
|
||||
bool isUploading = false;
|
||||
bool isCompleted = false;
|
||||
dynamic error;
|
||||
|
||||
AttachmentUploadTask({
|
||||
required this.file,
|
||||
required this.usage,
|
||||
this.metadata,
|
||||
});
|
||||
}
|
||||
|
||||
class AttachmentUploaderController extends GetxController {
|
||||
RxBool isUploading = false.obs;
|
||||
RxDouble progressOfUpload = 0.0.obs;
|
||||
RxList<AttachmentUploadTask> queueOfUpload = RxList.empty(growable: true);
|
||||
|
||||
Timer? _progressSyncTimer;
|
||||
double _progressOfUpload = 0.0;
|
||||
|
||||
void _syncProgress() {
|
||||
progressOfUpload.value = _progressOfUpload;
|
||||
queueOfUpload.refresh();
|
||||
}
|
||||
|
||||
void _startProgressSyncTimer() {
|
||||
if (_progressSyncTimer != null) {
|
||||
_progressSyncTimer!.cancel();
|
||||
}
|
||||
_progressSyncTimer = Timer.periodic(
|
||||
const Duration(milliseconds: 500),
|
||||
(_) => _syncProgress(),
|
||||
);
|
||||
}
|
||||
|
||||
void _stopProgressSyncTimer() {
|
||||
if (_progressSyncTimer == null) return;
|
||||
_progressSyncTimer!.cancel();
|
||||
_progressSyncTimer = null;
|
||||
}
|
||||
|
||||
void enqueueTask(AttachmentUploadTask task) {
|
||||
if (isUploading.value) throw Exception('uploading blocked');
|
||||
queueOfUpload.add(task);
|
||||
}
|
||||
|
||||
void enqueueTaskBatch(Iterable<AttachmentUploadTask> tasks) {
|
||||
if (isUploading.value) throw Exception('uploading blocked');
|
||||
queueOfUpload.addAll(tasks);
|
||||
}
|
||||
|
||||
void dequeueTask(AttachmentUploadTask task) {
|
||||
if (isUploading.value) throw Exception('uploading blocked');
|
||||
queueOfUpload.remove(task);
|
||||
}
|
||||
|
||||
Future<Attachment?> performSingleTask(int queueIndex) async {
|
||||
isUploading.value = true;
|
||||
progressOfUpload.value = 0;
|
||||
|
||||
_startProgressSyncTimer();
|
||||
queueOfUpload[queueIndex].isUploading = true;
|
||||
|
||||
final task = queueOfUpload[queueIndex];
|
||||
final result = await _rawUploadAttachment(
|
||||
await task.file.readAsBytes(),
|
||||
task.file.path,
|
||||
task.usage,
|
||||
null,
|
||||
onProgress: (value) {
|
||||
queueOfUpload[queueIndex].progress = value;
|
||||
_progressOfUpload = value;
|
||||
},
|
||||
onError: (err) {
|
||||
queueOfUpload[queueIndex].error = err;
|
||||
queueOfUpload[queueIndex].isUploading = false;
|
||||
},
|
||||
);
|
||||
|
||||
if (queueOfUpload[queueIndex].error == null) {
|
||||
queueOfUpload.removeAt(queueIndex);
|
||||
}
|
||||
_stopProgressSyncTimer();
|
||||
_syncProgress();
|
||||
|
||||
isUploading.value = false;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<void> performUploadQueue({
|
||||
required Function(Attachment item) onData,
|
||||
}) async {
|
||||
isUploading.value = true;
|
||||
progressOfUpload.value = 0;
|
||||
|
||||
_startProgressSyncTimer();
|
||||
|
||||
for (var idx = 0; idx < queueOfUpload.length; idx++) {
|
||||
if (queueOfUpload[idx].isUploading || queueOfUpload[idx].error != null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
queueOfUpload[idx].isUploading = true;
|
||||
|
||||
final task = queueOfUpload[idx];
|
||||
final result = await _rawUploadAttachment(
|
||||
await task.file.readAsBytes(),
|
||||
task.file.path,
|
||||
task.usage,
|
||||
null,
|
||||
onProgress: (value) {
|
||||
queueOfUpload[idx].progress = value;
|
||||
_progressOfUpload = (idx + value) / queueOfUpload.length;
|
||||
},
|
||||
onError: (err) {
|
||||
queueOfUpload[idx].error = err;
|
||||
queueOfUpload[idx].isUploading = false;
|
||||
},
|
||||
);
|
||||
_progressOfUpload = (idx + 1) / queueOfUpload.length;
|
||||
if (result != null) onData(result);
|
||||
|
||||
queueOfUpload[idx].isUploading = false;
|
||||
queueOfUpload[idx].isCompleted = true;
|
||||
}
|
||||
|
||||
queueOfUpload.value =
|
||||
queueOfUpload.where((x) => x.error == null).toList(growable: true);
|
||||
_stopProgressSyncTimer();
|
||||
_syncProgress();
|
||||
|
||||
isUploading.value = false;
|
||||
}
|
||||
|
||||
Future<void> uploadAttachmentWithCallback(
|
||||
Uint8List data,
|
||||
String path,
|
||||
String usage,
|
||||
Map<String, dynamic>? metadata,
|
||||
Function(Attachment?) callback,
|
||||
) async {
|
||||
if (isUploading.value) throw Exception('uploading blocked');
|
||||
|
||||
isUploading.value = true;
|
||||
final result = await _rawUploadAttachment(
|
||||
data,
|
||||
path,
|
||||
usage,
|
||||
metadata,
|
||||
onProgress: (progress) {
|
||||
progressOfUpload.value = progress;
|
||||
},
|
||||
);
|
||||
isUploading.value = false;
|
||||
callback(result);
|
||||
}
|
||||
|
||||
Future<Attachment?> uploadAttachment(
|
||||
Uint8List data,
|
||||
String path,
|
||||
String usage,
|
||||
Map<String, dynamic>? metadata,
|
||||
) async {
|
||||
if (isUploading.value) throw Exception('uploading blocked');
|
||||
|
||||
isUploading.value = true;
|
||||
final result = await _rawUploadAttachment(
|
||||
data,
|
||||
path,
|
||||
usage,
|
||||
metadata,
|
||||
onProgress: (progress) {
|
||||
progressOfUpload.value = progress;
|
||||
},
|
||||
);
|
||||
isUploading.value = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<Attachment?> _rawUploadAttachment(
|
||||
Uint8List data, String path, String usage, Map<String, dynamic>? metadata,
|
||||
{Function(double)? onProgress, Function(dynamic err)? onError}) async {
|
||||
final AttachmentProvider provider = Get.find();
|
||||
try {
|
||||
final result = await provider.createAttachment(
|
||||
data,
|
||||
path,
|
||||
usage,
|
||||
metadata,
|
||||
onProgress: onProgress,
|
||||
);
|
||||
return result;
|
||||
} catch (err) {
|
||||
if (onError != null) {
|
||||
onError(err);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ class ChatCallProvider extends GetxController {
|
||||
|
||||
RxBool isReady = false.obs;
|
||||
RxBool isMounted = false.obs;
|
||||
RxBool isInitialized = false.obs;
|
||||
|
||||
String? token;
|
||||
String? endpoint;
|
||||
@@ -151,6 +152,8 @@ class ChatCallProvider extends GetxController {
|
||||
void onRoomDidUpdate() => sortParticipants();
|
||||
|
||||
void setupRoom() {
|
||||
if(isInitialized.value) return;
|
||||
|
||||
sortParticipants();
|
||||
room.addListener(onRoomDidUpdate);
|
||||
WidgetsBindingCompatible.instance?.addPostFrameCallback(
|
||||
@@ -160,6 +163,8 @@ class ChatCallProvider extends GetxController {
|
||||
if (lkPlatformIsMobile()) {
|
||||
Hardware.instance.setSpeakerphoneOn(true);
|
||||
}
|
||||
|
||||
isInitialized.value = true;
|
||||
}
|
||||
|
||||
void setupRoomListeners({
|
||||
@@ -362,6 +367,7 @@ class ChatCallProvider extends GetxController {
|
||||
|
||||
void disposeRoom() {
|
||||
isMounted.value = false;
|
||||
isInitialized.value = false;
|
||||
current.value = null;
|
||||
channel.value = null;
|
||||
room.removeListener(onRoomDidUpdate);
|
||||
|
||||
@@ -4,8 +4,10 @@ import 'dart:typed_data';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:solian/models/attachment.dart';
|
||||
import 'package:solian/models/pagination.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/services.dart';
|
||||
import 'package:dio/dio.dart' as dio;
|
||||
|
||||
class AttachmentProvider extends GetConnect {
|
||||
static Map<String, String> mimetypeOverrides = {
|
||||
@@ -20,6 +22,50 @@ class AttachmentProvider extends GetConnect {
|
||||
|
||||
final Map<int, Attachment> _cachedResponses = {};
|
||||
|
||||
Future<List<Attachment?>> listMetadata(
|
||||
List<int> id, {
|
||||
noCache = false,
|
||||
}) async {
|
||||
if (id.isEmpty) return List.empty();
|
||||
|
||||
List<Attachment?> result = List.filled(id.length, null);
|
||||
List<int> pendingQuery = List.empty(growable: true);
|
||||
if (!noCache) {
|
||||
for (var idx = 0; idx < id.length; idx++) {
|
||||
if (_cachedResponses.containsKey(id[idx])) {
|
||||
result[idx] = _cachedResponses[id[idx]];
|
||||
} else {
|
||||
pendingQuery.add(id[idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final resp = await get(
|
||||
'/attachments?take=${pendingQuery.length}&id=${pendingQuery.join(',')}',
|
||||
);
|
||||
if (resp.statusCode != 200) return result;
|
||||
|
||||
final rawOut = PaginationResult.fromJson(resp.body);
|
||||
if (rawOut.data == null) return result;
|
||||
|
||||
final List<Attachment> out =
|
||||
rawOut.data!.map((x) => Attachment.fromJson(x)).toList();
|
||||
for (final item in out) {
|
||||
if (item.destination != 0 && item.isAnalyzed) {
|
||||
_cachedResponses[item.id] = item;
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < out.length; i++) {
|
||||
for (var j = 0; j < id.length; j++) {
|
||||
if (out[i].id == id[j]) {
|
||||
result[j] = out[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<Attachment?> getMetadata(int id, {noCache = false}) async {
|
||||
if (!noCache && _cachedResponses.containsKey(id)) {
|
||||
return _cachedResponses[id]!;
|
||||
@@ -37,21 +83,14 @@ class AttachmentProvider extends GetConnect {
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<Response> createAttachment(
|
||||
Uint8List data,
|
||||
String path,
|
||||
String usage,
|
||||
Map<String, dynamic>? metadata,
|
||||
) async {
|
||||
Future<Attachment> createAttachment(
|
||||
Uint8List data, String path, String usage, Map<String, dynamic>? metadata,
|
||||
{Function(double)? onProgress}) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
|
||||
final client = auth.configureClient(
|
||||
'files',
|
||||
timeout: const Duration(minutes: 3),
|
||||
);
|
||||
|
||||
final filePayload = MultipartFile(data, filename: basename(path));
|
||||
final filePayload =
|
||||
dio.MultipartFile.fromBytes(data, filename: basename(path));
|
||||
final fileAlt = basename(path).contains('.')
|
||||
? basename(path).substring(0, basename(path).lastIndexOf('.'))
|
||||
: basename(path);
|
||||
@@ -64,19 +103,30 @@ class AttachmentProvider extends GetConnect {
|
||||
if (mimetypeOverrides.keys.contains(fileExt)) {
|
||||
mimetypeOverride = mimetypeOverrides[fileExt];
|
||||
}
|
||||
final payload = FormData({
|
||||
final payload = dio.FormData.fromMap({
|
||||
'alt': fileAlt,
|
||||
'file': filePayload,
|
||||
'usage': usage,
|
||||
if (mimetypeOverride != null) 'mimetype': mimetypeOverride,
|
||||
'metadata': jsonEncode(metadata),
|
||||
});
|
||||
final resp = await client.post('/attachments', payload);
|
||||
final resp = await dio.Dio(
|
||||
dio.BaseOptions(
|
||||
baseUrl: ServiceFinder.buildUrl('files', null),
|
||||
headers: {'Authorization': 'Bearer ${auth.credentials!.accessToken}'},
|
||||
),
|
||||
).post(
|
||||
'/attachments',
|
||||
data: payload,
|
||||
onSendProgress: (count, total) {
|
||||
if (onProgress != null) onProgress(count / total);
|
||||
},
|
||||
);
|
||||
if (resp.statusCode != 200) {
|
||||
throw Exception(resp.bodyString);
|
||||
throw Exception(resp.data);
|
||||
}
|
||||
|
||||
return resp;
|
||||
return Attachment.fromJson(resp.data);
|
||||
}
|
||||
|
||||
Future<Response> updateAttachment(
|
||||
|
||||
@@ -1,7 +1,24 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/models/realm.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
|
||||
class RealmProvider extends GetxController {
|
||||
RxBool isLoading = false.obs;
|
||||
RxList<Realm> availableRealms = RxList.empty(growable: true);
|
||||
|
||||
Future<void> refreshAvailableRealms() async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
|
||||
isLoading.value = true;
|
||||
final resp = await listAvailableRealm();
|
||||
isLoading.value = false;
|
||||
|
||||
availableRealms.value =
|
||||
resp.body.map((x) => Realm.fromJson(x)).toList().cast<Realm>();
|
||||
availableRealms.refresh();
|
||||
}
|
||||
|
||||
Future<Response> getRealm(String alias) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
|
||||
|
||||
@@ -4,15 +4,19 @@ import 'package:solian/models/relations.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
|
||||
class RelationshipProvider extends GetxController {
|
||||
final RxInt friendRequestCount = 0.obs;
|
||||
|
||||
final RxList<Relationship> _friends = RxList.empty(growable: true);
|
||||
|
||||
Future<void> refreshFriendList() async {
|
||||
final resp = await listRelationWithStatus(1);
|
||||
_friends.value = resp.body
|
||||
Future<void> refreshRelativeList() async {
|
||||
final resp = await listRelation();
|
||||
final List<Relationship> result = resp.body
|
||||
.map((e) => Relationship.fromJson(e))
|
||||
.toList()
|
||||
.cast<Relationship>();
|
||||
_friends.value = result.where((x) => x.status == 1).toList();
|
||||
_friends.refresh();
|
||||
friendRequestCount.value = result.where((x) => x.status == 0).length;
|
||||
}
|
||||
|
||||
bool hasFriend(Account account) {
|
||||
|
||||
38
lib/providers/stickers.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/models/pagination.dart';
|
||||
import 'package:solian/models/stickers.dart';
|
||||
import 'package:solian/services.dart';
|
||||
|
||||
class StickerProvider extends GetxController {
|
||||
final RxMap<String, String> aliasImageMapping = RxMap();
|
||||
final RxMap<String, List<Sticker>> availableStickers = RxMap();
|
||||
|
||||
Future<void> refreshAvailableStickers() async {
|
||||
final client = ServiceFinder.configureClient('files');
|
||||
final resp = await client.get(
|
||||
'/stickers/manifest?take=100',
|
||||
);
|
||||
if (resp.statusCode == 200) {
|
||||
final result = PaginationResult.fromJson(resp.body);
|
||||
final out = result.data?.map((e) => StickerPack.fromJson(e)).toList();
|
||||
if (out == null) return;
|
||||
|
||||
for (final pack in out) {
|
||||
for (final sticker in (pack.stickers ?? List<Sticker>.empty())) {
|
||||
sticker.pack = pack;
|
||||
final imageUrl = ServiceFinder.buildUrl(
|
||||
'files',
|
||||
'/attachments/${sticker.attachmentId}',
|
||||
);
|
||||
aliasImageMapping['${pack.prefix}${sticker.alias}'.camelCase!] =
|
||||
imageUrl;
|
||||
if (availableStickers[pack.prefix] == null) {
|
||||
availableStickers[pack.prefix] = List.empty(growable: true);
|
||||
}
|
||||
availableStickers[pack.prefix]!.add(sticker);
|
||||
}
|
||||
}
|
||||
}
|
||||
availableStickers.refresh();
|
||||
}
|
||||
}
|
||||
30
lib/providers/theme_switcher.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:solian/theme.dart';
|
||||
|
||||
class ThemeSwitcher extends ChangeNotifier {
|
||||
ThemeData lightThemeData;
|
||||
ThemeData darkThemeData;
|
||||
|
||||
ThemeSwitcher({
|
||||
required this.lightThemeData,
|
||||
required this.darkThemeData,
|
||||
});
|
||||
|
||||
Future<void> restoreTheme() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
if (prefs.containsKey('global_theme_color')) {
|
||||
final value = prefs.getInt('global_theme_color')!;
|
||||
final color = Color(value);
|
||||
lightThemeData = SolianTheme.build(Brightness.light, seedColor: color);
|
||||
darkThemeData = SolianTheme.build(Brightness.dark, seedColor: color);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
void setTheme(ThemeData light, dark) {
|
||||
lightThemeData = light;
|
||||
darkThemeData = dark;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:animations/animations.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:solian/models/realm.dart';
|
||||
import 'package:solian/screens/about.dart';
|
||||
@@ -5,6 +7,7 @@ import 'package:solian/screens/account.dart';
|
||||
import 'package:solian/screens/account/friend.dart';
|
||||
import 'package:solian/screens/account/personalize.dart';
|
||||
import 'package:solian/screens/account/profile_page.dart';
|
||||
import 'package:solian/screens/account/stickers.dart';
|
||||
import 'package:solian/screens/channel/channel_chat.dart';
|
||||
import 'package:solian/screens/channel/channel_detail.dart';
|
||||
import 'package:solian/screens/channel/channel_organize.dart';
|
||||
@@ -18,6 +21,7 @@ import 'package:solian/screens/realms/realm_organize.dart';
|
||||
import 'package:solian/screens/realms/realm_view.dart';
|
||||
import 'package:solian/screens/home.dart';
|
||||
import 'package:solian/screens/posts/post_editor.dart';
|
||||
import 'package:solian/screens/settings.dart';
|
||||
import 'package:solian/shells/root_shell.dart';
|
||||
import 'package:solian/shells/title_shell.dart';
|
||||
|
||||
@@ -34,6 +38,22 @@ abstract class AppRouter {
|
||||
_chatRoute,
|
||||
_realmRoute,
|
||||
_accountRoute,
|
||||
GoRoute(
|
||||
path: '/about',
|
||||
name: 'about',
|
||||
builder: (context, state) => TitleShell(
|
||||
state: state,
|
||||
child: const AboutScreen(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/settings',
|
||||
name: 'settings',
|
||||
builder: (context, state) => TitleShell(
|
||||
state: state,
|
||||
child: const SettingScreen(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -76,14 +96,26 @@ abstract class AppRouter {
|
||||
GoRoute(
|
||||
path: '/posts/editor',
|
||||
name: 'postEditor',
|
||||
builder: (context, state) {
|
||||
pageBuilder: (context, state) {
|
||||
final arguments = state.extra as PostPublishArguments?;
|
||||
return PostPublishScreen(
|
||||
edit: arguments?.edit,
|
||||
reply: arguments?.reply,
|
||||
repost: arguments?.repost,
|
||||
realm: arguments?.realm,
|
||||
mode: int.tryParse(state.uri.queryParameters['mode'] ?? '0') ?? 0,
|
||||
return CustomTransitionPage(
|
||||
child: PostPublishScreen(
|
||||
edit: arguments?.edit,
|
||||
reply: arguments?.reply,
|
||||
repost: arguments?.repost,
|
||||
realm: arguments?.realm,
|
||||
postListController: arguments?.postListController,
|
||||
mode: int.tryParse(state.uri.queryParameters['mode'] ?? '0') ?? 0,
|
||||
),
|
||||
transitionsBuilder:
|
||||
(context, animation, secondaryAnimation, child) {
|
||||
return FadeThroughTransition(
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
animation: animation,
|
||||
secondaryAnimation: secondaryAnimation,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -195,6 +227,14 @@ abstract class AppRouter {
|
||||
name: 'accountFriend',
|
||||
builder: (context, state) => const FriendScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/account/stickers',
|
||||
name: 'accountStickers',
|
||||
builder: (context, state) => TitleShell(
|
||||
state: state,
|
||||
child: const StickerScreen(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/account/personalize',
|
||||
name: 'accountPersonalize',
|
||||
@@ -210,14 +250,6 @@ abstract class AppRouter {
|
||||
name: state.pathParameters['name']!,
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/about',
|
||||
name: 'about',
|
||||
builder: (context, state) => TitleShell(
|
||||
state: state,
|
||||
child: const AboutScreen(),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,11 @@ class AboutScreen extends StatelessWidget {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset('assets/logo.png', width: 64, height: 64),
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||
child: Image.asset('assets/logo.png', width: 120, height: 120),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Solian',
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
@@ -44,17 +48,28 @@ class AboutScreen extends StatelessWidget {
|
||||
const SizedBox(height: 16),
|
||||
TextButton(
|
||||
style: denseButtonStyle,
|
||||
child: const Text('More Information'),
|
||||
onPressed: () {
|
||||
launchUrlString('https://solsynth.dev/products/solar-network');
|
||||
child: const Text('App Details'),
|
||||
onPressed: () async {
|
||||
final info = await PackageInfo.fromPlatform();
|
||||
|
||||
showAboutDialog(
|
||||
context: context,
|
||||
applicationVersion: '${info.version} (${info.buildNumber})',
|
||||
applicationLegalese:
|
||||
'The Solar Network App is an intuitive and self-hostable social network and computing platform. Experience the freedom of a user-friendly design that empowers you to create and connect with communities on your own terms. Embrace the future of social networking with a platform that prioritizes your independence and privacy.',
|
||||
applicationIcon: ClipRRect(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||
child: Image.asset('assets/logo.png', width: 60, height: 60),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
style: denseButtonStyle,
|
||||
child: const Text('Project Website'),
|
||||
onPressed: () {
|
||||
launchUrlString('https://solsynth.dev');
|
||||
launchUrlString('https://solsynth.dev/products/solar-network');
|
||||
},
|
||||
child: const Text('Official Website'),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
|
||||
@@ -3,11 +3,13 @@ import 'package:get/get.dart';
|
||||
import 'package:solian/models/account.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/providers/account_status.dart';
|
||||
import 'package:solian/providers/relation.dart';
|
||||
import 'package:solian/router.dart';
|
||||
import 'package:solian/screens/auth/signin.dart';
|
||||
import 'package:solian/screens/auth/signup.dart';
|
||||
import 'package:solian/widgets/account/account_heading.dart';
|
||||
import 'package:solian/widgets/sized_container.dart';
|
||||
import 'package:badges/badges.dart' as badges;
|
||||
|
||||
class AccountScreen extends StatefulWidget {
|
||||
const AccountScreen({super.key});
|
||||
@@ -23,10 +25,32 @@ class _AccountScreenState extends State<AccountScreen> {
|
||||
(
|
||||
const Icon(Icons.color_lens),
|
||||
'accountPersonalize'.tr,
|
||||
'accountPersonalize'
|
||||
'accountPersonalize',
|
||||
),
|
||||
(
|
||||
Obx(() {
|
||||
final RelationshipProvider relations = Get.find();
|
||||
return badges.Badge(
|
||||
badgeContent: Text(
|
||||
relations.friendRequestCount.value.toString(),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
showBadge: relations.friendRequestCount.value > 0,
|
||||
position: badges.BadgePosition.topEnd(
|
||||
top: -12,
|
||||
end: -8,
|
||||
),
|
||||
child: const Icon(Icons.diversity_1),
|
||||
);
|
||||
}),
|
||||
'accountFriend'.tr,
|
||||
'accountFriend',
|
||||
),
|
||||
(
|
||||
const Icon(Icons.emoji_symbols),
|
||||
'accountStickers'.tr,
|
||||
'accountStickers',
|
||||
),
|
||||
(const Icon(Icons.diversity_1), 'accountFriend'.tr, 'accountFriend'),
|
||||
(const Icon(Icons.info_outline), 'about'.tr, 'about'),
|
||||
];
|
||||
|
||||
final AuthProvider auth = Get.find();
|
||||
@@ -41,7 +65,10 @@ class _AccountScreenState extends State<AccountScreen> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ActionCard(
|
||||
icon: const Icon(Icons.login, color: Colors.white),
|
||||
icon: Icon(
|
||||
Icons.login,
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
),
|
||||
title: 'signin'.tr,
|
||||
caption: 'signinCaption'.tr,
|
||||
onTap: () {
|
||||
@@ -59,7 +86,10 @@ class _AccountScreenState extends State<AccountScreen> {
|
||||
},
|
||||
),
|
||||
ActionCard(
|
||||
icon: const Icon(Icons.add, color: Colors.white),
|
||||
icon: Icon(
|
||||
Icons.add,
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
),
|
||||
title: 'signup'.tr,
|
||||
caption: 'signupCaption'.tr,
|
||||
onTap: () {
|
||||
@@ -184,7 +214,7 @@ class ActionCard extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundColor: Colors.indigo,
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
child: icon,
|
||||
).paddingOnly(bottom: 12),
|
||||
Text(
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_animate/flutter_animate.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/exts.dart';
|
||||
import 'package:solian/models/relations.dart';
|
||||
import 'package:solian/providers/relation.dart';
|
||||
import 'package:solian/theme.dart';
|
||||
import 'package:solian/widgets/account/relative_list.dart';
|
||||
|
||||
class FriendScreen extends StatefulWidget {
|
||||
@@ -21,15 +21,15 @@ class _FriendScreenState extends State<FriendScreen>
|
||||
|
||||
List<Relationship> _relations = List.empty();
|
||||
|
||||
List<Relationship> filterByStatus(int status) {
|
||||
List<Relationship> _filterByStatus(int status) {
|
||||
return _relations.where((x) => x.status == status).toList();
|
||||
}
|
||||
|
||||
Future<void> loadRelations() async {
|
||||
Future<void> _loadRelations() async {
|
||||
setState(() => _isBusy = true);
|
||||
|
||||
final RelationshipProvider provider = Get.find();
|
||||
final resp = await provider.listRelation();
|
||||
final RelationshipProvider relations = Get.find();
|
||||
final resp = await relations.listRelation();
|
||||
|
||||
setState(() {
|
||||
_relations = resp.body
|
||||
@@ -38,9 +38,12 @@ class _FriendScreenState extends State<FriendScreen>
|
||||
.cast<Relationship>();
|
||||
_isBusy = false;
|
||||
});
|
||||
|
||||
relations.friendRequestCount.value =
|
||||
_relations.where((x) => x.status == 0).length;
|
||||
}
|
||||
|
||||
void promptAddFriend() async {
|
||||
void _promptAddFriend() async {
|
||||
final RelationshipProvider provider = Get.find();
|
||||
|
||||
final controller = TextEditingController();
|
||||
@@ -104,8 +107,8 @@ class _FriendScreenState extends State<FriendScreen>
|
||||
super.initState();
|
||||
_tabController = TabController(length: 3, vsync: this);
|
||||
|
||||
loadRelations().then((_) {
|
||||
if (filterByStatus(0).isEmpty) {
|
||||
_loadRelations().then((_) {
|
||||
if (_filterByStatus(0).isEmpty) {
|
||||
_tabController.animateTo(1);
|
||||
}
|
||||
});
|
||||
@@ -119,6 +122,19 @@ class _FriendScreenState extends State<FriendScreen>
|
||||
appBar: AppBar(
|
||||
centerTitle: false,
|
||||
title: Text('accountFriend'.tr),
|
||||
actions: [
|
||||
if (_isBusy)
|
||||
SizedBox(
|
||||
height: 48,
|
||||
width: 48,
|
||||
child: const CircularProgressIndicator(
|
||||
strokeWidth: 3,
|
||||
).paddingAll(14),
|
||||
),
|
||||
SizedBox(
|
||||
width: SolianTheme.isLargeScreen(context) ? 8 : 16,
|
||||
),
|
||||
],
|
||||
bottom: TabBar(
|
||||
controller: _tabController,
|
||||
tabs: const [
|
||||
@@ -130,52 +146,40 @@ class _FriendScreenState extends State<FriendScreen>
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.add),
|
||||
onPressed: () => promptAddFriend(),
|
||||
onPressed: () => _promptAddFriend(),
|
||||
),
|
||||
body: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
RefreshIndicator(
|
||||
onRefresh: () => loadRelations(),
|
||||
onRefresh: () => _loadRelations(),
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
if (_isBusy)
|
||||
SliverToBoxAdapter(
|
||||
child: const LinearProgressIndicator().animate().scaleX(),
|
||||
),
|
||||
SilverRelativeList(
|
||||
items: filterByStatus(0),
|
||||
onUpdate: () => loadRelations(),
|
||||
items: _filterByStatus(0),
|
||||
onUpdate: () => _loadRelations(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
RefreshIndicator(
|
||||
onRefresh: () => loadRelations(),
|
||||
onRefresh: () => _loadRelations(),
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
if (_isBusy)
|
||||
SliverToBoxAdapter(
|
||||
child: const LinearProgressIndicator().animate().scaleX(),
|
||||
),
|
||||
SilverRelativeList(
|
||||
items: filterByStatus(1),
|
||||
onUpdate: () => loadRelations(),
|
||||
items: _filterByStatus(1),
|
||||
onUpdate: () => _loadRelations(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
RefreshIndicator(
|
||||
onRefresh: () => loadRelations(),
|
||||
onRefresh: () => _loadRelations(),
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
if (_isBusy)
|
||||
SliverToBoxAdapter(
|
||||
child: const LinearProgressIndicator().animate().scaleX(),
|
||||
),
|
||||
SilverRelativeList(
|
||||
items: filterByStatus(3),
|
||||
onUpdate: () => loadRelations(),
|
||||
items: _filterByStatus(3),
|
||||
onUpdate: () => _loadRelations(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -3,9 +3,11 @@ import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_animate/flutter_animate.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:image_cropper/image_cropper.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:solian/exts.dart';
|
||||
import 'package:solian/models/attachment.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/providers/content/attachment.dart';
|
||||
import 'package:solian/services.dart';
|
||||
@@ -34,7 +36,7 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
|
||||
|
||||
bool _isBusy = false;
|
||||
|
||||
void selectBirthday() async {
|
||||
void _selectBirthday() async {
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: _birthday?.toLocal(),
|
||||
@@ -49,48 +51,73 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
void syncWidget() async {
|
||||
setState(() => _isBusy = true);
|
||||
void _syncWidget() async {
|
||||
_isBusy = true;
|
||||
|
||||
final AuthProvider auth = Get.find();
|
||||
final prof = auth.userProfile.value!;
|
||||
setState(() {
|
||||
_usernameController.text = prof['name'];
|
||||
_nicknameController.text = prof['nick'];
|
||||
_descriptionController.text = prof['description'];
|
||||
_firstNameController.text = prof['profile']['first_name'];
|
||||
_lastNameController.text = prof['profile']['last_name'];
|
||||
_avatar = prof['avatar'];
|
||||
_banner = prof['banner'];
|
||||
if (prof['profile']['birthday'] != null) {
|
||||
_birthday = DateTime.parse(prof['profile']['birthday']);
|
||||
_birthdayController.text =
|
||||
DateFormat('yyyy-MM-dd').format(_birthday!.toLocal());
|
||||
}
|
||||
_usernameController.text = prof['name'];
|
||||
_nicknameController.text = prof['nick'];
|
||||
_descriptionController.text = prof['description'];
|
||||
_firstNameController.text = prof['profile']['first_name'];
|
||||
_lastNameController.text = prof['profile']['last_name'];
|
||||
_avatar = prof['avatar'];
|
||||
_banner = prof['banner'];
|
||||
if (prof['profile']['birthday'] != null) {
|
||||
_birthday = DateTime.parse(prof['profile']['birthday']);
|
||||
_birthdayController.text =
|
||||
DateFormat('yyyy-MM-dd').format(_birthday!.toLocal());
|
||||
}
|
||||
|
||||
_isBusy = false;
|
||||
});
|
||||
_isBusy = false;
|
||||
}
|
||||
|
||||
Future<void> updateImage(String position) async {
|
||||
Future<void> _editImage(String position) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) return;
|
||||
|
||||
final image = await _imagePicker.pickImage(source: ImageSource.gallery);
|
||||
if (image == null) return;
|
||||
|
||||
CroppedFile? croppedFile = await ImageCropper().cropImage(
|
||||
sourcePath: image.path,
|
||||
uiSettings: [
|
||||
AndroidUiSettings(
|
||||
toolbarTitle: 'cropImage'.tr,
|
||||
toolbarColor: Theme.of(context).colorScheme.primary,
|
||||
toolbarWidgetColor: Theme.of(context).colorScheme.onPrimary,
|
||||
aspectRatioPresets: [
|
||||
if (position == 'avatar') CropAspectRatioPreset.square,
|
||||
if (position == 'banner') _BannerCropAspectRatioPreset(),
|
||||
],
|
||||
),
|
||||
IOSUiSettings(
|
||||
title: 'cropImage'.tr,
|
||||
aspectRatioPresets: [
|
||||
if (position == 'avatar') CropAspectRatioPreset.square,
|
||||
if (position == 'banner') _BannerCropAspectRatioPreset(),
|
||||
],
|
||||
),
|
||||
WebUiSettings(
|
||||
context: context,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
if (croppedFile == null) return;
|
||||
final file = File(croppedFile.path);
|
||||
|
||||
setState(() => _isBusy = true);
|
||||
|
||||
final AttachmentProvider provider = Get.find();
|
||||
|
||||
Response? attachResp;
|
||||
Attachment? attachResult;
|
||||
try {
|
||||
final file = File(image.path);
|
||||
attachResp = await provider.createAttachment(
|
||||
attachResult = await provider.createAttachment(
|
||||
await file.readAsBytes(),
|
||||
file.path,
|
||||
'p.$position',
|
||||
null
|
||||
null,
|
||||
);
|
||||
} catch (e) {
|
||||
setState(() => _isBusy = false);
|
||||
@@ -102,10 +129,10 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
|
||||
|
||||
final resp = await client.put(
|
||||
'/users/me/$position',
|
||||
{'attachment': attachResp.body['id']},
|
||||
{'attachment': attachResult.id},
|
||||
);
|
||||
if (resp.statusCode == 200) {
|
||||
syncWidget();
|
||||
_syncWidget();
|
||||
context.showSnackbar('accountPersonalizeApplied'.tr);
|
||||
} else {
|
||||
context.showErrorDialog(resp.bodyString);
|
||||
@@ -114,7 +141,7 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
|
||||
setState(() => _isBusy = false);
|
||||
}
|
||||
|
||||
void updatePersonalize() async {
|
||||
void _editUserInfo() async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) return;
|
||||
|
||||
@@ -134,7 +161,7 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
|
||||
},
|
||||
);
|
||||
if (resp.statusCode == 200) {
|
||||
syncWidget();
|
||||
_syncWidget();
|
||||
context.showSnackbar('accountPersonalizeApplied'.tr);
|
||||
} else {
|
||||
context.showErrorDialog(resp.bodyString);
|
||||
@@ -146,8 +173,7 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
Future.delayed(Duration.zero, () => syncWidget());
|
||||
_syncWidget();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -168,7 +194,7 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
|
||||
left: 40,
|
||||
child: FloatingActionButton.small(
|
||||
heroTag: const Key('avatar-editor'),
|
||||
onPressed: () => updateImage('avatar'),
|
||||
onPressed: () => _editImage('avatar'),
|
||||
child: const Icon(
|
||||
Icons.camera,
|
||||
),
|
||||
@@ -187,7 +213,8 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
child: _banner != null
|
||||
? Image.network(
|
||||
ServiceFinder.buildUrl('files', '/attachments/$_banner'),
|
||||
ServiceFinder.buildUrl(
|
||||
'files', '/attachments/$_banner'),
|
||||
fit: BoxFit.cover,
|
||||
loadingBuilder: (BuildContext context, Widget child,
|
||||
ImageChunkEvent? loadingProgress) {
|
||||
@@ -212,7 +239,7 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
|
||||
right: 16,
|
||||
child: FloatingActionButton(
|
||||
heroTag: const Key('banner-editor'),
|
||||
onPressed: () => updateImage('banner'),
|
||||
onPressed: () => _editImage('banner'),
|
||||
child: const Icon(
|
||||
Icons.camera_alt,
|
||||
),
|
||||
@@ -293,18 +320,18 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
|
||||
border: const OutlineInputBorder(),
|
||||
labelText: 'birthday'.tr,
|
||||
),
|
||||
onTap: () => selectBirthday(),
|
||||
onTap: () => _selectBirthday(),
|
||||
).paddingSymmetric(horizontal: padding),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: _isBusy ? null : () => syncWidget(),
|
||||
onPressed: _isBusy ? null : () => _syncWidget(),
|
||||
child: Text('reset'.tr),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: _isBusy ? null : () => updatePersonalize(),
|
||||
onPressed: _isBusy ? null : () => _editUserInfo(),
|
||||
child: Text('apply'.tr),
|
||||
),
|
||||
],
|
||||
@@ -325,3 +352,11 @@ class _PersonalizeScreenState extends State<PersonalizeScreen> {
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
class _BannerCropAspectRatioPreset extends CropAspectRatioPresetData {
|
||||
@override
|
||||
(int, int)? get data => (16, 7);
|
||||
|
||||
@override
|
||||
String get name => '16x7';
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ import 'package:solian/theme.dart';
|
||||
import 'package:solian/widgets/account/account_avatar.dart';
|
||||
import 'package:solian/widgets/app_bar_leading.dart';
|
||||
import 'package:solian/widgets/attachments/attachment_list.dart';
|
||||
import 'package:solian/widgets/feed/feed_list.dart';
|
||||
import 'package:solian/widgets/posts/post_list.dart';
|
||||
import 'package:solian/widgets/posts/post_warped_list.dart';
|
||||
import 'package:solian/widgets/sized_container.dart';
|
||||
|
||||
class AccountProfilePage extends StatefulWidget {
|
||||
@@ -40,7 +40,7 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
|
||||
List<Post> _pinnedPosts = List.empty();
|
||||
int _totalUpvote = 0, _totalDownvote = 0;
|
||||
|
||||
Future<void> getUserinfo() async {
|
||||
Future<void> _getUserinfo() async {
|
||||
setState(() => _isBusy = true);
|
||||
|
||||
var client = ServiceFinder.configureClient('auth');
|
||||
@@ -114,7 +114,7 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
|
||||
}
|
||||
});
|
||||
|
||||
getUserinfo();
|
||||
_getUserinfo();
|
||||
getPinnedPosts();
|
||||
}
|
||||
|
||||
@@ -189,8 +189,11 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
|
||||
: () async {
|
||||
setState(() => _isMakingFriend = true);
|
||||
try {
|
||||
await _relationshipProvider.makeFriend(widget.name);
|
||||
context.showSnackbar('accountFriendRequestSent'.tr);
|
||||
await _relationshipProvider
|
||||
.makeFriend(widget.name);
|
||||
context.showSnackbar(
|
||||
'accountFriendRequestSent'.tr,
|
||||
);
|
||||
} catch (e) {
|
||||
context.showErrorDialog(e);
|
||||
} finally {
|
||||
@@ -274,6 +277,8 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
|
||||
color:
|
||||
Theme.of(context).colorScheme.surfaceContainerLow,
|
||||
child: PostListEntryWidget(
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.surfaceContainerLow,
|
||||
item: element,
|
||||
isClickable: true,
|
||||
isNestedClickable: true,
|
||||
@@ -292,7 +297,7 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
if (_userinfo != null)
|
||||
FeedListWidget(
|
||||
PostWarpedListWidget(
|
||||
isPinned: false,
|
||||
controller: _postController.pagingController,
|
||||
),
|
||||
|
||||
181
lib/screens/account/stickers.dart
Normal file
@@ -0,0 +1,181 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
||||
import 'package:solian/models/pagination.dart';
|
||||
import 'package:solian/models/stickers.dart';
|
||||
import 'package:solian/platform.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/providers/stickers.dart';
|
||||
import 'package:solian/services.dart';
|
||||
import 'package:solian/widgets/stickers/sticker_uploader.dart';
|
||||
|
||||
class StickerScreen extends StatefulWidget {
|
||||
const StickerScreen({super.key});
|
||||
|
||||
@override
|
||||
State<StickerScreen> createState() => _StickerScreenState();
|
||||
}
|
||||
|
||||
class _StickerScreenState extends State<StickerScreen> {
|
||||
final PagingController<int, StickerPack> _pagingController =
|
||||
PagingController(firstPageKey: 0);
|
||||
|
||||
Future<bool> _promptDelete(Sticker item, String prefix) async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) return false;
|
||||
|
||||
final confirm = await showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('stickerDeletionConfirm'.tr),
|
||||
content: Text(
|
||||
'stickerDeletionConfirmCaption'.trParams({
|
||||
'name': ':${'$prefix${item.alias}'.camelCase}:',
|
||||
}),
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text('cancel'.tr),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: Text('confirm'.tr),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (confirm != true) return false;
|
||||
|
||||
final client = auth.configureClient('files');
|
||||
final resp = await client.delete('/stickers/${item.id}');
|
||||
|
||||
return resp.statusCode == 200;
|
||||
}
|
||||
|
||||
Future<bool?> _promptUploadSticker({Sticker? edit}) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => StickerUploadDialog(
|
||||
edit: edit,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEmoteEntry(Sticker item, String prefix) {
|
||||
final imageUrl = ServiceFinder.buildUrl(
|
||||
'files',
|
||||
'/attachments/${item.attachmentId}',
|
||||
);
|
||||
return ListTile(
|
||||
title: Text(item.name),
|
||||
subtitle: Text(':${'$prefix${item.alias}'.camelCase}:'),
|
||||
contentPadding: const EdgeInsets.only(left: 16, right: 14),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.edit_square),
|
||||
onPressed: () {
|
||||
_promptUploadSticker(edit: item).then((value) {
|
||||
if (value == true) _pagingController.refresh();
|
||||
});
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete),
|
||||
onPressed: () {
|
||||
_promptDelete(item, prefix).then((value) {
|
||||
if (value == true) _pagingController.refresh();
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
leading: PlatformInfo.canCacheImage
|
||||
? CachedNetworkImage(
|
||||
imageUrl: imageUrl,
|
||||
width: 28,
|
||||
height: 28,
|
||||
)
|
||||
: Image.network(
|
||||
imageUrl,
|
||||
width: 28,
|
||||
height: 28,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
final AuthProvider auth = Get.find();
|
||||
final name = auth.userProfile.value!['name'];
|
||||
_pagingController.addPageRequestListener((pageKey) async {
|
||||
final client = ServiceFinder.configureClient('files');
|
||||
final resp = await client.get(
|
||||
'/stickers/manifest?take=10&offset=$pageKey&author=$name',
|
||||
);
|
||||
if (resp.statusCode == 200) {
|
||||
final result = PaginationResult.fromJson(resp.body);
|
||||
final out = result.data?.map((e) => StickerPack.fromJson(e)).toList();
|
||||
if (out != null && result.data!.length >= 10) {
|
||||
_pagingController.appendPage(out, pageKey + out.length);
|
||||
} else if (out != null) {
|
||||
_pagingController.appendLastPage(out);
|
||||
}
|
||||
} else {
|
||||
_pagingController.error = resp.bodyString;
|
||||
}
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
final StickerProvider sticker = Get.find();
|
||||
sticker.refreshAvailableStickers();
|
||||
_pagingController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.add),
|
||||
onPressed: () {
|
||||
_promptUploadSticker().then((value) {
|
||||
if (value == true) _pagingController.refresh();
|
||||
});
|
||||
},
|
||||
),
|
||||
body: RefreshIndicator(
|
||||
onRefresh: () => Future.sync(() => _pagingController.refresh()),
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
PagedSliverList<int, StickerPack>(
|
||||
pagingController: _pagingController,
|
||||
builderDelegate: PagedChildBuilderDelegate(
|
||||
itemBuilder: (BuildContext context, item, int index) {
|
||||
return ExpansionTile(
|
||||
title: Text(item.name),
|
||||
subtitle: Text(
|
||||
item.description,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
children: item.stickers
|
||||
?.map((x) => _buildEmoteEntry(x, item.prefix))
|
||||
.toList() ??
|
||||
List.empty(),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:async/async.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/providers/call.dart';
|
||||
@@ -16,11 +17,26 @@ class CallScreen extends StatefulWidget {
|
||||
State<CallScreen> createState() => _CallScreenState();
|
||||
}
|
||||
|
||||
class _CallScreenState extends State<CallScreen> {
|
||||
Timer? timer;
|
||||
String currentDuration = '00:00:00';
|
||||
class _CallScreenState extends State<CallScreen> with TickerProviderStateMixin {
|
||||
Timer? _timer;
|
||||
String _currentDuration = '00:00:00';
|
||||
|
||||
String parseDuration() {
|
||||
int _layoutMode = 0;
|
||||
|
||||
bool _showControls = true;
|
||||
CancelableOperation? _hideControlsOperation;
|
||||
|
||||
late final AnimationController _controlsAnimationController =
|
||||
AnimationController(
|
||||
duration: const Duration(milliseconds: 500),
|
||||
vsync: this,
|
||||
);
|
||||
late final Animation<double> _controlsAnimation = CurvedAnimation(
|
||||
parent: _controlsAnimationController,
|
||||
curve: Curves.fastOutSlowIn,
|
||||
);
|
||||
|
||||
String _parseDuration() {
|
||||
final ChatCallProvider provider = Get.find();
|
||||
if (provider.current.value == null) return '00:00:00';
|
||||
Duration duration =
|
||||
@@ -34,9 +50,142 @@ class _CallScreenState extends State<CallScreen> {
|
||||
return formattedTime;
|
||||
}
|
||||
|
||||
void updateDuration() {
|
||||
void _updateDuration() {
|
||||
setState(() {
|
||||
currentDuration = parseDuration();
|
||||
_currentDuration = _parseDuration();
|
||||
});
|
||||
}
|
||||
|
||||
void _switchLayout() {
|
||||
if (_layoutMode < 1) {
|
||||
setState(() => _layoutMode++);
|
||||
} else {
|
||||
setState(() => _layoutMode = 0);
|
||||
}
|
||||
}
|
||||
|
||||
void _toggleControls() {
|
||||
if (_showControls) {
|
||||
setState(() => _showControls = false);
|
||||
_controlsAnimationController.animateTo(0);
|
||||
_hideControlsOperation?.cancel();
|
||||
} else {
|
||||
setState(() => _showControls = true);
|
||||
_controlsAnimationController.animateTo(1);
|
||||
_planAutoHideControls();
|
||||
}
|
||||
}
|
||||
|
||||
void _planAutoHideControls() {
|
||||
_hideControlsOperation = CancelableOperation.fromFuture(
|
||||
Future.delayed(const Duration(seconds: 3), () {
|
||||
if (!mounted) return;
|
||||
if (_showControls) _toggleControls();
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildListLayout() {
|
||||
final ChatCallProvider call = Get.find();
|
||||
return Obx(
|
||||
() => Stack(
|
||||
children: [
|
||||
Container(
|
||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||
child: call.focusTrack.value != null
|
||||
? InteractiveParticipantWidget(
|
||||
isFixedAvatar: false,
|
||||
participant: call.focusTrack.value!,
|
||||
onTap: () {},
|
||||
)
|
||||
: const SizedBox(),
|
||||
),
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
child: SizedBox(
|
||||
height: 128,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: math.max(0, call.participantTracks.length),
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final track = call.participantTracks[index];
|
||||
if (track.participant.sid ==
|
||||
call.focusTrack.value?.participant.sid) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 8, left: 8),
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
child: InteractiveParticipantWidget(
|
||||
isFixedAvatar: true,
|
||||
width: 120,
|
||||
height: 120,
|
||||
color: Theme.of(context).cardColor,
|
||||
participant: track,
|
||||
onTap: () {
|
||||
if (track.participant.sid !=
|
||||
call.focusTrack.value?.participant.sid) {
|
||||
call.changeFocusTrack(track);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildGridLayout() {
|
||||
final ChatCallProvider call = Get.find();
|
||||
return LayoutBuilder(builder: (context, constraints) {
|
||||
double screenWidth = constraints.maxWidth;
|
||||
double screenHeight = constraints.maxHeight;
|
||||
|
||||
int columns = (math.sqrt(call.participantTracks.length)).ceil();
|
||||
int rows = (call.participantTracks.length / columns).ceil();
|
||||
|
||||
double tileWidth = screenWidth / columns;
|
||||
double tileHeight = screenHeight / rows;
|
||||
|
||||
return Obx(
|
||||
() => GridView.builder(
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: columns,
|
||||
childAspectRatio: tileWidth / tileHeight,
|
||||
),
|
||||
itemCount: math.max(0, call.participantTracks.length),
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final track = call.participantTracks[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Card(
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
child: InteractiveParticipantWidget(
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
participant: track,
|
||||
onTap: () {
|
||||
if (track.participant.sid !=
|
||||
call.focusTrack.value?.participant.sid) {
|
||||
call.changeFocusTrack(track);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -45,7 +194,18 @@ class _CallScreenState extends State<CallScreen> {
|
||||
Get.find<ChatCallProvider>().setupRoom();
|
||||
super.initState();
|
||||
|
||||
timer = Timer.periodic(const Duration(seconds: 1), (_) => updateDuration());
|
||||
_updateDuration();
|
||||
_planAutoHideControls();
|
||||
_timer = Timer.periodic(
|
||||
const Duration(seconds: 1),
|
||||
(_) => _updateDuration(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controlsAnimationController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -68,80 +228,71 @@ class _CallScreenState extends State<CallScreen> {
|
||||
),
|
||||
const TextSpan(text: '\n'),
|
||||
TextSpan(
|
||||
text: currentDuration,
|
||||
text: _currentDuration,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Obx(
|
||||
() => Stack(
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
child: Column(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||
child: provider.focusTrack.value != null
|
||||
? InteractiveParticipantWidget(
|
||||
isFixed: false,
|
||||
participant: provider.focusTrack.value!,
|
||||
onTap: () {},
|
||||
)
|
||||
: const SizedBox(),
|
||||
),
|
||||
),
|
||||
if (provider.room.localParticipant != null)
|
||||
ControlsWidget(
|
||||
provider.room,
|
||||
provider.room.localParticipant!,
|
||||
),
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
SizeTransition(
|
||||
sizeFactor: _controlsAnimation,
|
||||
axis: Axis.vertical,
|
||||
child: SizedBox(
|
||||
height: 128,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: math.max(0, provider.participantTracks.length),
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final track = provider.participantTracks[index];
|
||||
if (track.participant.sid ==
|
||||
provider.focusTrack.value?.participant.sid) {
|
||||
return Container();
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: 64,
|
||||
child: Row(
|
||||
children: [
|
||||
const Expanded(child: SizedBox()),
|
||||
IconButton(
|
||||
icon: _layoutMode == 0
|
||||
? const Icon(Icons.view_list)
|
||||
: const Icon(Icons.grid_view),
|
||||
onPressed: () {
|
||||
_switchLayout();
|
||||
},
|
||||
),
|
||||
],
|
||||
).paddingSymmetric(horizontal: 10),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Material(
|
||||
color: Theme.of(context).colorScheme.surfaceContainerLow,
|
||||
elevation: 2,
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
switch (_layoutMode) {
|
||||
case 1:
|
||||
return _buildGridLayout();
|
||||
default:
|
||||
return _buildListLayout();
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 8, left: 8),
|
||||
child: ClipRRect(
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(8)),
|
||||
child: InteractiveParticipantWidget(
|
||||
isFixed: true,
|
||||
width: 120,
|
||||
height: 120,
|
||||
color: Theme.of(context).cardColor,
|
||||
participant: track,
|
||||
onTap: () {
|
||||
if (track.participant.sid !=
|
||||
provider
|
||||
.focusTrack.value?.participant.sid) {
|
||||
provider.changeFocusTrack(track);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
if (provider.room.localParticipant != null)
|
||||
SizeTransition(
|
||||
sizeFactor: _controlsAnimation,
|
||||
axis: Axis.vertical,
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: ControlsWidget(
|
||||
provider.room,
|
||||
provider.room.localParticipant!,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
_toggleControls();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -150,16 +301,16 @@ class _CallScreenState extends State<CallScreen> {
|
||||
|
||||
@override
|
||||
void deactivate() {
|
||||
timer?.cancel();
|
||||
timer = null;
|
||||
_timer?.cancel();
|
||||
_timer = null;
|
||||
super.deactivate();
|
||||
}
|
||||
|
||||
@override
|
||||
void activate() {
|
||||
timer ??= Timer.periodic(
|
||||
_timer ??= Timer.periodic(
|
||||
const Duration(seconds: 1),
|
||||
(_) => updateDuration(),
|
||||
(_) => _updateDuration(),
|
||||
);
|
||||
super.activate();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import 'package:solian/models/channel.dart';
|
||||
import 'package:solian/models/event.dart';
|
||||
import 'package:solian/models/packet.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/providers/call.dart';
|
||||
import 'package:solian/providers/content/channel.dart';
|
||||
import 'package:solian/providers/websocket.dart';
|
||||
import 'package:solian/router.dart';
|
||||
@@ -19,7 +18,7 @@ import 'package:solian/screens/channel/channel_detail.dart';
|
||||
import 'package:solian/theme.dart';
|
||||
import 'package:solian/widgets/app_bar_leading.dart';
|
||||
import 'package:solian/widgets/app_bar_title.dart';
|
||||
import 'package:solian/widgets/chat/call/call_prejoin.dart';
|
||||
import 'package:solian/widgets/channel/channel_call_indicator.dart';
|
||||
import 'package:solian/widgets/chat/call/chat_call_action.dart';
|
||||
import 'package:solian/widgets/chat/chat_event.dart';
|
||||
import 'package:solian/widgets/chat/chat_event_list.dart';
|
||||
@@ -53,7 +52,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
|
||||
late final ChatEventController _chatController;
|
||||
|
||||
getChannel({String? alias}) async {
|
||||
_getChannel({String? alias}) async {
|
||||
final ChannelProvider provider = Get.find();
|
||||
|
||||
setState(() => _isBusy = true);
|
||||
@@ -80,7 +79,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
setState(() => _isBusy = false);
|
||||
}
|
||||
|
||||
getOngoingCall() async {
|
||||
_getOngoingCall() async {
|
||||
final ChannelProvider provider = Get.find();
|
||||
|
||||
setState(() => _isBusy = true);
|
||||
@@ -100,7 +99,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
setState(() => _isBusy = false);
|
||||
}
|
||||
|
||||
void listenMessages() {
|
||||
void _listenMessages() {
|
||||
final WebSocketProvider provider = Get.find();
|
||||
_subscription = provider.stream.stream.listen((event) {
|
||||
switch (event.method) {
|
||||
@@ -110,26 +109,20 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
break;
|
||||
case 'calls.new':
|
||||
final payload = Call.fromJson(event.payload!);
|
||||
setState(() => _ongoingCall = payload);
|
||||
if (payload.channel.id == _channel!.id) {
|
||||
setState(() => _ongoingCall = payload);
|
||||
}
|
||||
break;
|
||||
case 'calls.end':
|
||||
setState(() => _ongoingCall = null);
|
||||
final payload = Call.fromJson(event.payload!);
|
||||
if (payload.channel.id == _channel!.id) {
|
||||
setState(() => _ongoingCall = null);
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void showCallPrejoin() {
|
||||
showModalBottomSheet(
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
builder: (context) => ChatCallPrejoinPopup(
|
||||
ongoingCall: _ongoingCall!,
|
||||
channel: _channel!,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Event? _messageToReplying;
|
||||
Event? _messageToEditing;
|
||||
|
||||
@@ -149,13 +142,12 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
_chatController = ChatEventController();
|
||||
_chatController.initialize();
|
||||
|
||||
getChannel().then((_) {
|
||||
_getOngoingCall();
|
||||
_getChannel().then((_) {
|
||||
_chatController.getEvents(_channel!, widget.realm);
|
||||
listenMessages();
|
||||
_listenMessages();
|
||||
});
|
||||
|
||||
getOngoingCall();
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@@ -183,8 +175,6 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
final ChatCallProvider call = Get.find();
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: AppBarLeadingButton.adaptive(context),
|
||||
@@ -219,7 +209,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
if (value == false) AppRouter.instance.pop();
|
||||
if (value != null) {
|
||||
final resp = Channel.fromJson(value as Map<String, dynamic>);
|
||||
getChannel(alias: resp.alias);
|
||||
_getChannel(alias: resp.alias);
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -232,32 +222,9 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
body: Column(
|
||||
children: [
|
||||
if (_ongoingCall != null)
|
||||
MaterialBanner(
|
||||
padding: const EdgeInsets.only(left: 16, top: 4, bottom: 4),
|
||||
leading: const Icon(Icons.call_received),
|
||||
backgroundColor: Theme.of(context).colorScheme.surfaceContainer,
|
||||
dividerColor: Colors.transparent,
|
||||
content: Text('callOngoing'.tr),
|
||||
actions: [
|
||||
Obx(() {
|
||||
if (call.current.value == null) {
|
||||
return TextButton(
|
||||
onPressed: showCallPrejoin,
|
||||
child: Text('callJoin'.tr),
|
||||
);
|
||||
} else if (call.channel.value?.id == _channel?.id) {
|
||||
return TextButton(
|
||||
onPressed: () => call.gotoScreen(context),
|
||||
child: Text('callResume'.tr),
|
||||
);
|
||||
} else {
|
||||
return TextButton(
|
||||
onPressed: null,
|
||||
child: Text('callJoin'.tr),
|
||||
);
|
||||
}
|
||||
})
|
||||
],
|
||||
ChannelCallIndicator(
|
||||
channel: _channel!,
|
||||
ongoingCall: _ongoingCall!,
|
||||
),
|
||||
Expanded(
|
||||
child: ChatEventList(
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:get/get.dart';
|
||||
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
||||
import 'package:solian/models/pagination.dart';
|
||||
import 'package:solian/providers/content/posts.dart';
|
||||
import 'package:solian/widgets/feed/feed_list.dart';
|
||||
import 'package:solian/widgets/posts/post_warped_list.dart';
|
||||
|
||||
import '../../models/post.dart';
|
||||
|
||||
@@ -77,7 +77,7 @@ class _FeedSearchScreenState extends State<FeedSearchScreen> {
|
||||
onRefresh: () => Future.sync(() => _pagingController.refresh()),
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
FeedListWidget(controller: _pagingController),
|
||||
PostWarpedListWidget(controller: _pagingController),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -4,12 +4,13 @@ import 'package:solian/controllers/post_list_controller.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/router.dart';
|
||||
import 'package:solian/screens/account/notification.dart';
|
||||
import 'package:solian/screens/posts/post_editor.dart';
|
||||
import 'package:solian/theme.dart';
|
||||
import 'package:solian/widgets/app_bar_title.dart';
|
||||
import 'package:solian/widgets/current_state_action.dart';
|
||||
import 'package:solian/widgets/app_bar_leading.dart';
|
||||
import 'package:solian/widgets/feed/feed_list.dart';
|
||||
import 'package:solian/widgets/posts/post_shuffle_swiper.dart';
|
||||
import 'package:solian/widgets/posts/post_warped_list.dart';
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
const HomeScreen({super.key});
|
||||
@@ -51,7 +52,9 @@ class _HomeScreenState extends State<HomeScreen>
|
||||
useRootNavigator: true,
|
||||
isScrollControlled: true,
|
||||
context: context,
|
||||
builder: (context) => const PostCreatePopup(),
|
||||
builder: (context) => PostCreatePopup(
|
||||
controller: _postController,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -95,7 +98,7 @@ class _HomeScreenState extends State<HomeScreen>
|
||||
RefreshIndicator(
|
||||
onRefresh: () => _postController.reloadAllOver(),
|
||||
child: CustomScrollView(slivers: [
|
||||
FeedListWidget(
|
||||
PostWarpedListWidget(
|
||||
controller: _postController.pagingController,
|
||||
),
|
||||
]),
|
||||
@@ -118,12 +121,12 @@ class _HomeScreenState extends State<HomeScreen>
|
||||
|
||||
class PostCreatePopup extends StatelessWidget {
|
||||
final bool hideDraftBox;
|
||||
final Function? onCreated;
|
||||
final PostListController controller;
|
||||
|
||||
const PostCreatePopup({
|
||||
super.key,
|
||||
this.hideDraftBox = false,
|
||||
this.onCreated,
|
||||
required this.controller,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -140,11 +143,13 @@ class PostCreatePopup extends StatelessWidget {
|
||||
label: 'postEditorModeStory'.tr,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
AppRouter.instance.pushNamed('postEditor', queryParameters: {
|
||||
'mode': 0.toString(),
|
||||
}).then((val) {
|
||||
if (val != null && onCreated != null) onCreated!();
|
||||
});
|
||||
AppRouter.instance.pushNamed(
|
||||
'postEditor',
|
||||
extra: PostPublishArguments(postListController: controller),
|
||||
queryParameters: {
|
||||
'mode': 0.toString(),
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
(
|
||||
@@ -152,11 +157,13 @@ class PostCreatePopup extends StatelessWidget {
|
||||
label: 'postEditorModeArticle'.tr,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
AppRouter.instance.pushNamed('postEditor', queryParameters: {
|
||||
'mode': 1.toString(),
|
||||
}).then((val) {
|
||||
if (val != null && onCreated != null) onCreated!();
|
||||
});
|
||||
AppRouter.instance.pushNamed(
|
||||
'postEditor',
|
||||
extra: PostPublishArguments(postListController: controller),
|
||||
queryParameters: {
|
||||
'mode': 1.toString(),
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
(
|
||||
|
||||
@@ -3,14 +3,18 @@ import 'package:get/get.dart';
|
||||
import 'package:solian/exts.dart';
|
||||
import 'package:solian/models/post.dart';
|
||||
import 'package:solian/providers/content/posts.dart';
|
||||
import 'package:solian/widgets/sized_container.dart';
|
||||
import 'package:solian/widgets/posts/post_item.dart';
|
||||
import 'package:solian/widgets/posts/post_replies.dart';
|
||||
|
||||
class PostDetailScreen extends StatefulWidget {
|
||||
final String id;
|
||||
final Post? post;
|
||||
|
||||
const PostDetailScreen({super.key, required this.id});
|
||||
const PostDetailScreen({
|
||||
super.key,
|
||||
required this.id,
|
||||
this.post,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PostDetailScreen> createState() => _PostDetailScreenState();
|
||||
@@ -20,6 +24,11 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
||||
Post? item;
|
||||
|
||||
Future<Post?> getDetail() async {
|
||||
if (widget.post != null) {
|
||||
item = widget.post;
|
||||
return widget.post;
|
||||
}
|
||||
|
||||
final PostProvider provider = Get.find();
|
||||
|
||||
try {
|
||||
@@ -48,14 +57,12 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: CenteredContainer(
|
||||
child: PostItem(
|
||||
item: item!,
|
||||
isClickable: true,
|
||||
isFullDate: true,
|
||||
isShowReply: false,
|
||||
isContentSelectable: true,
|
||||
),
|
||||
child: PostItem(
|
||||
item: item!,
|
||||
isClickable: true,
|
||||
isFullDate: true,
|
||||
isShowReply: false,
|
||||
isContentSelectable: true,
|
||||
),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
@@ -63,14 +70,12 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
||||
.paddingOnly(top: 4),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: CenteredContainer(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
'postReplies'.tr,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
).paddingOnly(left: 24, right: 24, top: 16),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
'postReplies'.tr,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
).paddingOnly(left: 24, right: 24, top: 16),
|
||||
),
|
||||
),
|
||||
PostReplyList(item: item!),
|
||||
|
||||
@@ -3,10 +3,13 @@ import 'package:flutter_animate/flutter_animate.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:markdown_toolbar/markdown_toolbar.dart';
|
||||
import 'package:solian/controllers/post_editor_controller.dart';
|
||||
import 'package:solian/controllers/post_list_controller.dart';
|
||||
import 'package:solian/exts.dart';
|
||||
import 'package:solian/models/post.dart';
|
||||
import 'package:solian/models/realm.dart';
|
||||
import 'package:solian/providers/attachment_uploader.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/router.dart';
|
||||
import 'package:solian/theme.dart';
|
||||
@@ -20,8 +23,15 @@ class PostPublishArguments {
|
||||
final Post? reply;
|
||||
final Post? repost;
|
||||
final Realm? realm;
|
||||
final PostListController? postListController;
|
||||
|
||||
PostPublishArguments({this.edit, this.reply, this.repost, this.realm});
|
||||
PostPublishArguments({
|
||||
this.edit,
|
||||
this.reply,
|
||||
this.repost,
|
||||
this.realm,
|
||||
this.postListController,
|
||||
});
|
||||
}
|
||||
|
||||
class PostPublishScreen extends StatefulWidget {
|
||||
@@ -29,6 +39,7 @@ class PostPublishScreen extends StatefulWidget {
|
||||
final Post? reply;
|
||||
final Post? repost;
|
||||
final Realm? realm;
|
||||
final PostListController? postListController;
|
||||
final int mode;
|
||||
|
||||
const PostPublishScreen({
|
||||
@@ -37,6 +48,7 @@ class PostPublishScreen extends StatefulWidget {
|
||||
this.reply,
|
||||
this.repost,
|
||||
this.realm,
|
||||
this.postListController,
|
||||
required this.mode,
|
||||
});
|
||||
|
||||
@@ -46,6 +58,7 @@ class PostPublishScreen extends StatefulWidget {
|
||||
|
||||
class _PostPublishScreenState extends State<PostPublishScreen> {
|
||||
final _editorController = PostEditorController();
|
||||
final _contentFocusNode = FocusNode();
|
||||
|
||||
bool _isBusy = false;
|
||||
|
||||
@@ -54,6 +67,14 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
||||
if (auth.isAuthorized.isFalse) return;
|
||||
if (_editorController.isEmpty) return;
|
||||
|
||||
final AttachmentUploaderController uploader = Get.find();
|
||||
if (uploader.queueOfUpload.any(
|
||||
((x) => x.usage == 'i.attachment' && x.isUploading),
|
||||
)) {
|
||||
context.showErrorDialog('attachmentUploadInProgress'.tr);
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() => _isBusy = true);
|
||||
|
||||
final client = auth.configureClient('interactive');
|
||||
@@ -74,34 +95,57 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
||||
context.showErrorDialog(resp.bodyString);
|
||||
} else {
|
||||
_editorController.localClear();
|
||||
if (widget.postListController != null) {
|
||||
widget.postListController!.reloadAllOver();
|
||||
}
|
||||
AppRouter.instance.pop(resp.body);
|
||||
}
|
||||
|
||||
setState(() => _isBusy = false);
|
||||
}
|
||||
|
||||
void syncWidget() {
|
||||
void _syncWidget() {
|
||||
_editorController.mode.value = widget.mode;
|
||||
if (widget.edit != null) {
|
||||
_editorController.editTarget = widget.edit;
|
||||
}
|
||||
if (widget.realm != null) {
|
||||
_editorController.realmZone.value = widget.realm;
|
||||
}
|
||||
}
|
||||
|
||||
void cancelAction() {
|
||||
void _cancelAction() {
|
||||
_editorController.localClear();
|
||||
AppRouter.instance.pop();
|
||||
}
|
||||
|
||||
Post? get _editTo => _editorController.editTo.value;
|
||||
|
||||
Post? get _replyTo => _editorController.replyTo.value;
|
||||
|
||||
Post? get _repostTo => _editorController.repostTo.value;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
syncWidget();
|
||||
if (widget.edit == null && widget.reply == null && widget.repost == null) {
|
||||
_editorController.localRead();
|
||||
}
|
||||
if (widget.reply != null) {
|
||||
_editorController.replyTo.value = widget.reply;
|
||||
}
|
||||
if (widget.repost != null) {
|
||||
_editorController.repostTo.value = widget.repost;
|
||||
}
|
||||
_editorController.contentController.addListener(() => setState(() {}));
|
||||
_syncWidget();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final notifyBannerActions = [
|
||||
TextButton(
|
||||
onPressed: cancelAction,
|
||||
onPressed: _cancelAction,
|
||||
child: Text('cancel'.tr),
|
||||
)
|
||||
];
|
||||
@@ -134,6 +178,7 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ListTile(
|
||||
tileColor: Theme.of(context).colorScheme.surfaceContainerLow,
|
||||
@@ -162,68 +207,65 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
||||
},
|
||||
),
|
||||
),
|
||||
if (_editTo != null && _editTo!.isDraft != true)
|
||||
MaterialBanner(
|
||||
leading: const Icon(Icons.edit),
|
||||
leadingPadding: const EdgeInsets.only(left: 10, right: 20),
|
||||
dividerColor: Colors.transparent,
|
||||
content: Text('postEditingNotify'.tr),
|
||||
actions: notifyBannerActions,
|
||||
),
|
||||
if (_replyTo != null)
|
||||
ExpansionTile(
|
||||
leading: const FaIcon(
|
||||
FontAwesomeIcons.reply,
|
||||
size: 18,
|
||||
).paddingOnly(left: 2),
|
||||
title: Text('postReplyingNotify'.trParams(
|
||||
{'username': '@${widget.reply!.author.name}'},
|
||||
)),
|
||||
collapsedBackgroundColor:
|
||||
Theme.of(context).colorScheme.surfaceContainer,
|
||||
children: [
|
||||
Container(
|
||||
constraints: const BoxConstraints(maxHeight: 280),
|
||||
child: SingleChildScrollView(
|
||||
child: PostItem(
|
||||
item: _replyTo!,
|
||||
isReactable: false,
|
||||
).paddingOnly(bottom: 8),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (_repostTo != null)
|
||||
ExpansionTile(
|
||||
leading: const FaIcon(
|
||||
FontAwesomeIcons.retweet,
|
||||
size: 18,
|
||||
).paddingOnly(left: 2),
|
||||
title: Text('postRepostingNotify'.trParams(
|
||||
{'username': '@${widget.repost!.author.name}'},
|
||||
)),
|
||||
collapsedBackgroundColor:
|
||||
Theme.of(context).colorScheme.surfaceContainer,
|
||||
children: [
|
||||
Container(
|
||||
constraints: const BoxConstraints(maxHeight: 280),
|
||||
child: SingleChildScrollView(
|
||||
child: PostItem(
|
||||
item: _repostTo!,
|
||||
isReactable: false,
|
||||
).paddingOnly(bottom: 8),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
if (_isBusy)
|
||||
const LinearProgressIndicator().animate().scaleX(),
|
||||
if (widget.edit != null && widget.edit!.isDraft != true)
|
||||
MaterialBanner(
|
||||
leading: const Icon(Icons.edit),
|
||||
leadingPadding:
|
||||
const EdgeInsets.only(left: 10, right: 20),
|
||||
dividerColor: Colors.transparent,
|
||||
content: Text('postEditingNotify'.tr),
|
||||
actions: notifyBannerActions,
|
||||
),
|
||||
if (widget.reply != null)
|
||||
ExpansionTile(
|
||||
leading: const FaIcon(
|
||||
FontAwesomeIcons.reply,
|
||||
size: 18,
|
||||
).paddingOnly(left: 2),
|
||||
title: Text('postReplyingNotify'.trParams(
|
||||
{'username': '@${widget.reply!.author.name}'},
|
||||
)),
|
||||
collapsedBackgroundColor:
|
||||
Theme.of(context).colorScheme.surfaceContainer,
|
||||
children: [
|
||||
PostItem(
|
||||
item: widget.reply!,
|
||||
isReactable: false,
|
||||
).paddingOnly(bottom: 8),
|
||||
],
|
||||
),
|
||||
if (widget.repost != null)
|
||||
ExpansionTile(
|
||||
leading: const FaIcon(
|
||||
FontAwesomeIcons.retweet,
|
||||
size: 18,
|
||||
).paddingOnly(left: 2),
|
||||
title: Text('postRepostingNotify'.trParams(
|
||||
{'username': '@${widget.repost!.author.name}'},
|
||||
)),
|
||||
collapsedBackgroundColor:
|
||||
Theme.of(context).colorScheme.surfaceContainer,
|
||||
children: [
|
||||
PostItem(
|
||||
item: widget.repost!,
|
||||
isReactable: false,
|
||||
).paddingOnly(bottom: 8),
|
||||
],
|
||||
),
|
||||
if (widget.realm != null)
|
||||
MaterialBanner(
|
||||
leading: const Icon(Icons.group),
|
||||
leadingPadding:
|
||||
const EdgeInsets.only(left: 10, right: 20),
|
||||
dividerColor: Colors.transparent,
|
||||
content: Text(
|
||||
'postInRealmNotify'
|
||||
.trParams({'realm': '#${widget.realm!.alias}'}),
|
||||
),
|
||||
actions: notifyBannerActions,
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
@@ -235,8 +277,8 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
||||
autocorrect: true,
|
||||
keyboardType: TextInputType.multiline,
|
||||
controller: _editorController.contentController,
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
focusNode: _contentFocusNode,
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'postContentPlaceholder'.tr,
|
||||
),
|
||||
onTapOutside: (_) =>
|
||||
@@ -383,12 +425,72 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.tag),
|
||||
icon: Obx(() {
|
||||
return badges.Badge(
|
||||
badgeContent: Text(
|
||||
_editorController.tags.length.toString(),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
showBadge: _editorController.tags.isNotEmpty,
|
||||
position: badges.BadgePosition.topEnd(
|
||||
top: -12,
|
||||
end: -8,
|
||||
),
|
||||
child: const Icon(Icons.label),
|
||||
);
|
||||
}),
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
onPressed: () {
|
||||
_editorController.editCategoriesAndTags(context);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: Obx(() {
|
||||
return badges.Badge(
|
||||
showBadge:
|
||||
_editorController.realmZone.value != null,
|
||||
position: badges.BadgePosition.topEnd(
|
||||
top: -4,
|
||||
end: -6,
|
||||
),
|
||||
child: const Icon(Icons.workspaces),
|
||||
);
|
||||
}),
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
onPressed: () {
|
||||
_editorController.editPublishZone(context);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: Obx(() {
|
||||
return badges.Badge(
|
||||
showBadge:
|
||||
_editorController.publishedAt.value != null ||
|
||||
_editorController.publishedUntil.value !=
|
||||
null,
|
||||
position: badges.BadgePosition.topEnd(
|
||||
top: -4,
|
||||
end: -6,
|
||||
),
|
||||
child: const Icon(Icons.schedule),
|
||||
);
|
||||
}),
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
onPressed: () {
|
||||
_editorController.editPublishDate(context);
|
||||
},
|
||||
),
|
||||
MarkdownToolbar(
|
||||
hideImage: true,
|
||||
useIncludedTextField: false,
|
||||
backgroundColor: Colors.transparent,
|
||||
iconColor: Theme.of(context).colorScheme.onSurface,
|
||||
controller: _editorController.contentController,
|
||||
focusNode: _contentFocusNode,
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(20)),
|
||||
width: 40,
|
||||
).paddingSymmetric(horizontal: 4),
|
||||
],
|
||||
).paddingSymmetric(horizontal: 6, vertical: 8),
|
||||
),
|
||||
@@ -403,6 +505,7 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_contentFocusNode.dispose();
|
||||
_editorController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class _RealmListScreenState extends State<RealmListScreen> {
|
||||
|
||||
final List<Realm> _realms = List.empty(growable: true);
|
||||
|
||||
getRealms() async {
|
||||
_getRealms() async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (auth.isAuthorized.isFalse) return;
|
||||
|
||||
@@ -48,7 +48,7 @@ class _RealmListScreenState extends State<RealmListScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
getRealms();
|
||||
_getRealms();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -71,7 +71,7 @@ class _RealmListScreenState extends State<RealmListScreen> {
|
||||
onPressed: () {
|
||||
AppRouter.instance.pushNamed('realmOrganizing').then(
|
||||
(value) {
|
||||
if (value != null) getRealms();
|
||||
if (value != null) _getRealms();
|
||||
},
|
||||
);
|
||||
},
|
||||
@@ -84,7 +84,7 @@ class _RealmListScreenState extends State<RealmListScreen> {
|
||||
body: Obx(() {
|
||||
if (auth.isAuthorized.isFalse) {
|
||||
return SigninRequiredOverlay(
|
||||
onSignedIn: () => getRealms(),
|
||||
onSignedIn: () => _getRealms(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -94,12 +94,12 @@ class _RealmListScreenState extends State<RealmListScreen> {
|
||||
Expanded(
|
||||
child: CenteredContainer(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () => getRealms(),
|
||||
onRefresh: () => _getRealms(),
|
||||
child: ListView.builder(
|
||||
itemCount: _realms.length,
|
||||
itemBuilder: (context, index) {
|
||||
final element = _realms[index];
|
||||
return buildRealm(element);
|
||||
return _buildEntry(element);
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -112,7 +112,7 @@ class _RealmListScreenState extends State<RealmListScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildRealm(Realm element) {
|
||||
Widget _buildEntry(Realm element) {
|
||||
return Card(
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
|
||||
@@ -12,7 +12,6 @@ import 'package:solian/providers/content/posts.dart';
|
||||
import 'package:solian/providers/content/realm.dart';
|
||||
import 'package:solian/router.dart';
|
||||
import 'package:solian/screens/channel/channel_organize.dart';
|
||||
import 'package:solian/screens/posts/post_editor.dart';
|
||||
import 'package:solian/theme.dart';
|
||||
import 'package:solian/widgets/app_bar_leading.dart';
|
||||
import 'package:solian/widgets/channel/channel_list.dart';
|
||||
@@ -136,6 +135,7 @@ class _RealmViewScreenState extends State<RealmViewScreen> {
|
||||
}
|
||||
|
||||
return TabBarView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: [
|
||||
RealmPostListWidget(realm: _realm!),
|
||||
RealmChannelListWidget(
|
||||
@@ -189,7 +189,6 @@ class _RealmPostListWidgetState extends State<RealmPostListWidget> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_pagingController.addPageRequestListener(getPosts);
|
||||
}
|
||||
|
||||
@@ -199,28 +198,6 @@ class _RealmPostListWidgetState extends State<RealmPostListWidget> {
|
||||
onRefresh: () => Future.sync(() => _pagingController.refresh()),
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.post_add),
|
||||
contentPadding: const EdgeInsets.only(left: 24, right: 8),
|
||||
tileColor: Theme.of(context).colorScheme.surfaceContainer,
|
||||
title: Text('postNew'.tr),
|
||||
subtitle: Text(
|
||||
'postNewInRealmHint'
|
||||
.trParams({'realm': '#${widget.realm.alias}'}),
|
||||
),
|
||||
onTap: () {
|
||||
AppRouter.instance
|
||||
.pushNamed(
|
||||
'postEditor',
|
||||
extra: PostPublishArguments(realm: widget.realm),
|
||||
)
|
||||
.then((value) {
|
||||
if (value != null) _pagingController.refresh();
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
PostListWidget(controller: _pagingController),
|
||||
],
|
||||
),
|
||||
|
||||
102
lib/screens/settings.dart
Normal file
@@ -0,0 +1,102 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:solian/exts.dart';
|
||||
import 'package:solian/providers/theme_switcher.dart';
|
||||
import 'package:solian/router.dart';
|
||||
import 'package:solian/theme.dart';
|
||||
|
||||
class SettingScreen extends StatefulWidget {
|
||||
const SettingScreen({super.key});
|
||||
|
||||
@override
|
||||
State<SettingScreen> createState() => _SettingScreenState();
|
||||
}
|
||||
|
||||
class _SettingScreenState extends State<SettingScreen> {
|
||||
late final SharedPreferences _prefs;
|
||||
|
||||
Widget _buildCaptionHeader(String title) {
|
||||
return Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||
child: Text(title),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildThemeColorButton(String label, Color color) {
|
||||
return IconButton(
|
||||
icon: Icon(Icons.circle, color: color),
|
||||
tooltip: label,
|
||||
onPressed: () {
|
||||
context.read<ThemeSwitcher>().setTheme(
|
||||
SolianTheme.build(
|
||||
Brightness.light,
|
||||
seedColor: color,
|
||||
),
|
||||
SolianTheme.build(
|
||||
Brightness.dark,
|
||||
seedColor: color,
|
||||
),
|
||||
);
|
||||
_prefs.setInt('global_theme_color', color.value);
|
||||
context.clearSnackbar();
|
||||
context.showSnackbar('themeColorApplied'.tr);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
static final List<(String, Color)> _presentTheme = [
|
||||
('themeColorRed', const Color.fromRGBO(154, 98, 91, 1)),
|
||||
('themeColorBlue', const Color.fromRGBO(103, 96, 193, 1)),
|
||||
('themeColorMiku', const Color.fromRGBO(56, 120, 126, 1)),
|
||||
('themeColorKagamine', const Color.fromRGBO(244, 183, 63, 1)),
|
||||
('themeColorLuka', const Color.fromRGBO(243, 174, 218, 1)),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
SharedPreferences.getInstance().then((inst) {
|
||||
_prefs = inst;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: ListView(
|
||||
children: [
|
||||
_buildCaptionHeader('themeColor'.tr),
|
||||
SizedBox(
|
||||
height: 56,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
children: _presentTheme
|
||||
.map((x) => _buildThemeColorButton(x.$1, x.$2))
|
||||
.toList(),
|
||||
).paddingSymmetric(horizontal: 12, vertical: 8),
|
||||
),
|
||||
_buildCaptionHeader('more'.tr),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
TextButton(
|
||||
style: const ButtonStyle(
|
||||
visualDensity: VisualDensity(horizontal: -4, vertical: -4),
|
||||
),
|
||||
child: Text('about'.tr),
|
||||
onPressed: () {
|
||||
AppRouter.instance.pushNamed('about');
|
||||
},
|
||||
),
|
||||
],
|
||||
).paddingSymmetric(horizontal: 12, vertical: 8),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,15 @@ import 'package:solian/widgets/app_bar_leading.dart';
|
||||
class TitleShell extends StatelessWidget {
|
||||
final bool showAppBar;
|
||||
final bool isCenteredTitle;
|
||||
final GoRouterState state;
|
||||
final String? title;
|
||||
final GoRouterState? state;
|
||||
final Widget child;
|
||||
|
||||
const TitleShell({
|
||||
super.key,
|
||||
required this.child,
|
||||
required this.state,
|
||||
this.title,
|
||||
this.state,
|
||||
this.showAppBar = true,
|
||||
this.isCenteredTitle = false,
|
||||
});
|
||||
@@ -25,7 +27,9 @@ class TitleShell extends StatelessWidget {
|
||||
appBar: showAppBar
|
||||
? AppBar(
|
||||
leading: AppBarLeadingButton.adaptive(context),
|
||||
title: AppBarTitle(state.topRoute?.name?.tr ?? 'page'.tr),
|
||||
title: AppBarTitle(
|
||||
title ?? (state!.topRoute?.name?.tr ?? 'page'.tr),
|
||||
),
|
||||
centerTitle: isCenteredTitle,
|
||||
toolbarHeight: SolianTheme.toolbarHeight(context),
|
||||
)
|
||||
|
||||
@@ -27,13 +27,25 @@ abstract class SolianTheme {
|
||||
}
|
||||
}
|
||||
|
||||
static ThemeData build(Brightness brightness) {
|
||||
static ThemeData build(Brightness brightness, {Color? seedColor}) {
|
||||
return ThemeData(
|
||||
brightness: brightness,
|
||||
useMaterial3: true,
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
brightness: brightness,
|
||||
seedColor: const Color.fromRGBO(154, 98, 91, 1),
|
||||
seedColor: seedColor ?? const Color.fromRGBO(154, 98, 91, 1),
|
||||
),
|
||||
fontFamily: 'Comfortaa',
|
||||
fontFamilyFallback: [
|
||||
'NotoSansSC',
|
||||
'NotoSansHK',
|
||||
'NotoSansJP',
|
||||
if (PlatformInfo.isWeb) 'NotoSansEmoji',
|
||||
],
|
||||
typography: Typography.material2021(
|
||||
colorScheme: brightness == Brightness.light
|
||||
? const ColorScheme.light()
|
||||
: const ColorScheme.dark(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,8 +10,10 @@ const i18nEnglish = {
|
||||
'draft': 'Draft',
|
||||
'draftSave': 'Save',
|
||||
'draftBox': 'Draft Box',
|
||||
'more': 'More',
|
||||
'share': 'Share',
|
||||
'feed': 'Feed',
|
||||
'unlink': 'Unlink',
|
||||
'feedSearch': 'Search Feed',
|
||||
'feedSearchWithTag': 'Searching with tag #@key',
|
||||
'feedSearchWithCategory': 'Searching in category @category',
|
||||
@@ -27,11 +29,13 @@ const i18nEnglish = {
|
||||
'about': 'About',
|
||||
'edit': 'Edit',
|
||||
'delete': 'Delete',
|
||||
'settings': 'Settings',
|
||||
'search': 'Search',
|
||||
'post': 'Post',
|
||||
'article': 'Article',
|
||||
'reply': 'Reply',
|
||||
'repost': 'Repost',
|
||||
'openInAlbum': 'Open in album',
|
||||
'openInBrowser': 'Open in browser',
|
||||
'notification': 'Notification',
|
||||
'errorHappened': 'An error occurred',
|
||||
@@ -48,6 +52,7 @@ const i18nEnglish = {
|
||||
'account': 'Account',
|
||||
'accountPersonalize': 'Personalize',
|
||||
'accountPersonalizeApplied': 'Account personalize settings has been saved.',
|
||||
'accountStickers': 'Stickers',
|
||||
'accountFriend': 'Friend',
|
||||
'accountFriendNew': 'New friend',
|
||||
'accountFriendNewHint':
|
||||
@@ -99,6 +104,11 @@ const i18nEnglish = {
|
||||
'postRestoreFromLocal': 'Restore from local',
|
||||
'postAutoSaveAt': 'Auto saved at @date',
|
||||
'postCategoriesAndTags': 'Categories n\' Tags',
|
||||
'postPublishDate': 'Publish Date',
|
||||
'postPublishAt': 'Publish At',
|
||||
'postPublishedUntil': 'Publish Until',
|
||||
'postPublishZone': 'Publish Zone',
|
||||
'postPublishZoneNone': 'None',
|
||||
'postVisibility': 'Visibility',
|
||||
'postVisibilityAll': 'Everyone',
|
||||
'postVisibilityFriends': 'Friends',
|
||||
@@ -122,7 +132,7 @@ const i18nEnglish = {
|
||||
'postAction': 'Post',
|
||||
'postEdited': 'Edited at @date',
|
||||
'postNewCreated': 'Created at @date',
|
||||
'postAttachmentTip': '@count attachment(s)',
|
||||
'attachmentHint': '@count attachment(s)',
|
||||
'postInRealm': 'In @realm',
|
||||
'postDetail': 'Post',
|
||||
'postReplies': 'Replies',
|
||||
@@ -150,6 +160,14 @@ const i18nEnglish = {
|
||||
'reactCompleted': 'Your reaction has been added',
|
||||
'reactUncompleted': 'Your reaction has been removed',
|
||||
'attachmentUploadBy': 'Upload by',
|
||||
'attachmentAutoUpload': 'Auto Upload',
|
||||
'attachmentUploadQueue': 'Upload Queue',
|
||||
'attachmentUploadQueueStart': 'Start All',
|
||||
'attachmentUploadInProgress':
|
||||
'There are attachments being uploaded. Please wait until all attachments have been uploaded before proceeding...',
|
||||
'attachmentAttached': 'Exists Files',
|
||||
'attachmentUploadBlocked':
|
||||
'Upload blocked, there is currently a task in progress...',
|
||||
'attachmentAdd': 'Attach attachments',
|
||||
'attachmentAddGalleryPhoto': 'Gallery photo',
|
||||
'attachmentAddGalleryVideo': 'Gallery video',
|
||||
@@ -157,6 +175,10 @@ const i18nEnglish = {
|
||||
'attachmentAddCameraVideo': 'Capture video',
|
||||
'attachmentAddClipboard': 'Paste file',
|
||||
'attachmentAddFile': 'Attach file',
|
||||
'attachmentAddLink': 'Link attachments',
|
||||
'attachmentAddLinkHint':
|
||||
'Enter attachment serial number to link that attachment',
|
||||
'attachmentAddLinkInput': 'Serial number',
|
||||
'attachmentSetting': 'Adjust attachment',
|
||||
'attachmentAlt': 'Alternative text',
|
||||
'attachmentLoadFailed': 'Load Attachment Failed',
|
||||
@@ -239,6 +261,8 @@ const i18nEnglish = {
|
||||
'Are your sure to delete message @id? This action cannot be undone!',
|
||||
'call': 'Call',
|
||||
'callOngoing': 'A call is ongoing...',
|
||||
'callOngoingEmpty': 'A call is on hold...',
|
||||
'callOngoingParticipants': '@count people are calling...',
|
||||
'callJoin': 'Join',
|
||||
'callResume': 'Resume',
|
||||
'callMicrophone': 'Microphone',
|
||||
@@ -293,6 +317,14 @@ const i18nEnglish = {
|
||||
'accountStatusNegative': 'Negative',
|
||||
'accountStatusNeutral': 'Neutral',
|
||||
'accountStatusPositive': 'Positive',
|
||||
'bsLoadingTheme': 'Loading Theme',
|
||||
'bsCheckForUpdate': 'Checking For Updates',
|
||||
'bsCheckForUpdateFailed': 'Unable to Check Updates',
|
||||
'bsCheckForUpdateNew': 'Found New Version',
|
||||
'bsCheckForUpdateDescApple':
|
||||
'Please head to TestFlight and update your app to latest version to prevent error happens and get latest functions.',
|
||||
'bsCheckForUpdateDescCommon':
|
||||
'Please head to our website download and install latest version of application to prevent error happens and get latest functions.',
|
||||
'bsCheckingServer': 'Checking Server Status',
|
||||
'bsCheckingServerFail':
|
||||
'Unable connect to server, check your network connection',
|
||||
@@ -304,4 +336,28 @@ const i18nEnglish = {
|
||||
'postShareContent':
|
||||
'@content\n\n@username on the Solar Network\nCheck it out: @link',
|
||||
'postShareSubject': '@username posted a post on the Solar Network',
|
||||
'themeColor': 'Global Theme Color',
|
||||
'themeColorRed': 'Modern Red',
|
||||
'themeColorBlue': 'Classic Blue',
|
||||
'themeColorMiku': 'Miku Blue',
|
||||
'themeColorKagamine': 'Kagamine Yellow',
|
||||
'themeColorLuka': 'Luka Pink',
|
||||
'stickerDeletionConfirm': 'Confirm sticker delete',
|
||||
'stickerDeletionConfirmCaption':
|
||||
'Are you sure to delete sticker @name? This action cannot be undo.',
|
||||
'themeColorApplied': 'Global theme color has been applied.',
|
||||
'attachmentSaved': 'Attachment saved to your system album.',
|
||||
'cropImage': 'Crop Image',
|
||||
'stickerUploader': 'Upload sticker',
|
||||
'stickerUploaderAttachmentNew': 'Upload new attachment',
|
||||
'stickerUploaderAttachment': 'Attachment serial number',
|
||||
'stickerUploaderPack': 'Sticker pack serial number',
|
||||
'stickerUploaderPackHint':
|
||||
'Don\'t have pack id? Head to creator platform and create one!',
|
||||
'stickerUploaderAlias': 'Alias',
|
||||
'stickerUploaderAliasHint':
|
||||
'Will be used as a placeholder with the sticker pack prefix when entered.',
|
||||
'stickerUploaderName': 'Name',
|
||||
'stickerUploaderNameHint':
|
||||
'A human-friendly name given to the user in the sticker selection interface.',
|
||||
};
|
||||
|
||||
@@ -13,12 +13,15 @@ const i18nSimplifiedChinese = {
|
||||
'about': '关于',
|
||||
'edit': '编辑',
|
||||
'delete': '删除',
|
||||
'settings': '设置',
|
||||
'page': '页面',
|
||||
'draft': '草稿',
|
||||
'draftSave': '存为草稿',
|
||||
'draftBox': '草稿箱',
|
||||
'more': '更多',
|
||||
'share': '分享',
|
||||
'feed': '资讯',
|
||||
'unlink': '移除链接',
|
||||
'feedSearch': '搜索资讯',
|
||||
'feedSearchWithTag': '检索带有 #@key 标签的资讯',
|
||||
'feedSearchWithCategory': '检索位于分类 @category 的资讯',
|
||||
@@ -32,6 +35,7 @@ const i18nSimplifiedChinese = {
|
||||
'article': '文章',
|
||||
'reply': '回复',
|
||||
'repost': '转帖',
|
||||
'openInAlbum': '在相簿中打开',
|
||||
'openInBrowser': '在浏览器中打开',
|
||||
'notification': '通知',
|
||||
'errorHappened': '发生错误了',
|
||||
@@ -48,6 +52,7 @@ const i18nSimplifiedChinese = {
|
||||
'account': '账号',
|
||||
'accountPersonalize': '个性化',
|
||||
'accountPersonalizeApplied': '账户的个性化设置已保存。',
|
||||
'accountStickers': '贴图',
|
||||
'accountFriend': '好友',
|
||||
'accountFriendNew': '添加好友',
|
||||
'accountFriendNewHint': '使用他人的用户名来发送一个好友请求吧!',
|
||||
@@ -93,6 +98,11 @@ const i18nSimplifiedChinese = {
|
||||
'postRestoreFromLocal': '内容从本地暂存回复',
|
||||
'postAutoSaveAt': '已自动保存于 @date',
|
||||
'postCategoriesAndTags': '分类与标签',
|
||||
'postPublishDate': '发布时间',
|
||||
'postPublishAt': '发布帖子于',
|
||||
'postPublishedUntil': '取消发布于',
|
||||
'postPublishZone': '帖子发布区',
|
||||
'postPublishZoneNone': '无所属领域',
|
||||
'postVisibility': '帖子可见性',
|
||||
'postVisibilityAll': '所有人可见',
|
||||
'postVisibilityFriends': '仅好友可见',
|
||||
@@ -117,7 +127,7 @@ const i18nSimplifiedChinese = {
|
||||
'postEdited': '编辑于 @date',
|
||||
'postNewCreated': '创建于 @date',
|
||||
'postInRealm': '发表于 @realm',
|
||||
'postAttachmentTip': '@count 个附件',
|
||||
'attachmentHint': '@count 个附件',
|
||||
'postDetail': '帖子详情',
|
||||
'postReplies': '帖子回复',
|
||||
'postPublish': '编辑帖子',
|
||||
@@ -139,6 +149,12 @@ const i18nSimplifiedChinese = {
|
||||
'reactCompleted': '你的反应已被添加',
|
||||
'reactUncompleted': '你的反应已被移除',
|
||||
'attachmentUploadBy': '由上传',
|
||||
'attachmentAutoUpload': '自动上传',
|
||||
'attachmentUploadQueue': '上传队列',
|
||||
'attachmentUploadQueueStart': '整队上传',
|
||||
'attachmentUploadInProgress': '有附件正在上传,请等待所有附件上传完毕后再进行操作……',
|
||||
'attachmentAttached': '已附附件',
|
||||
'attachmentUploadBlocked': '上传受阻,当前已有任务进行中……',
|
||||
'attachmentAdd': '附加附件',
|
||||
'attachmentAddGalleryPhoto': '相册照片',
|
||||
'attachmentAddGalleryVideo': '相册视频',
|
||||
@@ -146,6 +162,9 @@ const i18nSimplifiedChinese = {
|
||||
'attachmentAddCameraVideo': '拍摄视频',
|
||||
'attachmentAddClipboard': '粘贴文件',
|
||||
'attachmentAddFile': '附加文件',
|
||||
'attachmentAddLink': '链接附件',
|
||||
'attachmentAddLinkHint': '输入附件的神秘代号来链接对应附件',
|
||||
'attachmentAddLinkInput': '神秘代号',
|
||||
'attachmentSetting': '调整附件',
|
||||
'attachmentAlt': '替代文字',
|
||||
'attachmentLoadFailed': '加载失败',
|
||||
@@ -220,6 +239,8 @@ const i18nSimplifiedChinese = {
|
||||
'messageDeletionConfirmCaption': '你确定要删除消息 @id 吗?该操作不可撤销。',
|
||||
'call': '通话',
|
||||
'callOngoing': '一则通话正在进行中…',
|
||||
'callOngoingEmpty': '一则通话待机中…',
|
||||
'callOngoingParticipants': '@count 人正在进行通话…',
|
||||
'callJoin': '加入',
|
||||
'callResume': '恢复',
|
||||
'callMicrophone': '麦克风',
|
||||
@@ -272,6 +293,12 @@ const i18nSimplifiedChinese = {
|
||||
'accountStatusNegative': '负面',
|
||||
'accountStatusNeutral': '中性',
|
||||
'accountStatusPositive': '积极',
|
||||
'bsLoadingTheme': '正在装载主题',
|
||||
'bsCheckForUpdate': '正在检查更新',
|
||||
'bsCheckForUpdateFailed': '无法检查更新',
|
||||
'bsCheckForUpdateNew': '发现新版本',
|
||||
'bsCheckForUpdateDescApple': '请前往 TestFlight 并将您的应用程序更新到最新版本,以防止出现错误并获取最新功能。',
|
||||
'bsCheckForUpdateDescCommon': '请前往我们的网站下载并安装最新版本的应用程序,以防止出现错误并获取最新功能。',
|
||||
'bsCheckingServer': '检查服务器状态中',
|
||||
'bsCheckingServerFail': '无法连接至服务器,请检查你的网络连接状态',
|
||||
'bsCheckingServerDown': '当前服务器不可用,请稍后重试',
|
||||
@@ -281,4 +308,24 @@ const i18nSimplifiedChinese = {
|
||||
'bsRegisteringPushNotify': '正在启用推送通知',
|
||||
'postShareContent': '@content\n\n@username 在 Solar Network\n原帖地址:@link',
|
||||
'postShareSubject': '@username 在 Solar Network 上发布了一篇帖子',
|
||||
'themeColor': '全局主题色',
|
||||
'themeColorRed': '现代红',
|
||||
'themeColorBlue': '经典蓝',
|
||||
'themeColorMiku': '未来蓝',
|
||||
'themeColorKagamine': '镜音黄',
|
||||
'themeColorLuka': '流音粉',
|
||||
'themeColorApplied': '全局主题颜色已应用',
|
||||
'stickerDeletionConfirm': '确认删除贴图',
|
||||
'stickerDeletionConfirmCaption': '你确认要删除贴图 @name 吗?该操作不可撤销。',
|
||||
'attachmentSaved': '附件已保存到系统相册',
|
||||
'cropImage': '裁剪图片',
|
||||
'stickerUploader': '上传贴图',
|
||||
'stickerUploaderAttachmentNew': '上传附件',
|
||||
'stickerUploaderAttachment': '附件序列号',
|
||||
'stickerUploaderPack': '贴图包序号',
|
||||
'stickerUploaderPackHint': '没有该序号?请转到我们的创作者平台创建一个贴图包。',
|
||||
'stickerUploaderAlias': '贴图别名',
|
||||
'stickerUploaderAliasHint': '将会在输入时使用和贴图包前缀组成占位符。',
|
||||
'stickerUploaderName': '贴图名称',
|
||||
'stickerUploaderNameHint': '在贴图选择界面提供给用户的人类友好名称。',
|
||||
};
|
||||
|
||||
@@ -8,9 +8,9 @@ import 'package:solian/services.dart';
|
||||
import 'package:solian/widgets/account/account_heading.dart';
|
||||
|
||||
class AccountProfilePopup extends StatefulWidget {
|
||||
final Account account;
|
||||
final String name;
|
||||
|
||||
const AccountProfilePopup({super.key, required this.account});
|
||||
const AccountProfilePopup({super.key, required this.name});
|
||||
|
||||
@override
|
||||
State<AccountProfilePopup> createState() => _AccountProfilePopupState();
|
||||
@@ -21,11 +21,11 @@ class _AccountProfilePopupState extends State<AccountProfilePopup> {
|
||||
|
||||
Account? _userinfo;
|
||||
|
||||
void getUserinfo() async {
|
||||
void _getUserinfo() async {
|
||||
setState(() => _isBusy = true);
|
||||
|
||||
final client = ServiceFinder.configureClient('auth');
|
||||
final resp = await client.get('/users/${widget.account.name}');
|
||||
final resp = await client.get('/users/${widget.name}');
|
||||
if (resp.statusCode == 200) {
|
||||
_userinfo = Account.fromJson(resp.body);
|
||||
setState(() => _isBusy = false);
|
||||
@@ -38,7 +38,7 @@ class _AccountProfilePopupState extends State<AccountProfilePopup> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
getUserinfo();
|
||||
_getUserinfo();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -226,7 +226,7 @@ class _AccountStatusEditorDialogState extends State<AccountStatusEditorDialog> {
|
||||
onTapOutside: (_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
const SizedBox(height: 8),
|
||||
TextField(
|
||||
controller: _clearAtController,
|
||||
readOnly: true,
|
||||
@@ -238,7 +238,7 @@ class _AccountStatusEditorDialogState extends State<AccountStatusEditorDialog> {
|
||||
),
|
||||
onTap: () => selectClearAt(),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
const SizedBox(height: 8),
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Wrap(
|
||||
@@ -281,7 +281,7 @@ class _AccountStatusEditorDialogState extends State<AccountStatusEditorDialog> {
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
const SizedBox(height: 8),
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Wrap(
|
||||
|
||||
@@ -35,7 +35,7 @@ class SilverRelativeList extends StatelessWidget {
|
||||
context: context,
|
||||
builder: (context) =>
|
||||
AccountProfilePopup(
|
||||
account: element.related,
|
||||
name: element.related.name,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
132
lib/widgets/attachments/attachment_attr_editor.dart
Normal file
@@ -0,0 +1,132 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_animate/flutter_animate.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/exts.dart';
|
||||
import 'package:solian/models/attachment.dart';
|
||||
import 'package:solian/providers/content/attachment.dart';
|
||||
|
||||
class AttachmentAttrEditorDialog extends StatefulWidget {
|
||||
final Attachment item;
|
||||
final Function(Attachment item) onUpdate;
|
||||
|
||||
const AttachmentAttrEditorDialog({
|
||||
super.key,
|
||||
required this.item,
|
||||
required this.onUpdate,
|
||||
});
|
||||
|
||||
@override
|
||||
State<AttachmentAttrEditorDialog> createState() => _AttachmentAttrEditorDialogState();
|
||||
}
|
||||
|
||||
class _AttachmentAttrEditorDialogState extends State<AttachmentAttrEditorDialog> {
|
||||
final _altController = TextEditingController();
|
||||
|
||||
bool _isBusy = false;
|
||||
bool _isMature = false;
|
||||
|
||||
Future<Attachment?> _updateAttachment() async {
|
||||
final AttachmentProvider provider = Get.find();
|
||||
|
||||
setState(() => _isBusy = true);
|
||||
try {
|
||||
final resp = await provider.updateAttachment(
|
||||
widget.item.id,
|
||||
_altController.value.text,
|
||||
widget.item.usage,
|
||||
isMature: _isMature,
|
||||
);
|
||||
|
||||
Get.find<AttachmentProvider>().clearCache(id: widget.item.id);
|
||||
|
||||
setState(() => _isBusy = false);
|
||||
return Attachment.fromJson(resp.body);
|
||||
} catch (e) {
|
||||
context.showErrorDialog(e);
|
||||
setState(() => _isBusy = false);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void syncWidget() {
|
||||
_isMature = widget.item.isMature;
|
||||
_altController.text = widget.item.alt;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
syncWidget();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('attachmentSetting'.tr),
|
||||
content: Container(
|
||||
constraints: const BoxConstraints(minWidth: 400),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (_isBusy)
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
child: const LinearProgressIndicator().animate().scaleX(),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
TextField(
|
||||
controller: _altController,
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
prefixIcon: const Icon(Icons.image_not_supported),
|
||||
border: const OutlineInputBorder(),
|
||||
labelText: 'attachmentAlt'.tr,
|
||||
),
|
||||
onTapOutside: (_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
CheckboxListTile(
|
||||
contentPadding: const EdgeInsets.only(left: 4, right: 18),
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10))),
|
||||
title: Text('matureContent'.tr),
|
||||
secondary: const Icon(Icons.visibility_off),
|
||||
value: _isMature,
|
||||
onChanged: (newValue) {
|
||||
setState(() => _isMature = newValue ?? false);
|
||||
},
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actionsAlignment: MainAxisAlignment.spaceBetween,
|
||||
actions: <Widget>[
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor:
|
||||
Theme.of(context).colorScheme.onSurfaceVariant),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text('cancel'.tr),
|
||||
),
|
||||
TextButton(
|
||||
child: Text('apply'.tr),
|
||||
onPressed: () {
|
||||
_updateAttachment().then((value) {
|
||||
if (value != null) {
|
||||
widget.onUpdate(value);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
300
lib/widgets/attachments/attachment_fullscreen.dart
Normal file
@@ -0,0 +1,300 @@
|
||||
import 'dart:io';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:dismissible_page/dismissible_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_animate/flutter_animate.dart';
|
||||
import 'package:gal/gal.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/exts.dart';
|
||||
import 'package:solian/models/attachment.dart';
|
||||
import 'package:solian/platform.dart';
|
||||
import 'package:solian/services.dart';
|
||||
import 'package:solian/widgets/account/account_avatar.dart';
|
||||
import 'package:solian/widgets/attachments/attachment_item.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
import 'package:path/path.dart' show extension;
|
||||
|
||||
class AttachmentFullScreen extends StatefulWidget {
|
||||
final String parentId;
|
||||
final Attachment item;
|
||||
|
||||
const AttachmentFullScreen(
|
||||
{super.key, required this.parentId, required this.item});
|
||||
|
||||
@override
|
||||
State<AttachmentFullScreen> createState() => _AttachmentFullScreenState();
|
||||
}
|
||||
|
||||
class _AttachmentFullScreenState extends State<AttachmentFullScreen> {
|
||||
bool _showDetails = true;
|
||||
|
||||
bool _isDownloading = false;
|
||||
bool _isCompletedDownload = false;
|
||||
double? _progressOfDownload = 0;
|
||||
|
||||
Color get _unFocusColor =>
|
||||
Theme.of(context).colorScheme.onSurface.withOpacity(0.75);
|
||||
|
||||
String _formatBytes(int bytes, {int decimals = 2}) {
|
||||
if (bytes == 0) return '0 Bytes';
|
||||
const k = 1024;
|
||||
final dm = decimals < 0 ? 0 : decimals;
|
||||
final sizes = [
|
||||
'Bytes',
|
||||
'KiB',
|
||||
'MiB',
|
||||
'GiB',
|
||||
'TiB',
|
||||
'PiB',
|
||||
'EiB',
|
||||
'ZiB',
|
||||
'YiB'
|
||||
];
|
||||
final i = (math.log(bytes) / math.log(k)).floor().toInt();
|
||||
return '${(bytes / math.pow(k, i)).toStringAsFixed(dm)} ${sizes[i]}';
|
||||
}
|
||||
|
||||
double _getRatio() {
|
||||
final value = widget.item.metadata?['ratio'];
|
||||
if (value == null) return 1;
|
||||
if (value is int) return value.toDouble();
|
||||
if (value is double) return value;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Future<void> _saveToAlbum() async {
|
||||
final url = ServiceFinder.buildUrl(
|
||||
'files',
|
||||
'/attachments/${widget.item.id}',
|
||||
);
|
||||
|
||||
if (PlatformInfo.isWeb) {
|
||||
await launchUrlString(url);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!await Gal.hasAccess(toAlbum: true)) {
|
||||
if (!await Gal.requestAccess(toAlbum: true)) return;
|
||||
}
|
||||
|
||||
setState(() => _isDownloading = true);
|
||||
|
||||
var extName = extension(widget.item.name);
|
||||
if (extName.isEmpty) extName = '.png';
|
||||
final imagePath =
|
||||
'${Directory.systemTemp.path}/${widget.item.uuid}$extName';
|
||||
await Dio().download(
|
||||
url,
|
||||
imagePath,
|
||||
onReceiveProgress: (count, total) {
|
||||
setState(() => _progressOfDownload = count / total);
|
||||
},
|
||||
);
|
||||
|
||||
bool isSuccess = false;
|
||||
try {
|
||||
await Gal.putImage(imagePath);
|
||||
isSuccess = true;
|
||||
} on GalException catch (e) {
|
||||
context.showErrorDialog(e.type.message);
|
||||
}
|
||||
|
||||
context.showSnackbar(
|
||||
'attachmentSaved'.tr,
|
||||
action: SnackBarAction(
|
||||
label: 'openInAlbum'.tr,
|
||||
onPressed: () async => Gal.open(),
|
||||
),
|
||||
);
|
||||
setState(() {
|
||||
_isDownloading = false;
|
||||
_isCompletedDownload = isSuccess;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final metaTextStyle = TextStyle(
|
||||
fontSize: 12,
|
||||
color: _unFocusColor,
|
||||
);
|
||||
|
||||
return DismissiblePage(
|
||||
key: Key('attachment-dismissible${widget.item.id}'),
|
||||
direction: DismissiblePageDismissDirection.vertical,
|
||||
onDismissed: () => Navigator.pop(context),
|
||||
dismissThresholds: const {
|
||||
DismissiblePageDismissDirection.vertical: 0.0,
|
||||
},
|
||||
onDragStart: () {
|
||||
setState(() => _showDetails = false);
|
||||
},
|
||||
onDragEnd: () {
|
||||
setState(() => _showDetails = true);
|
||||
},
|
||||
child: GestureDetector(
|
||||
child: Stack(
|
||||
fit: StackFit.loose,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: InteractiveViewer(
|
||||
boundaryMargin: EdgeInsets.zero,
|
||||
minScale: 1,
|
||||
maxScale: 16,
|
||||
panEnabled: true,
|
||||
scaleEnabled: true,
|
||||
child: AttachmentItem(
|
||||
parentId: widget.parentId,
|
||||
showHideButton: false,
|
||||
item: widget.item,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: IgnorePointer(
|
||||
child: Container(
|
||||
height: 300,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.bottomCenter,
|
||||
end: Alignment.topCenter,
|
||||
colors: [
|
||||
Theme.of(context).colorScheme.surface,
|
||||
Theme.of(context).colorScheme.surface.withOpacity(0),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
.animate(target: _showDetails ? 1 : 0)
|
||||
.fadeIn(curve: Curves.fastEaseInToSlowEaseOut),
|
||||
Positioned(
|
||||
bottom: math.max(MediaQuery.of(context).padding.bottom, 16),
|
||||
left: 16,
|
||||
right: 16,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (widget.item.account != null)
|
||||
Row(
|
||||
children: [
|
||||
IgnorePointer(
|
||||
child: AccountAvatar(
|
||||
content: widget.item.account!.avatar,
|
||||
radius: 19,
|
||||
),
|
||||
),
|
||||
const IgnorePointer(child: SizedBox(width: 8)),
|
||||
Expanded(
|
||||
child: IgnorePointer(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'attachmentUploadBy'.tr,
|
||||
style:
|
||||
Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
Text(
|
||||
widget.item.account!.nick,
|
||||
style:
|
||||
Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
visualDensity: const VisualDensity(
|
||||
horizontal: -4,
|
||||
vertical: -2,
|
||||
),
|
||||
icon: !_isDownloading
|
||||
? !_isCompletedDownload
|
||||
? const Icon(Icons.save_alt)
|
||||
: const Icon(Icons.download_done)
|
||||
: SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: CircularProgressIndicator(
|
||||
value: _progressOfDownload,
|
||||
strokeWidth: 3,
|
||||
),
|
||||
),
|
||||
onPressed:
|
||||
_isDownloading ? null : () => _saveToAlbum(),
|
||||
),
|
||||
],
|
||||
),
|
||||
const IgnorePointer(child: SizedBox(height: 4)),
|
||||
IgnorePointer(
|
||||
child: Text(
|
||||
widget.item.alt,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
const IgnorePointer(child: SizedBox(height: 2)),
|
||||
IgnorePointer(
|
||||
child: Wrap(
|
||||
spacing: 6,
|
||||
children: [
|
||||
Text(
|
||||
'#${widget.item.id}',
|
||||
style: metaTextStyle,
|
||||
),
|
||||
if (widget.item.metadata?['width'] != null &&
|
||||
widget.item.metadata?['height'] != null)
|
||||
Text(
|
||||
'${widget.item.metadata?['width']}x${widget.item.metadata?['height']}',
|
||||
style: metaTextStyle,
|
||||
),
|
||||
if (widget.item.metadata?['ratio'] != null)
|
||||
Text(
|
||||
'${_getRatio().toPrecision(2)}',
|
||||
style: metaTextStyle,
|
||||
),
|
||||
Text(
|
||||
_formatBytes(widget.item.size),
|
||||
style: metaTextStyle,
|
||||
),
|
||||
Text(
|
||||
widget.item.mimetype,
|
||||
style: metaTextStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
.animate(target: _showDetails ? 1 : 0)
|
||||
.fadeIn(curve: Curves.fastEaseInToSlowEaseOut),
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
setState(() => _showDetails = !_showDetails);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import 'package:get/get.dart';
|
||||
import 'package:solian/models/attachment.dart';
|
||||
import 'package:solian/widgets/attachments/attachment_item.dart';
|
||||
import 'package:solian/providers/content/attachment.dart';
|
||||
import 'package:solian/widgets/attachments/attachment_list_fullscreen.dart';
|
||||
import 'package:solian/widgets/attachments/attachment_fullscreen.dart';
|
||||
|
||||
class AttachmentList extends StatefulWidget {
|
||||
final String parentId;
|
||||
@@ -45,7 +45,7 @@ class _AttachmentListState extends State<AttachmentList> {
|
||||
List<Attachment?> _attachmentsMeta = List.empty();
|
||||
|
||||
void _getMetadataList() {
|
||||
final AttachmentProvider provider = Get.find();
|
||||
final AttachmentProvider attach = Get.find();
|
||||
|
||||
if (widget.attachmentsId.isEmpty) {
|
||||
return;
|
||||
@@ -53,25 +53,16 @@ class _AttachmentListState extends State<AttachmentList> {
|
||||
_attachmentsMeta = List.filled(widget.attachmentsId.length, null);
|
||||
}
|
||||
|
||||
int progress = 0;
|
||||
for (var idx = 0; idx < widget.attachmentsId.length; idx++) {
|
||||
provider.getMetadata(widget.attachmentsId[idx]).then((resp) {
|
||||
progress++;
|
||||
if (resp != null) {
|
||||
_attachmentsMeta[idx] = resp;
|
||||
}
|
||||
if (progress == widget.attachmentsId.length) {
|
||||
calculateAspectRatio();
|
||||
|
||||
if (mounted) {
|
||||
setState(() => _isLoading = false);
|
||||
}
|
||||
}
|
||||
attach.listMetadata(widget.attachmentsId).then((result) {
|
||||
setState(() {
|
||||
_attachmentsMeta = result;
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
_calculateAspectRatio();
|
||||
});
|
||||
}
|
||||
|
||||
void calculateAspectRatio() {
|
||||
void _calculateAspectRatio() {
|
||||
bool isConsistent = true;
|
||||
double? consistentValue;
|
||||
int portrait = 0, square = 0, landscape = 0;
|
||||
@@ -320,9 +311,9 @@ class AttachmentListEntry extends StatelessWidget {
|
||||
onReveal(true);
|
||||
} else if (['image'].contains(item!.mimetype.split('/').first)) {
|
||||
context.pushTransparentRoute(
|
||||
AttachmentListFullScreen(
|
||||
AttachmentFullScreen(
|
||||
parentId: parentId,
|
||||
attachment: item!,
|
||||
item: item!,
|
||||
),
|
||||
rootNavigator: true,
|
||||
);
|
||||
|
||||
@@ -1,197 +0,0 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:dismissible_page/dismissible_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_animate/flutter_animate.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/models/attachment.dart';
|
||||
import 'package:solian/widgets/account/account_avatar.dart';
|
||||
import 'package:solian/widgets/attachments/attachment_item.dart';
|
||||
|
||||
class AttachmentListFullScreen extends StatefulWidget {
|
||||
final String parentId;
|
||||
final Attachment attachment;
|
||||
|
||||
const AttachmentListFullScreen(
|
||||
{super.key, required this.parentId, required this.attachment});
|
||||
|
||||
@override
|
||||
State<AttachmentListFullScreen> createState() =>
|
||||
_AttachmentListFullScreenState();
|
||||
}
|
||||
|
||||
class _AttachmentListFullScreenState extends State<AttachmentListFullScreen> {
|
||||
bool _showDetails = true;
|
||||
|
||||
Color get _unFocusColor =>
|
||||
Theme.of(context).colorScheme.onSurface.withOpacity(0.75);
|
||||
|
||||
String _formatBytes(int bytes, {int decimals = 2}) {
|
||||
if (bytes == 0) return '0 Bytes';
|
||||
const k = 1024;
|
||||
final dm = decimals < 0 ? 0 : decimals;
|
||||
final sizes = [
|
||||
'Bytes',
|
||||
'KiB',
|
||||
'MiB',
|
||||
'GiB',
|
||||
'TiB',
|
||||
'PiB',
|
||||
'EiB',
|
||||
'ZiB',
|
||||
'YiB'
|
||||
];
|
||||
final i = (math.log(bytes) / math.log(k)).floor().toInt();
|
||||
return '${(bytes / math.pow(k, i)).toStringAsFixed(dm)} ${sizes[i]}';
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DismissiblePage(
|
||||
key: Key('attachment-dismissible${widget.attachment.id}'),
|
||||
direction: DismissiblePageDismissDirection.vertical,
|
||||
onDismissed: () => Navigator.pop(context),
|
||||
dismissThresholds: const {
|
||||
DismissiblePageDismissDirection.vertical: 0.0,
|
||||
},
|
||||
onDragStart: () {
|
||||
setState(() => _showDetails = false);
|
||||
},
|
||||
onDragEnd: () {
|
||||
setState(() => _showDetails = true);
|
||||
},
|
||||
child: GestureDetector(
|
||||
child: Stack(
|
||||
fit: StackFit.loose,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: InteractiveViewer(
|
||||
boundaryMargin: EdgeInsets.zero,
|
||||
minScale: 1,
|
||||
maxScale: 16,
|
||||
panEnabled: true,
|
||||
scaleEnabled: true,
|
||||
child: AttachmentItem(
|
||||
parentId: widget.parentId,
|
||||
showHideButton: false,
|
||||
item: widget.attachment,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: IgnorePointer(
|
||||
child: Container(
|
||||
height: 300,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.bottomCenter,
|
||||
end: Alignment.topCenter,
|
||||
colors: [
|
||||
Theme.of(context).colorScheme.surface,
|
||||
Theme.of(context).colorScheme.surface.withOpacity(0),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
.animate(target: _showDetails ? 1 : 0)
|
||||
.fadeIn(curve: Curves.fastEaseInToSlowEaseOut),
|
||||
Positioned(
|
||||
bottom: math.max(MediaQuery.of(context).padding.bottom, 16),
|
||||
left: 16,
|
||||
right: 16,
|
||||
child: IgnorePointer(
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (widget.attachment.account != null)
|
||||
Row(
|
||||
children: [
|
||||
AccountAvatar(
|
||||
content: widget.attachment.account!.avatar,
|
||||
radius: 19,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'attachmentUploadBy'.tr,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
Text(
|
||||
widget.attachment.account!.nick,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
widget.attachment.alt,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Wrap(
|
||||
spacing: 6,
|
||||
children: [
|
||||
if (widget.attachment.metadata?['width'] != null &&
|
||||
widget.attachment.metadata?['height'] != null)
|
||||
Text(
|
||||
'${widget.attachment.metadata?['width']}x${widget.attachment.metadata?['height']}',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: _unFocusColor,
|
||||
),
|
||||
),
|
||||
if (widget.attachment.metadata?['ratio'] != null)
|
||||
Text(
|
||||
'${(widget.attachment.metadata?['ratio'] as double).toPrecision(2)}',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: _unFocusColor,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
_formatBytes(widget.attachment.size),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: _unFocusColor,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
.animate(target: _showDetails ? 1 : 0)
|
||||
.fadeIn(curve: Curves.fastEaseInToSlowEaseOut),
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
setState(() => _showDetails = !_showDetails);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
89
lib/widgets/channel/channel_call_indicator.dart
Normal file
@@ -0,0 +1,89 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:avatar_stack/avatar_stack.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/models/account.dart';
|
||||
import 'package:solian/models/call.dart';
|
||||
import 'package:solian/models/channel.dart';
|
||||
import 'package:solian/platform.dart';
|
||||
import 'package:solian/providers/call.dart';
|
||||
import 'package:solian/widgets/chat/call/call_prejoin.dart';
|
||||
|
||||
class ChannelCallIndicator extends StatelessWidget {
|
||||
final Channel channel;
|
||||
final Call ongoingCall;
|
||||
|
||||
const ChannelCallIndicator(
|
||||
{super.key, required this.channel, required this.ongoingCall});
|
||||
|
||||
void _showCallPrejoin(BuildContext context) {
|
||||
showModalBottomSheet(
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
builder: (context) => ChatCallPrejoinPopup(
|
||||
ongoingCall: ongoingCall,
|
||||
channel: channel,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ChatCallProvider call = Get.find();
|
||||
|
||||
return MaterialBanner(
|
||||
padding: const EdgeInsets.only(left: 16, top: 4, bottom: 4),
|
||||
leading: const Icon(Icons.call_received),
|
||||
backgroundColor: Theme.of(context).colorScheme.surfaceContainer,
|
||||
dividerColor: Colors.transparent,
|
||||
content: Row(
|
||||
children: [
|
||||
if (ongoingCall.participants.isEmpty) Text('callOngoingEmpty'.tr),
|
||||
if (ongoingCall.participants.isNotEmpty)
|
||||
Text('callOngoingParticipants'.trParams({
|
||||
'count': ongoingCall.participants.length.toString(),
|
||||
})),
|
||||
const SizedBox(width: 6),
|
||||
if (ongoingCall.participants.isNotEmpty)
|
||||
Container(
|
||||
height: 28,
|
||||
constraints: const BoxConstraints(maxWidth: 120),
|
||||
child: AvatarStack(
|
||||
height: 28,
|
||||
borderWidth: 0,
|
||||
avatars: ongoingCall.participants.map((x) {
|
||||
final userinfo = Account.fromJson(jsonDecode(x['metadata']));
|
||||
return PlatformInfo.canCacheImage
|
||||
? CachedNetworkImageProvider(userinfo.avatar)
|
||||
as ImageProvider
|
||||
: NetworkImage(userinfo.avatar) as ImageProvider;
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
Obx(() {
|
||||
if (call.current.value == null) {
|
||||
return TextButton(
|
||||
onPressed: () => _showCallPrejoin(context),
|
||||
child: Text('callJoin'.tr),
|
||||
);
|
||||
} else if (call.channel.value?.id == channel.id) {
|
||||
return TextButton(
|
||||
onPressed: () => call.gotoScreen(context),
|
||||
child: Text('callResume'.tr),
|
||||
);
|
||||
} else {
|
||||
return TextButton(
|
||||
onPressed: null,
|
||||
child: Text('callJoin'.tr),
|
||||
);
|
||||
}
|
||||
})
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/controllers/chat_events_controller.dart';
|
||||
import 'package:solian/models/channel.dart';
|
||||
import 'package:solian/platform.dart';
|
||||
import 'package:solian/router.dart';
|
||||
import 'package:solian/widgets/account/account_avatar.dart';
|
||||
|
||||
@@ -31,7 +33,9 @@ class _ChannelListWidgetState extends State<ChannelListWidget> {
|
||||
final List<Channel> _globalChannels = List.empty(growable: true);
|
||||
final Map<String, List<Channel>> _inRealms = {};
|
||||
|
||||
void mapChannels() {
|
||||
final ChatEventController _eventController = ChatEventController();
|
||||
|
||||
void _mapChannels() {
|
||||
_inRealms.clear();
|
||||
_globalChannels.clear();
|
||||
|
||||
@@ -55,16 +59,17 @@ class _ChannelListWidgetState extends State<ChannelListWidget> {
|
||||
@override
|
||||
void didUpdateWidget(covariant ChannelListWidget oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
setState(() => mapChannels());
|
||||
setState(() => _mapChannels());
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
mapChannels();
|
||||
_mapChannels();
|
||||
_eventController.initialize();
|
||||
}
|
||||
|
||||
void gotoChannel(Channel item) {
|
||||
void _gotoChannel(Channel item) {
|
||||
if (widget.useReplace) {
|
||||
AppRouter.instance.pushReplacementNamed(
|
||||
'channelChat',
|
||||
@@ -88,7 +93,35 @@ class _ChannelListWidgetState extends State<ChannelListWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
Widget buildItem(Channel item) {
|
||||
Widget _buildDirectMessageDescription(Channel item, ChannelMember otherside) {
|
||||
if (PlatformInfo.isWeb) {
|
||||
return Text('channelDirectDescription'.trParams(
|
||||
{'username': '@${otherside.account.name}'},
|
||||
));
|
||||
}
|
||||
|
||||
return FutureBuilder(
|
||||
future: Future.delayed(
|
||||
const Duration(milliseconds: 500),
|
||||
() => _eventController.database.localEvents.findLastByChannel(item.id),
|
||||
),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData && snapshot.data == null) {
|
||||
return Text('channelDirectDescription'.trParams(
|
||||
{'username': '@${otherside.account.name}'},
|
||||
));
|
||||
}
|
||||
|
||||
return Text(
|
||||
'${snapshot.data!.data.sender.account.nick}: ${snapshot.data!.data.body['text'] ?? 'Unsupported message to preview'}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEntry(Channel item) {
|
||||
final padding = widget.isDense
|
||||
? const EdgeInsets.symmetric(horizontal: 20)
|
||||
: const EdgeInsets.symmetric(horizontal: 16);
|
||||
@@ -102,37 +135,36 @@ class _ChannelListWidgetState extends State<ChannelListWidget> {
|
||||
leading: AccountAvatar(
|
||||
content: otherside.account.avatar,
|
||||
radius: widget.isDense ? 12 : 20,
|
||||
bgColor: Colors.indigo,
|
||||
feColor: Colors.white,
|
||||
bgColor: Theme.of(context).colorScheme.primary,
|
||||
feColor: Theme.of(context).colorScheme.onPrimary,
|
||||
),
|
||||
contentPadding: padding,
|
||||
title: Text(otherside.account.nick),
|
||||
subtitle: !widget.isDense
|
||||
? Text(
|
||||
'channelDirectDescription'.trParams(
|
||||
{'username': '@${otherside.account.name}'},
|
||||
),
|
||||
)
|
||||
? _buildDirectMessageDescription(item, otherside)
|
||||
: null,
|
||||
onTap: () => gotoChannel(item),
|
||||
onTap: () => _gotoChannel(item),
|
||||
);
|
||||
} else {
|
||||
return ListTile(
|
||||
minTileHeight: widget.isDense ? 48 : null,
|
||||
leading: CircleAvatar(
|
||||
backgroundColor:
|
||||
item.realmId == null ? Colors.indigo : Colors.transparent,
|
||||
backgroundColor: item.realmId == null
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Colors.transparent,
|
||||
radius: widget.isDense ? 12 : 20,
|
||||
child: FaIcon(
|
||||
FontAwesomeIcons.hashtag,
|
||||
color: item.realmId == null ? Colors.white : Colors.indigo,
|
||||
color: item.realmId == null
|
||||
? Theme.of(context).colorScheme.onPrimary
|
||||
: Theme.of(context).colorScheme.primary,
|
||||
size: widget.isDense ? 12 : 16,
|
||||
),
|
||||
),
|
||||
contentPadding: padding,
|
||||
title: Text(item.name),
|
||||
subtitle: !widget.isDense ? Text(item.description) : null,
|
||||
onTap: () => gotoChannel(item),
|
||||
onTap: () => _gotoChannel(item),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -146,7 +178,7 @@ class _ChannelListWidgetState extends State<ChannelListWidget> {
|
||||
itemCount: _globalChannels.length,
|
||||
itemBuilder: (context, index) {
|
||||
final element = _globalChannels[index];
|
||||
return buildItem(element);
|
||||
return _buildEntry(element);
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -159,13 +191,13 @@ class _ChannelListWidgetState extends State<ChannelListWidget> {
|
||||
itemCount: _globalChannels.length,
|
||||
itemBuilder: (context, index) {
|
||||
final element = _globalChannels[index];
|
||||
return buildItem(element);
|
||||
return _buildEntry(element);
|
||||
},
|
||||
),
|
||||
SliverList.list(
|
||||
children: _inRealms.entries.map((element) {
|
||||
return ExpansionTile(
|
||||
tilePadding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
tilePadding: const EdgeInsets.only(left: 20, right: 24),
|
||||
minTileHeight: 48,
|
||||
title: Text(element.value.first.realm!.name),
|
||||
leading: CircleAvatar(
|
||||
@@ -177,7 +209,7 @@ class _ChannelListWidgetState extends State<ChannelListWidget> {
|
||||
size: widget.isDense ? 12 : 16,
|
||||
),
|
||||
),
|
||||
children: element.value.map((x) => buildItem(x)).toList(),
|
||||
children: element.value.map((x) => _buildEntry(x)).toList(),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
|
||||
@@ -57,7 +57,7 @@ class _ChannelMemberListPopupState extends State<ChannelMemberListPopup> {
|
||||
setState(() => _isBusy = false);
|
||||
}
|
||||
|
||||
void promptAddMember() async {
|
||||
void _promptAddMember() async {
|
||||
final input = await showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
@@ -141,7 +141,7 @@ class _ChannelMemberListPopupState extends State<ChannelMemberListPopup> {
|
||||
'channelMembersAddHint'
|
||||
.trParams({'channel': '#${widget.channel.alias}'}),
|
||||
),
|
||||
onTap: () => promptAddMember(),
|
||||
onTap: () => _promptAddMember(),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
@@ -160,7 +160,7 @@ class _ChannelMemberListPopupState extends State<ChannelMemberListPopup> {
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
context: context,
|
||||
builder: (context) => AccountProfilePopup(
|
||||
account: element.account,
|
||||
name: element.account.name,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -23,7 +23,7 @@ class ControlsWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
CameraPosition position = CameraPosition.front;
|
||||
CameraPosition _position = CameraPosition.front;
|
||||
|
||||
List<MediaDevice>? _audioInputs;
|
||||
List<MediaDevice>? _audioOutputs;
|
||||
@@ -36,25 +36,25 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
participant.addListener(onChange);
|
||||
_participant.addListener(onChange);
|
||||
_subscription = Hardware.instance.onDeviceChange.stream
|
||||
.listen((List<MediaDevice> devices) {
|
||||
revertDevices(devices);
|
||||
_revertDevices(devices);
|
||||
});
|
||||
Hardware.instance.enumerateDevices().then(revertDevices);
|
||||
Hardware.instance.enumerateDevices().then(_revertDevices);
|
||||
_speakerphoneOn = Hardware.instance.speakerOn ?? false;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_subscription?.cancel();
|
||||
participant.removeListener(onChange);
|
||||
_participant.removeListener(onChange);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
LocalParticipant get participant => widget.participant;
|
||||
LocalParticipant get _participant => widget.participant;
|
||||
|
||||
void revertDevices(List<MediaDevice> devices) async {
|
||||
void _revertDevices(List<MediaDevice> devices) async {
|
||||
_audioInputs = devices.where((d) => d.kind == 'audioinput').toList();
|
||||
_audioOutputs = devices.where((d) => d.kind == 'audiooutput').toList();
|
||||
_videoInputs = devices.where((d) => d.kind == 'videoinput').toList();
|
||||
@@ -63,7 +63,7 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
|
||||
void onChange() => setState(() {});
|
||||
|
||||
bool get isMuted => participant.isMuted;
|
||||
bool get isMuted => _participant.isMuted;
|
||||
|
||||
Future<bool?> showDisconnectDialog() {
|
||||
return showDialog<bool>(
|
||||
@@ -85,7 +85,7 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
void disconnect() async {
|
||||
void _disconnect() async {
|
||||
if (await showDisconnectDialog() != true) return;
|
||||
|
||||
final ChatCallProvider provider = Get.find();
|
||||
@@ -95,59 +95,59 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
void disableAudio() async {
|
||||
await participant.setMicrophoneEnabled(false);
|
||||
void _disableAudio() async {
|
||||
await _participant.setMicrophoneEnabled(false);
|
||||
}
|
||||
|
||||
void enableAudio() async {
|
||||
await participant.setMicrophoneEnabled(true);
|
||||
void _enableAudio() async {
|
||||
await _participant.setMicrophoneEnabled(true);
|
||||
}
|
||||
|
||||
void disableVideo() async {
|
||||
await participant.setCameraEnabled(false);
|
||||
void _disableVideo() async {
|
||||
await _participant.setCameraEnabled(false);
|
||||
}
|
||||
|
||||
void enableVideo() async {
|
||||
await participant.setCameraEnabled(true);
|
||||
void _enableVideo() async {
|
||||
await _participant.setCameraEnabled(true);
|
||||
}
|
||||
|
||||
void selectAudioOutput(MediaDevice device) async {
|
||||
void _selectAudioOutput(MediaDevice device) async {
|
||||
await widget.room.setAudioOutputDevice(device);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void selectAudioInput(MediaDevice device) async {
|
||||
void _selectAudioInput(MediaDevice device) async {
|
||||
await widget.room.setAudioInputDevice(device);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void selectVideoInput(MediaDevice device) async {
|
||||
void _selectVideoInput(MediaDevice device) async {
|
||||
await widget.room.setVideoInputDevice(device);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void setSpeakerphoneOn() {
|
||||
void _setSpeakerphoneOn() {
|
||||
_speakerphoneOn = !_speakerphoneOn;
|
||||
Hardware.instance.setSpeakerphoneOn(_speakerphoneOn);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void toggleCamera() async {
|
||||
final track = participant.videoTrackPublications.firstOrNull?.track;
|
||||
void _toggleCamera() async {
|
||||
final track = _participant.videoTrackPublications.firstOrNull?.track;
|
||||
if (track == null) return;
|
||||
|
||||
try {
|
||||
final newPosition = position.switched();
|
||||
final newPosition = _position.switched();
|
||||
await track.setCameraPosition(newPosition);
|
||||
setState(() {
|
||||
position = newPosition;
|
||||
_position = newPosition;
|
||||
});
|
||||
} catch (error) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void enableScreenShare() async {
|
||||
void _enableScreenShare() async {
|
||||
if (lkPlatformIsDesktop()) {
|
||||
try {
|
||||
final source = await showDialog<DesktopCapturerSource>(
|
||||
@@ -163,7 +163,7 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
maxFrameRate: 15.0,
|
||||
),
|
||||
);
|
||||
await participant.publishVideoTrack(track);
|
||||
await _participant.publishVideoTrack(track);
|
||||
} catch (e) {
|
||||
final message = e.toString();
|
||||
context.showErrorDialog(message);
|
||||
@@ -177,7 +177,7 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
maxFrameRate: 30.0,
|
||||
),
|
||||
);
|
||||
await participant.publishVideoTrack(track);
|
||||
await _participant.publishVideoTrack(track);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -188,11 +188,11 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
return;
|
||||
}
|
||||
|
||||
await participant.setScreenShareEnabled(true, captureScreenAudio: true);
|
||||
await _participant.setScreenShareEnabled(true, captureScreenAudio: true);
|
||||
}
|
||||
|
||||
void disableScreenShare() async {
|
||||
await participant.setScreenShareEnabled(false);
|
||||
void _disableScreenShare() async {
|
||||
await _participant.setScreenShareEnabled(false);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -210,12 +210,12 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
icon: Transform.flip(
|
||||
flipX: true, child: const Icon(Icons.exit_to_app)),
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
onPressed: disconnect,
|
||||
onPressed: _disconnect,
|
||||
),
|
||||
if (participant.isMicrophoneEnabled())
|
||||
if (_participant.isMicrophoneEnabled())
|
||||
if (lkPlatformIs(PlatformType.android))
|
||||
IconButton(
|
||||
onPressed: disableAudio,
|
||||
onPressed: _disableAudio,
|
||||
icon: const Icon(Icons.mic),
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
tooltip: 'callMicrophoneOff'.tr,
|
||||
@@ -227,7 +227,7 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
return [
|
||||
PopupMenuItem<MediaDevice>(
|
||||
value: null,
|
||||
onTap: isMuted ? enableAudio : disableAudio,
|
||||
onTap: isMuted ? _enableAudio : _disableAudio,
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.mic_off),
|
||||
title: Text(isMuted
|
||||
@@ -246,7 +246,7 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
: const Icon(Icons.check_box_outline_blank),
|
||||
title: Text(device.label),
|
||||
),
|
||||
onTap: () => selectAudioInput(device),
|
||||
onTap: () => _selectAudioInput(device),
|
||||
);
|
||||
})
|
||||
];
|
||||
@@ -254,19 +254,19 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
)
|
||||
else
|
||||
IconButton(
|
||||
onPressed: enableAudio,
|
||||
onPressed: _enableAudio,
|
||||
icon: const Icon(Icons.mic_off),
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
tooltip: 'callMicrophoneOn'.tr,
|
||||
),
|
||||
if (participant.isCameraEnabled())
|
||||
if (_participant.isCameraEnabled())
|
||||
PopupMenuButton<MediaDevice>(
|
||||
icon: const Icon(Icons.videocam_sharp),
|
||||
itemBuilder: (BuildContext context) {
|
||||
return [
|
||||
PopupMenuItem<MediaDevice>(
|
||||
value: null,
|
||||
onTap: disableVideo,
|
||||
onTap: _disableVideo,
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.videocam_off),
|
||||
title: Text('callCameraOff'.tr),
|
||||
@@ -283,7 +283,7 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
: const Icon(Icons.check_box_outline_blank),
|
||||
title: Text(device.label),
|
||||
),
|
||||
onTap: () => selectVideoInput(device),
|
||||
onTap: () => _selectVideoInput(device),
|
||||
);
|
||||
})
|
||||
];
|
||||
@@ -291,17 +291,17 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
)
|
||||
else
|
||||
IconButton(
|
||||
onPressed: enableVideo,
|
||||
onPressed: _enableVideo,
|
||||
icon: const Icon(Icons.videocam_off),
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
tooltip: 'callCameraOn'.tr,
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(position == CameraPosition.back
|
||||
icon: Icon(_position == CameraPosition.back
|
||||
? Icons.video_camera_back
|
||||
: Icons.video_camera_front),
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
onPressed: () => toggleCamera(),
|
||||
onPressed: () => _toggleCamera(),
|
||||
tooltip: 'callVideoFlip'.tr,
|
||||
),
|
||||
if (!lkPlatformIs(PlatformType.iOS))
|
||||
@@ -327,7 +327,7 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
: const Icon(Icons.check_box_outline_blank),
|
||||
title: Text(device.label),
|
||||
),
|
||||
onTap: () => selectAudioOutput(device),
|
||||
onTap: () => _selectAudioOutput(device),
|
||||
);
|
||||
})
|
||||
];
|
||||
@@ -336,7 +336,7 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
if (!kIsWeb && lkPlatformIs(PlatformType.iOS))
|
||||
IconButton(
|
||||
onPressed: Hardware.instance.canSwitchSpeakerphone
|
||||
? setSpeakerphoneOn
|
||||
? _setSpeakerphoneOn
|
||||
: null,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
icon: Icon(
|
||||
@@ -344,18 +344,18 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
),
|
||||
tooltip: 'callSpeakerphoneToggle'.tr,
|
||||
),
|
||||
if (participant.isScreenShareEnabled())
|
||||
if (_participant.isScreenShareEnabled())
|
||||
IconButton(
|
||||
icon: const Icon(Icons.monitor_outlined),
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
onPressed: () => disableScreenShare(),
|
||||
onPressed: () => _disableScreenShare(),
|
||||
tooltip: 'callScreenOff'.tr,
|
||||
)
|
||||
else
|
||||
IconButton(
|
||||
icon: const Icon(Icons.monitor),
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
onPressed: () => enableScreenShare(),
|
||||
onPressed: () => _enableScreenShare(),
|
||||
tooltip: 'callScreenOn'.tr,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -201,7 +201,7 @@ class InteractiveParticipantWidget extends StatelessWidget {
|
||||
final double? width;
|
||||
final double? height;
|
||||
final Color? color;
|
||||
final bool isFixed;
|
||||
final bool isFixedAvatar;
|
||||
final ParticipantTrack participant;
|
||||
final Function() onTap;
|
||||
|
||||
@@ -210,35 +210,32 @@ class InteractiveParticipantWidget extends StatelessWidget {
|
||||
this.width,
|
||||
this.height,
|
||||
this.color,
|
||||
this.isFixed = false,
|
||||
this.isFixedAvatar = false,
|
||||
required this.participant,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
child: Container(
|
||||
width: width,
|
||||
height: height,
|
||||
color: color,
|
||||
child: ParticipantWidget.widgetFor(participant, isFixed: isFixed),
|
||||
),
|
||||
onTap: () => onTap(),
|
||||
onLongPress: () {
|
||||
if (participant.participant is LocalParticipant) return;
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (context) => ParticipantMenu(
|
||||
participant: participant.participant as RemoteParticipant,
|
||||
videoTrack: participant.videoTrack,
|
||||
isScreenShare: participant.isScreenShare,
|
||||
),
|
||||
);
|
||||
},
|
||||
return GestureDetector(
|
||||
child: Container(
|
||||
width: width,
|
||||
height: height,
|
||||
color: color,
|
||||
child: ParticipantWidget.widgetFor(participant, isFixed: isFixedAvatar),
|
||||
),
|
||||
onTap: () => onTap(),
|
||||
onLongPress: () {
|
||||
if (participant.participant is LocalParticipant) return;
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (context) => ParticipantMenu(
|
||||
participant: participant.participant as RemoteParticipant,
|
||||
videoTrack: participant.videoTrack,
|
||||
isScreenShare: participant.isScreenShare,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:livekit_client/livekit_client.dart';
|
||||
|
||||
class ParticipantInfoWidget extends StatelessWidget {
|
||||
@@ -34,38 +35,42 @@ class ParticipantInfoWidget extends StatelessWidget {
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
isScreenShare
|
||||
? const Padding(
|
||||
padding: EdgeInsets.only(left: 5),
|
||||
child: Icon(
|
||||
Icons.monitor,
|
||||
color: Colors.white,
|
||||
size: 16,
|
||||
),
|
||||
? const Icon(
|
||||
Icons.monitor,
|
||||
color: Colors.white,
|
||||
size: 16,
|
||||
)
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(left: 5),
|
||||
child: Icon(
|
||||
audioAvailable ? Icons.mic : Icons.mic_off,
|
||||
color: audioAvailable ? Colors.white : Colors.red,
|
||||
size: 16,
|
||||
),
|
||||
: Icon(
|
||||
audioAvailable ? Icons.mic : Icons.mic_off,
|
||||
color: audioAvailable ? Colors.white : Colors.red,
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(width: 3),
|
||||
if (connectionQuality != ConnectionQuality.unknown)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 5),
|
||||
child: Icon(
|
||||
connectionQuality == ConnectionQuality.poor
|
||||
? Icons.wifi_off_outlined
|
||||
: Icons.wifi,
|
||||
color: {
|
||||
ConnectionQuality.excellent: Colors.green,
|
||||
ConnectionQuality.good: Colors.orange,
|
||||
ConnectionQuality.poor: Colors.red,
|
||||
}[connectionQuality],
|
||||
size: 16,
|
||||
Icon(
|
||||
{
|
||||
ConnectionQuality.excellent: Icons.signal_cellular_alt,
|
||||
ConnectionQuality.good: Icons.signal_cellular_alt_2_bar,
|
||||
ConnectionQuality.poor: Icons.signal_cellular_alt_1_bar,
|
||||
}[connectionQuality],
|
||||
color: {
|
||||
ConnectionQuality.excellent: Colors.green,
|
||||
ConnectionQuality.good: Colors.orange,
|
||||
ConnectionQuality.poor: Colors.red,
|
||||
}[connectionQuality],
|
||||
size: 16,
|
||||
)
|
||||
else
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
height: 12,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
),
|
||||
).paddingAll(3),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -9,19 +9,21 @@ class ChatCallCurrentIndicator extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final ChatCallProvider provider = Get.find();
|
||||
|
||||
if (provider.current.value == null || provider.channel.value == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
return Obx(() {
|
||||
if (provider.current.value == null || provider.channel.value == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
|
||||
return ListTile(
|
||||
tileColor: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 32),
|
||||
leading: const Icon(Icons.call),
|
||||
title: Text(provider.channel.value!.name),
|
||||
subtitle: Text('callAlreadyOngoing'.tr),
|
||||
onTap: () {
|
||||
provider.gotoScreen(context);
|
||||
},
|
||||
);
|
||||
return ListTile(
|
||||
tileColor: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 32),
|
||||
leading: const Icon(Icons.call),
|
||||
title: Text(provider.channel.value!.name),
|
||||
subtitle: Text('callAlreadyOngoing'.tr),
|
||||
onTap: () {
|
||||
provider.gotoScreen(context);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,13 +37,33 @@ class ChatEvent extends StatelessWidget {
|
||||
return '$negativeSign${twoDigits(duration.inHours)}:$twoDigitMinutes:$twoDigitSeconds';
|
||||
}
|
||||
|
||||
Widget _buildAttachment(BuildContext context) {
|
||||
Widget _buildAttachment(BuildContext context, {bool isMinimal = false}) {
|
||||
final attachments = item.body['attachments'] != null
|
||||
? List<int>.from(item.body['attachments'].map((x) => x))
|
||||
: List<int>.empty();
|
||||
|
||||
if (attachments.isEmpty) return const SizedBox();
|
||||
|
||||
if (isMinimal) {
|
||||
final unFocusColor =
|
||||
Theme.of(context).colorScheme.onSurface.withOpacity(0.75);
|
||||
return Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.attachment,
|
||||
size: 18,
|
||||
color: unFocusColor,
|
||||
).paddingOnly(right: 6),
|
||||
Text(
|
||||
'attachmentHint'.trParams(
|
||||
{'count': attachments.length.toString()},
|
||||
),
|
||||
style: TextStyle(color: unFocusColor),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Container(
|
||||
key: Key('m${item.uuid}attachments-box'),
|
||||
width: MediaQuery.of(context).size.width,
|
||||
@@ -92,7 +112,9 @@ class ChatEvent extends StatelessWidget {
|
||||
case 'messages.edit':
|
||||
return ChatEventMessageActionLog(
|
||||
icon: const Icon(Icons.edit_note, size: 16),
|
||||
text: 'messageEditDesc'.trParams({'id': '#${item.id}'}),
|
||||
text: 'messageEditDesc'.trParams({
|
||||
'id': '#${item.body['related_event']}',
|
||||
}),
|
||||
isMerged: isMerged,
|
||||
isHasMerged: isHasMerged,
|
||||
isQuote: isQuote,
|
||||
@@ -100,7 +122,9 @@ class ChatEvent extends StatelessWidget {
|
||||
case 'messages.delete':
|
||||
return ChatEventMessageActionLog(
|
||||
icon: const Icon(Icons.cancel_schedule_send, size: 16),
|
||||
text: 'messageDeleteDesc'.trParams({'id': '#${item.id}'}),
|
||||
text: 'messageDeleteDesc'.trParams({
|
||||
'id': '#${item.body['related_event']}',
|
||||
}),
|
||||
isMerged: isMerged,
|
||||
isHasMerged: isHasMerged,
|
||||
isQuote: isQuote,
|
||||
@@ -164,7 +188,8 @@ class ChatEvent extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
).paddingOnly(right: 12),
|
||||
_buildAttachment(context),
|
||||
_buildAttachment(context, isMinimal: isContentPreviewing)
|
||||
.paddingOnly(left: isContentPreviewing ? 12 : 0),
|
||||
],
|
||||
);
|
||||
} else if (isQuote) {
|
||||
@@ -218,7 +243,7 @@ class ChatEvent extends StatelessWidget {
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
context: context,
|
||||
builder: (context) => AccountProfilePopup(
|
||||
account: item.sender.account,
|
||||
name: item.sender.account.name,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_animate/flutter_animate.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/controllers/chat_events_controller.dart';
|
||||
import 'package:solian/models/channel.dart';
|
||||
@@ -23,7 +24,7 @@ class ChatEventList extends StatelessWidget {
|
||||
required this.onReply,
|
||||
});
|
||||
|
||||
bool checkMessageMergeable(Event? a, Event? b) {
|
||||
bool _checkMessageMergeable(Event? a, Event? b) {
|
||||
if (a == null || b == null) return false;
|
||||
if (a.sender.account.id != b.sender.account.id) return false;
|
||||
return a.createdAt.difference(b.createdAt).inMinutes <= 3;
|
||||
@@ -41,13 +42,13 @@ class ChatEventList extends StatelessWidget {
|
||||
itemBuilder: (context, index) {
|
||||
bool isMerged = false, hasMerged = false;
|
||||
if (index > 0) {
|
||||
hasMerged = checkMessageMergeable(
|
||||
hasMerged = _checkMessageMergeable(
|
||||
chatController.currentEvents[index - 1].data,
|
||||
chatController.currentEvents[index].data,
|
||||
);
|
||||
}
|
||||
if (index + 1 < chatController.currentEvents.length) {
|
||||
isMerged = checkMessageMergeable(
|
||||
isMerged = _checkMessageMergeable(
|
||||
chatController.currentEvents[index].data,
|
||||
chatController.currentEvents[index + 1].data,
|
||||
);
|
||||
@@ -82,7 +83,12 @@ class ChatEventList extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
).animate(key: Key('m-animation${item.uuid}')).slideY(
|
||||
duration: 250.ms,
|
||||
curve: Curves.fastEaseInToSlowEaseOut,
|
||||
end: 0,
|
||||
begin: 0.5,
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
|
||||
@@ -24,7 +24,8 @@ class ChatEventMessage extends StatelessWidget {
|
||||
final hasAttachment = body.attachments?.isNotEmpty ?? false;
|
||||
|
||||
if (body.text.isEmpty && hasAttachment) {
|
||||
final unFocusColor = Theme.of(context).colorScheme.onSurface.withOpacity(0.75);
|
||||
final unFocusColor =
|
||||
Theme.of(context).colorScheme.onSurface.withOpacity(0.75);
|
||||
return Row(
|
||||
children: [
|
||||
Icon(
|
||||
@@ -33,7 +34,7 @@ class ChatEventMessage extends StatelessWidget {
|
||||
color: unFocusColor,
|
||||
).paddingOnly(right: 6),
|
||||
Text(
|
||||
'postAttachmentTip'.trParams(
|
||||
'attachmentHint'.trParams(
|
||||
{'count': body.attachments?.length.toString() ?? 0.toString()},
|
||||
),
|
||||
style: TextStyle(color: unFocusColor),
|
||||
@@ -46,9 +47,7 @@ class ChatEventMessage extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildBody(BuildContext context) {
|
||||
if (isContentPreviewing) {
|
||||
return _buildContent(context);
|
||||
} else if (isMerged) {
|
||||
if (isMerged) {
|
||||
return _buildContent(context).paddingOnly(left: 52);
|
||||
} else {
|
||||
return _buildContent(context);
|
||||
@@ -64,7 +63,7 @@ class ChatEventMessage extends StatelessWidget {
|
||||
left: isQuote ? 0 : 12,
|
||||
right: isQuote ? 0 : 12,
|
||||
top: body.quoteEvent == null ? 2 : 0,
|
||||
bottom: hasAttachment ? 4 : (isHasMerged ? 2 : 0),
|
||||
bottom: hasAttachment && !isContentPreviewing ? 4 : (isHasMerged ? 2 : 0),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,11 @@ import 'package:solian/exts.dart';
|
||||
import 'package:solian/models/account.dart';
|
||||
import 'package:solian/models/channel.dart';
|
||||
import 'package:solian/models/event.dart';
|
||||
import 'package:solian/providers/attachment_uploader.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/widgets/attachments/attachment_editor.dart';
|
||||
import 'package:solian/widgets/chat/chat_event.dart';
|
||||
import 'package:badges/badges.dart' as badges;
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class ChatMessageInput extends StatefulWidget {
|
||||
@@ -38,47 +40,92 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
|
||||
final TextEditingController _textController = TextEditingController();
|
||||
final FocusNode _focusNode = FocusNode();
|
||||
|
||||
List<int> _attachments = List.empty(growable: true);
|
||||
final List<int> _attachments = List.empty(growable: true);
|
||||
|
||||
Event? _editTo;
|
||||
Event? _replyTo;
|
||||
|
||||
void showAttachments() {
|
||||
void _editAttachments() {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
builder: (context) => AttachmentEditorPopup(
|
||||
usage: 'm.attachment',
|
||||
current: _attachments,
|
||||
onUpdate: (value) => _attachments = value,
|
||||
initialAttachments: _attachments,
|
||||
onAdd: (value) {
|
||||
setState(() {
|
||||
_attachments.add(value);
|
||||
});
|
||||
},
|
||||
onRemove: (value) {
|
||||
setState(() {
|
||||
_attachments.remove(value);
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> sendMessage() async {
|
||||
List<String> _findMentionedUsers(String text) {
|
||||
RegExp regExp = RegExp(r'@[a-zA-Z0-9_]+');
|
||||
Iterable<RegExpMatch> matches = regExp.allMatches(text);
|
||||
|
||||
List<String> mentionedUsers =
|
||||
matches.map((match) => match.group(0)!.substring(1)).toList();
|
||||
|
||||
return mentionedUsers;
|
||||
}
|
||||
|
||||
Future<void> _sendMessage() async {
|
||||
_focusNode.requestFocus();
|
||||
|
||||
final AuthProvider auth = Get.find();
|
||||
final prof = auth.userProfile.value!;
|
||||
if (auth.isAuthorized.isFalse) return;
|
||||
|
||||
final client = auth.configureClient('messaging');
|
||||
final AttachmentUploaderController uploader = Get.find();
|
||||
if (uploader.queueOfUpload.any(
|
||||
((x) => x.usage == 'm.attachment' && x.isUploading),
|
||||
)) {
|
||||
context.showErrorDialog('attachmentUploadInProgress'.tr);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO Deal with the @ ping (query uid with username), and then add into related_user and replace the @ with internal link in body
|
||||
Response resp;
|
||||
|
||||
final mentionedUserNames = _findMentionedUsers(_textController.text);
|
||||
final mentionedUserIds = List<int>.empty(growable: true);
|
||||
|
||||
var client = auth.configureClient('auth');
|
||||
if (mentionedUserNames.isNotEmpty) {
|
||||
resp = await client.get('/users?name=${mentionedUserNames.join(',')}');
|
||||
if (resp.statusCode != 200) {
|
||||
context.showErrorDialog(resp.bodyString);
|
||||
return;
|
||||
} else {
|
||||
mentionedUserIds.addAll(
|
||||
resp.body.map((x) => Account.fromJson(x).id).toList().cast<int>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
client = auth.configureClient('messaging');
|
||||
|
||||
const uuid = Uuid();
|
||||
final payload = {
|
||||
'uuid': uuid.v4(),
|
||||
'type': _editTo == null ? 'messages.new' : 'messages.edit',
|
||||
'body': {
|
||||
'text': _textController.value.text,
|
||||
'text': _textController.text,
|
||||
'algorithm': 'plain',
|
||||
'attachments': List.from(_attachments),
|
||||
'related_users': [
|
||||
if (_replyTo != null) _replyTo!.sender.accountId,
|
||||
...mentionedUserIds,
|
||||
],
|
||||
if (_replyTo != null) 'quote_event': _replyTo!.id,
|
||||
if (_editTo != null) 'related_event': _editTo!.id,
|
||||
if (_editTo != null && _editTo!.body['quote_event'] != null)
|
||||
'quote_event': _editTo!.body['quote_event'],
|
||||
}
|
||||
};
|
||||
|
||||
@@ -111,7 +158,6 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
|
||||
|
||||
resetInput();
|
||||
|
||||
Response resp;
|
||||
if (_editTo != null) {
|
||||
resp = await client.put(
|
||||
'/channels/${widget.realm}/${widget.channel.alias}/messages/${_editTo!.id}',
|
||||
@@ -217,20 +263,31 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
|
||||
{'channel': '#${widget.channel.alias}'},
|
||||
),
|
||||
),
|
||||
onSubmitted: (_) => sendMessage(),
|
||||
onSubmitted: (_) => _sendMessage(),
|
||||
onTapOutside: (_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.attach_file),
|
||||
icon: badges.Badge(
|
||||
badgeContent: Text(
|
||||
_attachments.length.toString(),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
showBadge: _attachments.isNotEmpty,
|
||||
position: badges.BadgePosition.topEnd(
|
||||
top: -12,
|
||||
end: -8,
|
||||
),
|
||||
child: const Icon(Icons.file_present_rounded),
|
||||
),
|
||||
color: Colors.teal,
|
||||
onPressed: () => showAttachments(),
|
||||
onPressed: () => _editAttachments(),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.send),
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
onPressed: () => sendMessage(),
|
||||
onPressed: () => _sendMessage(),
|
||||
)
|
||||
],
|
||||
).paddingOnly(left: 20, right: 16),
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_markdown_selectionarea/flutter_markdown.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:markdown/markdown.dart' as markdown;
|
||||
import 'package:markdown/markdown.dart';
|
||||
import 'package:solian/providers/stickers.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
import 'account/account_profile_popup.dart';
|
||||
|
||||
class MarkdownTextContent extends StatelessWidget {
|
||||
final String content;
|
||||
final bool isSelectable;
|
||||
@@ -19,7 +24,9 @@ class MarkdownTextContent extends StatelessWidget {
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
data: content,
|
||||
padding: EdgeInsets.zero,
|
||||
styleSheet: MarkdownStyleSheet.fromTheme(Theme.of(context)).copyWith(
|
||||
styleSheet: MarkdownStyleSheet.fromTheme(
|
||||
Theme.of(context),
|
||||
).copyWith(
|
||||
horizontalRuleDecoration: BoxDecoration(
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
@@ -32,6 +39,8 @@ class MarkdownTextContent extends StatelessWidget {
|
||||
extensionSet: markdown.ExtensionSet(
|
||||
markdown.ExtensionSet.gitHubFlavored.blockSyntaxes,
|
||||
<markdown.InlineSyntax>[
|
||||
_UserNameCardInlineSyntax(),
|
||||
_CustomEmoteInlineSyntax(),
|
||||
markdown.EmojiSyntax(),
|
||||
markdown.AutolinkExtensionSyntax(),
|
||||
...markdown.ExtensionSet.gitHubFlavored.inlineSyntaxes
|
||||
@@ -39,6 +48,23 @@ class MarkdownTextContent extends StatelessWidget {
|
||||
),
|
||||
onTapLink: (text, href, title) async {
|
||||
if (href == null) return;
|
||||
if (href.startsWith('solink://')) {
|
||||
final segments = href.replaceFirst('solink://', '').split('/');
|
||||
switch (segments[0]) {
|
||||
case 'users':
|
||||
showModalBottomSheet(
|
||||
useRootNavigator: true,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
context: context,
|
||||
builder: (context) => AccountProfilePopup(
|
||||
name: segments[1],
|
||||
),
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
await launchUrlString(
|
||||
href,
|
||||
mode: LaunchMode.externalApplication,
|
||||
@@ -55,3 +81,39 @@ class MarkdownTextContent extends StatelessWidget {
|
||||
return _buildContent(context);
|
||||
}
|
||||
}
|
||||
|
||||
class _UserNameCardInlineSyntax extends InlineSyntax {
|
||||
_UserNameCardInlineSyntax() : super(r'@[a-zA-Z0-9_]+');
|
||||
|
||||
@override
|
||||
bool onMatch(markdown.InlineParser parser, Match match) {
|
||||
final alias = match[0]!;
|
||||
final anchor = markdown.Element.text('a', alias)
|
||||
..attributes['href'] = Uri.encodeFull(
|
||||
'solink://users/${alias.substring(1)}',
|
||||
);
|
||||
parser.addNode(anchor);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class _CustomEmoteInlineSyntax extends InlineSyntax {
|
||||
_CustomEmoteInlineSyntax() : super(r':([a-z0-9_+-]+):');
|
||||
|
||||
@override
|
||||
bool onMatch(markdown.InlineParser parser, Match match) {
|
||||
final StickerProvider sticker = Get.find();
|
||||
final alias = match[1]!;
|
||||
if (sticker.aliasImageMapping[alias] == null) {
|
||||
parser.advanceBy(1);
|
||||
return false;
|
||||
}
|
||||
|
||||
final element = markdown.Element.empty('img');
|
||||
element.attributes['src'] = sticker.aliasImageMapping[alias]!;
|
||||
parser.addNode(element);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:solian/models/account_status.dart';
|
||||
import 'package:solian/providers/account_status.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/providers/content/channel.dart';
|
||||
import 'package:solian/providers/relation.dart';
|
||||
import 'package:solian/router.dart';
|
||||
import 'package:solian/shells/root_shell.dart';
|
||||
import 'package:solian/theme.dart';
|
||||
@@ -29,7 +30,7 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
||||
|
||||
late final ChannelProvider _channels;
|
||||
|
||||
void getStatus() async {
|
||||
Future<void> _getStatus() async {
|
||||
final StatusProvider provider = Get.find();
|
||||
|
||||
final resp = await provider.getCurrentStatus();
|
||||
@@ -40,7 +41,7 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
||||
});
|
||||
}
|
||||
|
||||
void detectSelectedIndex() {
|
||||
void _detectSelectedIndex() {
|
||||
if (widget.routeName == null) return;
|
||||
|
||||
final nameList = AppNavigation.destinations.map((x) => x.page).toList();
|
||||
@@ -49,22 +50,32 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
||||
_selectedIndex = idx != -1 ? idx : null;
|
||||
}
|
||||
|
||||
void closeDrawer() {
|
||||
void _closeDrawer() {
|
||||
rootScaffoldKey.currentState!.closeDrawer();
|
||||
}
|
||||
|
||||
Widget _buildSettingButton() {
|
||||
return IconButton(
|
||||
icon: const Icon(Icons.settings),
|
||||
onPressed: () {
|
||||
AppRouter.instance.pushNamed('settings');
|
||||
setState(() => _selectedIndex = null);
|
||||
_closeDrawer();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_channels = Get.find();
|
||||
detectSelectedIndex();
|
||||
getStatus();
|
||||
_detectSelectedIndex();
|
||||
_getStatus();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
detectSelectedIndex();
|
||||
_detectSelectedIndex();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -78,7 +89,7 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
||||
onDestinationSelected: (idx) {
|
||||
setState(() => _selectedIndex = idx);
|
||||
AppRouter.instance.goNamed(AppNavigation.destinations[idx].page);
|
||||
closeDrawer();
|
||||
_closeDrawer();
|
||||
},
|
||||
children: [
|
||||
Obx(() {
|
||||
@@ -88,10 +99,11 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
||||
leading: const Icon(Icons.account_circle),
|
||||
title: Text('guest'.tr),
|
||||
subtitle: Text('unsignedIn'.tr),
|
||||
trailing: _buildSettingButton(),
|
||||
onTap: () {
|
||||
AppRouter.instance.goNamed('account');
|
||||
setState(() => _selectedIndex = null);
|
||||
closeDrawer();
|
||||
_closeDrawer();
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -118,43 +130,55 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
||||
);
|
||||
},
|
||||
),
|
||||
leading: Builder(builder: (context) {
|
||||
final badgeColor = _accountStatus != null
|
||||
leading: Obx(() {
|
||||
final statusBadgeColor = _accountStatus != null
|
||||
? StatusProvider.determineStatus(
|
||||
_accountStatus!,
|
||||
).$2
|
||||
: Colors.grey;
|
||||
|
||||
final RelationshipProvider relations = Get.find();
|
||||
final accountNotifications = relations.friendRequestCount.value;
|
||||
|
||||
return badges.Badge(
|
||||
showBadge: _accountStatus != null,
|
||||
badgeStyle: badges.BadgeStyle(badgeColor: badgeColor),
|
||||
position: badges.BadgePosition.bottomEnd(
|
||||
bottom: 0,
|
||||
end: -2,
|
||||
badgeContent: Text(
|
||||
accountNotifications.toString(),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
child: AccountAvatar(
|
||||
content: auth.userProfile.value!['avatar'],
|
||||
showBadge: accountNotifications > 0,
|
||||
position: badges.BadgePosition.topEnd(
|
||||
top: -10,
|
||||
end: -6,
|
||||
),
|
||||
child: badges.Badge(
|
||||
showBadge: _accountStatus != null,
|
||||
badgeStyle: badges.BadgeStyle(badgeColor: statusBadgeColor),
|
||||
position: badges.BadgePosition.bottomEnd(
|
||||
bottom: 0,
|
||||
end: -2,
|
||||
),
|
||||
child: AccountAvatar(
|
||||
content: auth.userProfile.value!['avatar'],
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.face_retouching_natural),
|
||||
onPressed: () {
|
||||
showModalBottomSheet(
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
builder: (context) => AccountStatusAction(
|
||||
currentStatus: _accountStatus!.status,
|
||||
),
|
||||
).then((val) {
|
||||
if (val == true) getStatus();
|
||||
});
|
||||
},
|
||||
),
|
||||
trailing: _buildSettingButton(),
|
||||
onTap: () {
|
||||
AppRouter.instance.goNamed('account');
|
||||
setState(() => _selectedIndex = null);
|
||||
closeDrawer();
|
||||
_closeDrawer();
|
||||
},
|
||||
onLongPress: () {
|
||||
showModalBottomSheet(
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
builder: (context) => AccountStatusAction(
|
||||
currentStatus: _accountStatus!.status,
|
||||
),
|
||||
).then((val) {
|
||||
if (val == true) _getStatus();
|
||||
});
|
||||
},
|
||||
);
|
||||
}).paddingOnly(top: 8),
|
||||
@@ -199,7 +223,7 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
||||
useReplace: true,
|
||||
onSelected: (_) {
|
||||
setState(() => _selectedIndex = null);
|
||||
closeDrawer();
|
||||
_closeDrawer();
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
@@ -16,8 +16,7 @@ class PostEditorCategoriesDialog extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TagsField(
|
||||
initialTags:
|
||||
controller.editTo.value?.tags?.map((x) => x.alias).toList(),
|
||||
initialTags: controller.tags,
|
||||
hintText: 'postTagsPlaceholder'.tr,
|
||||
onUpdate: (value) {
|
||||
controller.tags.value = value;
|
||||
|
||||