3rd person fix
3rd person fix
This commit is contained in:
@@ -61,6 +61,7 @@ extension ApiServiceChats on ApiService {
|
||||
"[_sendAuthRequestAfterHandshake] ✅ Профиль и ID пользователя найдены. ID: ${contactProfile['id']}. ЗАПУСКАЕМ АНАЛИТИКУ.",
|
||||
);
|
||||
_userId = contactProfile['id'];
|
||||
await prefs.setString('userId', _userId.toString());
|
||||
_sessionId = DateTime.now().millisecondsSinceEpoch;
|
||||
_lastActionTime = _sessionId;
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ class MyApp extends StatelessWidget {
|
||||
dynamicSchemeVariant: DynamicSchemeVariant.tonalSpot,
|
||||
),
|
||||
useMaterial3: true,
|
||||
pageTransitionsTheme: PageTransitionsTheme(builders: {TargetPlatform.android: CupertinoPageTransitionsBuilder()}),
|
||||
appBarTheme: AppBarTheme(
|
||||
titleTextStyle: TextStyle(
|
||||
fontSize: 16,
|
||||
@@ -152,12 +153,14 @@ class MyApp extends StatelessWidget {
|
||||
navigatorKey: navigatorKey,
|
||||
builder: (context, child) {
|
||||
final showHud = themeProvider.debugShowPerformanceOverlay;
|
||||
if (!showHud) return child ?? const SizedBox.shrink();
|
||||
return Stack(
|
||||
children: [
|
||||
if (child != null) child,
|
||||
const Positioned(top: 8, right: 56, child: _MiniFpsHud()),
|
||||
],
|
||||
return SizedBox.expand(
|
||||
child: Stack(
|
||||
children: [
|
||||
if (child != null) child,
|
||||
if (showHud)
|
||||
const Positioned(top: 8, right: 56, child: _MiniFpsHud()),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
theme: baseLightTheme,
|
||||
|
||||
@@ -24,6 +24,7 @@ import 'package:gwid/screens/edit_contact_screen.dart';
|
||||
import 'package:gwid/widgets/contact_name_widget.dart';
|
||||
import 'package:gwid/widgets/contact_avatar_widget.dart';
|
||||
import 'package:flutter_linkify/flutter_linkify.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
|
||||
@@ -343,6 +344,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
|
||||
Future<void> _initializeChat() async {
|
||||
await _loadCachedContacts();
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
if (!widget.isGroupChat && !widget.isChannel) {
|
||||
_contactDetailsCache[widget.contact.id] = widget.contact;
|
||||
@@ -357,7 +359,8 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
if (contactProfile != null &&
|
||||
contactProfile['id'] != null &&
|
||||
contactProfile['id'] != 0) {
|
||||
_actualMyId = contactProfile['id'];
|
||||
String? idStr = await prefs.getString("userId");
|
||||
_actualMyId = idStr!.isNotEmpty ? int.parse(idStr) : contactProfile['id'];
|
||||
print(
|
||||
'✅ [_initializeChat] ID пользователя получен из ApiService: $_actualMyId',
|
||||
);
|
||||
@@ -374,7 +377,8 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
);
|
||||
}
|
||||
} else if (_actualMyId == null) {
|
||||
_actualMyId = widget.myId;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
_actualMyId = int.parse(await prefs.getString('userId')!);;
|
||||
print(
|
||||
'⚠️ [_initializeChat] ID не найден, используется из виджета: $_actualMyId',
|
||||
);
|
||||
@@ -1129,13 +1133,13 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
|
||||
final int tempCid = DateTime.now().millisecondsSinceEpoch;
|
||||
final tempMessageJson = {
|
||||
'id': 'local_$tempCid', // Временный "локальный" ID
|
||||
'id': 'local_$tempCid',
|
||||
'text': text,
|
||||
'time': tempCid,
|
||||
'sender': _actualMyId!,
|
||||
'cid': tempCid, // Уникальный ID клиента
|
||||
'cid': tempCid,
|
||||
'type': 'USER',
|
||||
'attaches': [], // Оптимистично без вложений (для текста)
|
||||
'attaches': [],
|
||||
'link': _replyingToMessage != null
|
||||
? {
|
||||
'type': 'REPLY',
|
||||
@@ -1191,7 +1195,6 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
}
|
||||
|
||||
void _testSlideAnimation() {
|
||||
print('=== ТЕСТ SLIDE+ АНИМАЦИИ ===');
|
||||
|
||||
final myMessage = Message(
|
||||
id: 'test_my_${DateTime.now().millisecondsSinceEpoch}',
|
||||
@@ -1948,12 +1951,12 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
for (final contact in chatContacts) {
|
||||
_contactDetailsCache[contact.id] = contact;
|
||||
|
||||
if (contact.id == widget.myId && _actualMyId == null) {
|
||||
_actualMyId = contact.id;
|
||||
/*if (contact.id == widget.myId && _actualMyId == null) {
|
||||
//_actualMyId = contact.id;
|
||||
print(
|
||||
'✅ [_loadCachedContacts] Собственный ID восстановлен из кэша: $_actualMyId (${contact.name})',
|
||||
);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
print(
|
||||
'✅ Загружено ${_contactDetailsCache.length} контактов из кэша чата ${widget.chatId}',
|
||||
@@ -1968,7 +1971,9 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
_contactDetailsCache[contact.id] = contact;
|
||||
|
||||
if (contact.id == widget.myId && _actualMyId == null) {
|
||||
_actualMyId = contact.id;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
_actualMyId = int.parse(await prefs.getString('userId')!);
|
||||
print(
|
||||
'✅ [_loadCachedContacts] Собственный ID восстановлен из глобального кэша: $_actualMyId (${contact.name})',
|
||||
);
|
||||
@@ -4364,6 +4369,7 @@ extension BrightnessExtension on Brightness {
|
||||
bool get isDark => this == Brightness.dark;
|
||||
}
|
||||
|
||||
//note: unused
|
||||
class GroupProfileDraggableDialog extends StatelessWidget {
|
||||
final Contact contact;
|
||||
|
||||
@@ -4427,8 +4433,6 @@ class GroupProfileDraggableDialog extends StatelessWidget {
|
||||
IconButton(
|
||||
icon: Icon(Icons.settings, color: colors.primary),
|
||||
onPressed: () async {
|
||||
final myId = 0; // This should be passed or retrieved
|
||||
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
@@ -4436,7 +4440,7 @@ class GroupProfileDraggableDialog extends StatelessWidget {
|
||||
chatId: -contact
|
||||
.id, // Convert back to positive chatId
|
||||
initialContact: contact,
|
||||
myId: myId,
|
||||
myId: 0,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -270,9 +270,9 @@ class _ChatsScreenState extends State<ChatsScreen>
|
||||
|
||||
void _navigateToLogin() {
|
||||
print('Перенаправляем на экран входа из-за недействительного токена');
|
||||
Navigator.of(context).pushReplacement(
|
||||
/*Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(builder: (context) => const PhoneEntryScreen()),
|
||||
);
|
||||
);*/
|
||||
}
|
||||
|
||||
void _showTokenExpiredDialog(String message) {
|
||||
|
||||
@@ -1242,7 +1242,6 @@ class _DesktopLayoutState extends State<_DesktopLayout> {
|
||||
isChannel: _isChannel,
|
||||
participantCount: _participantCount,
|
||||
isDesktopMode: true,
|
||||
onChatUpdated: () {},
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -132,15 +132,21 @@ class _MusicLibraryScreenState extends State<MusicLibraryScreen> {
|
||||
return ValueListenableBuilder<bool>(
|
||||
valueListenable: BottomSheetMusicPlayer.isExpandedNotifier,
|
||||
builder: (context, isPlayerExpanded, child) {
|
||||
return PopScope(
|
||||
canPop: !isPlayerExpanded,
|
||||
onPopInvoked: (didPop) {
|
||||
if (!didPop && isPlayerExpanded) {
|
||||
BottomSheetMusicPlayer.isExpandedNotifier.value = false;
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(title: const Text('Музыка')),
|
||||
return ValueListenableBuilder<bool>(
|
||||
valueListenable: BottomSheetMusicPlayer.isFullscreenNotifier,
|
||||
builder: (context, isFullscreen, _) {
|
||||
return PopScope(
|
||||
canPop: !isPlayerExpanded,
|
||||
onPopInvoked: (didPop) {
|
||||
if (!didPop && isPlayerExpanded) {
|
||||
BottomSheetMusicPlayer.isExpandedNotifier.value = false;
|
||||
BottomSheetMusicPlayer.isFullscreenNotifier.value = false;
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: isFullscreen
|
||||
? null
|
||||
: AppBar(title: const Text('Музыка')),
|
||||
body: Stack(
|
||||
children: [
|
||||
_isLoading
|
||||
@@ -321,7 +327,9 @@ class _MusicLibraryScreenState extends State<MusicLibraryScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -56,7 +56,7 @@ class _OTPScreenState extends State<OTPScreen> {
|
||||
if (payload != null &&
|
||||
payload['tokenAttrs']?['LOGIN']?['token'] != null) {
|
||||
final String finalToken = payload['tokenAttrs']['LOGIN']['token'];
|
||||
final userId = payload['tokenAttrs']?['LOGIN']?['userId'];
|
||||
final userId = payload['payload']?['profile']?['contact']?['id'];
|
||||
print('Успешная авторизация! Токен: $finalToken, UserID: $userId');
|
||||
|
||||
ApiService.instance
|
||||
|
||||
@@ -200,18 +200,16 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("Настройки"),
|
||||
leading: widget.showBackToChats
|
||||
? IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: widget.onBackToChats,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
body: SafeArea(
|
||||
child: _buildSettingsContent(),
|
||||
),
|
||||
appBar: AppBar(
|
||||
title: const Text("Настройки"),
|
||||
/*leading: widget.showBackToChats
|
||||
? IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: widget.onBackToChats,
|
||||
)
|
||||
: null,*/
|
||||
),
|
||||
body: _buildSettingsContent(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -224,8 +222,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
final isSmallScreen = screenWidth < 600 || screenHeight < 800;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
body: Stack(
|
||||
body: SafeArea(
|
||||
child: Stack(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => Navigator.of(context).pop(),
|
||||
@@ -346,7 +344,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -104,6 +104,7 @@ class MusicPlayerService extends ChangeNotifier {
|
||||
StreamSubscription<Duration>? _positionSubscription;
|
||||
StreamSubscription<Duration?>? _durationSubscription;
|
||||
StreamSubscription<PlayerState>? _playerStateSubscription;
|
||||
bool _wasCompleted = false;
|
||||
|
||||
MusicTrack? get currentTrack =>
|
||||
_currentIndex >= 0 && _currentIndex < _playlist.length
|
||||
@@ -129,10 +130,20 @@ class MusicPlayerService extends ChangeNotifier {
|
||||
});
|
||||
|
||||
_playerStateSubscription = _audioPlayer.playerStateStream.listen((state) {
|
||||
final wasCompleted = _wasCompleted;
|
||||
_isPlaying = state.playing;
|
||||
_isLoading =
|
||||
state.processingState == ProcessingState.loading ||
|
||||
state.processingState == ProcessingState.buffering;
|
||||
|
||||
// Detect track completion and auto-play next track
|
||||
if (state.processingState == ProcessingState.completed && !wasCompleted) {
|
||||
_wasCompleted = true;
|
||||
_autoPlayNext();
|
||||
} else if (state.processingState != ProcessingState.completed) {
|
||||
_wasCompleted = false;
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
});
|
||||
|
||||
@@ -257,6 +268,20 @@ class MusicPlayerService extends ChangeNotifier {
|
||||
await savePlaylist();
|
||||
}
|
||||
|
||||
Future<void> _autoPlayNext() async {
|
||||
if (_playlist.isEmpty || _playlist.length <= 1) return;
|
||||
|
||||
try {
|
||||
_currentIndex = (_currentIndex + 1) % _playlist.length;
|
||||
await _loadAndPlayTrack(_playlist[_currentIndex]);
|
||||
await savePlaylist();
|
||||
} catch (e) {
|
||||
print('Error auto-playing next track: $e');
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> addToPlaylist(MusicTrack track) async {
|
||||
if (!_playlist.any((t) => t.id == track.id)) {
|
||||
_playlist.add(track);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user