3rd person fix

3rd person fix
This commit is contained in:
nyakokitsu
2025-11-30 23:35:13 +03:00
committed by GitHub
10 changed files with 655 additions and 383 deletions

View File

@@ -61,6 +61,7 @@ extension ApiServiceChats on ApiService {
"[_sendAuthRequestAfterHandshake] ✅ Профиль и ID пользователя найдены. ID: ${contactProfile['id']}. ЗАПУСКАЕМ АНАЛИТИКУ.", "[_sendAuthRequestAfterHandshake] ✅ Профиль и ID пользователя найдены. ID: ${contactProfile['id']}. ЗАПУСКАЕМ АНАЛИТИКУ.",
); );
_userId = contactProfile['id']; _userId = contactProfile['id'];
await prefs.setString('userId', _userId.toString());
_sessionId = DateTime.now().millisecondsSinceEpoch; _sessionId = DateTime.now().millisecondsSinceEpoch;
_lastActionTime = _sessionId; _lastActionTime = _sessionId;

View File

@@ -102,6 +102,7 @@ class MyApp extends StatelessWidget {
dynamicSchemeVariant: DynamicSchemeVariant.tonalSpot, dynamicSchemeVariant: DynamicSchemeVariant.tonalSpot,
), ),
useMaterial3: true, useMaterial3: true,
pageTransitionsTheme: PageTransitionsTheme(builders: {TargetPlatform.android: CupertinoPageTransitionsBuilder()}),
appBarTheme: AppBarTheme( appBarTheme: AppBarTheme(
titleTextStyle: TextStyle( titleTextStyle: TextStyle(
fontSize: 16, fontSize: 16,
@@ -152,12 +153,14 @@ class MyApp extends StatelessWidget {
navigatorKey: navigatorKey, navigatorKey: navigatorKey,
builder: (context, child) { builder: (context, child) {
final showHud = themeProvider.debugShowPerformanceOverlay; final showHud = themeProvider.debugShowPerformanceOverlay;
if (!showHud) return child ?? const SizedBox.shrink(); return SizedBox.expand(
return Stack( child: Stack(
children: [ children: [
if (child != null) child, if (child != null) child,
const Positioned(top: 8, right: 56, child: _MiniFpsHud()), if (showHud)
], const Positioned(top: 8, right: 56, child: _MiniFpsHud()),
],
),
); );
}, },
theme: baseLightTheme, theme: baseLightTheme,

View File

@@ -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_name_widget.dart';
import 'package:gwid/widgets/contact_avatar_widget.dart'; import 'package:gwid/widgets/contact_avatar_widget.dart';
import 'package:flutter_linkify/flutter_linkify.dart'; import 'package:flutter_linkify/flutter_linkify.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import 'package:video_player/video_player.dart'; import 'package:video_player/video_player.dart';
@@ -343,6 +344,7 @@ class _ChatScreenState extends State<ChatScreen> {
Future<void> _initializeChat() async { Future<void> _initializeChat() async {
await _loadCachedContacts(); await _loadCachedContacts();
final prefs = await SharedPreferences.getInstance();
if (!widget.isGroupChat && !widget.isChannel) { if (!widget.isGroupChat && !widget.isChannel) {
_contactDetailsCache[widget.contact.id] = widget.contact; _contactDetailsCache[widget.contact.id] = widget.contact;
@@ -357,7 +359,8 @@ class _ChatScreenState extends State<ChatScreen> {
if (contactProfile != null && if (contactProfile != null &&
contactProfile['id'] != null && contactProfile['id'] != null &&
contactProfile['id'] != 0) { contactProfile['id'] != 0) {
_actualMyId = contactProfile['id']; String? idStr = await prefs.getString("userId");
_actualMyId = idStr!.isNotEmpty ? int.parse(idStr) : contactProfile['id'];
print( print(
'✅ [_initializeChat] ID пользователя получен из ApiService: $_actualMyId', '✅ [_initializeChat] ID пользователя получен из ApiService: $_actualMyId',
); );
@@ -374,7 +377,8 @@ class _ChatScreenState extends State<ChatScreen> {
); );
} }
} else if (_actualMyId == null) { } else if (_actualMyId == null) {
_actualMyId = widget.myId; final prefs = await SharedPreferences.getInstance();
_actualMyId = int.parse(await prefs.getString('userId')!);;
print( print(
'⚠️ [_initializeChat] ID не найден, используется из виджета: $_actualMyId', '⚠️ [_initializeChat] ID не найден, используется из виджета: $_actualMyId',
); );
@@ -1129,13 +1133,13 @@ class _ChatScreenState extends State<ChatScreen> {
final int tempCid = DateTime.now().millisecondsSinceEpoch; final int tempCid = DateTime.now().millisecondsSinceEpoch;
final tempMessageJson = { final tempMessageJson = {
'id': 'local_$tempCid', // Временный "локальный" ID 'id': 'local_$tempCid',
'text': text, 'text': text,
'time': tempCid, 'time': tempCid,
'sender': _actualMyId!, 'sender': _actualMyId!,
'cid': tempCid, // Уникальный ID клиента 'cid': tempCid,
'type': 'USER', 'type': 'USER',
'attaches': [], // Оптимистично без вложений (для текста) 'attaches': [],
'link': _replyingToMessage != null 'link': _replyingToMessage != null
? { ? {
'type': 'REPLY', 'type': 'REPLY',
@@ -1191,7 +1195,6 @@ class _ChatScreenState extends State<ChatScreen> {
} }
void _testSlideAnimation() { void _testSlideAnimation() {
print('=== ТЕСТ SLIDE+ АНИМАЦИИ ===');
final myMessage = Message( final myMessage = Message(
id: 'test_my_${DateTime.now().millisecondsSinceEpoch}', id: 'test_my_${DateTime.now().millisecondsSinceEpoch}',
@@ -1948,12 +1951,12 @@ class _ChatScreenState extends State<ChatScreen> {
for (final contact in chatContacts) { for (final contact in chatContacts) {
_contactDetailsCache[contact.id] = contact; _contactDetailsCache[contact.id] = contact;
if (contact.id == widget.myId && _actualMyId == null) { /*if (contact.id == widget.myId && _actualMyId == null) {
_actualMyId = contact.id; //_actualMyId = contact.id;
print( print(
'✅ [_loadCachedContacts] Собственный ID восстановлен из кэша: $_actualMyId (${contact.name})', '✅ [_loadCachedContacts] Собственный ID восстановлен из кэша: $_actualMyId (${contact.name})',
); );
} }*/
} }
print( print(
'✅ Загружено ${_contactDetailsCache.length} контактов из кэша чата ${widget.chatId}', '✅ Загружено ${_contactDetailsCache.length} контактов из кэша чата ${widget.chatId}',
@@ -1968,7 +1971,9 @@ class _ChatScreenState extends State<ChatScreen> {
_contactDetailsCache[contact.id] = contact; _contactDetailsCache[contact.id] = contact;
if (contact.id == widget.myId && _actualMyId == null) { if (contact.id == widget.myId && _actualMyId == null) {
_actualMyId = contact.id; final prefs = await SharedPreferences.getInstance();
_actualMyId = int.parse(await prefs.getString('userId')!);
print( print(
'✅ [_loadCachedContacts] Собственный ID восстановлен из глобального кэша: $_actualMyId (${contact.name})', '✅ [_loadCachedContacts] Собственный ID восстановлен из глобального кэша: $_actualMyId (${contact.name})',
); );
@@ -4364,6 +4369,7 @@ extension BrightnessExtension on Brightness {
bool get isDark => this == Brightness.dark; bool get isDark => this == Brightness.dark;
} }
//note: unused
class GroupProfileDraggableDialog extends StatelessWidget { class GroupProfileDraggableDialog extends StatelessWidget {
final Contact contact; final Contact contact;
@@ -4427,8 +4433,6 @@ class GroupProfileDraggableDialog extends StatelessWidget {
IconButton( IconButton(
icon: Icon(Icons.settings, color: colors.primary), icon: Icon(Icons.settings, color: colors.primary),
onPressed: () async { onPressed: () async {
final myId = 0; // This should be passed or retrieved
Navigator.of(context).pop(); Navigator.of(context).pop();
Navigator.of(context).push( Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute(
@@ -4436,7 +4440,7 @@ class GroupProfileDraggableDialog extends StatelessWidget {
chatId: -contact chatId: -contact
.id, // Convert back to positive chatId .id, // Convert back to positive chatId
initialContact: contact, initialContact: contact,
myId: myId, myId: 0,
), ),
), ),
); );

View File

@@ -270,9 +270,9 @@ class _ChatsScreenState extends State<ChatsScreen>
void _navigateToLogin() { void _navigateToLogin() {
print('Перенаправляем на экран входа из-за недействительного токена'); print('Перенаправляем на экран входа из-за недействительного токена');
Navigator.of(context).pushReplacement( /*Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (context) => const PhoneEntryScreen()), MaterialPageRoute(builder: (context) => const PhoneEntryScreen()),
); );*/
} }
void _showTokenExpiredDialog(String message) { void _showTokenExpiredDialog(String message) {

View File

@@ -1242,7 +1242,6 @@ class _DesktopLayoutState extends State<_DesktopLayout> {
isChannel: _isChannel, isChannel: _isChannel,
participantCount: _participantCount, participantCount: _participantCount,
isDesktopMode: true, isDesktopMode: true,
onChatUpdated: () {},
), ),
), ),
], ],

View File

@@ -132,15 +132,21 @@ class _MusicLibraryScreenState extends State<MusicLibraryScreen> {
return ValueListenableBuilder<bool>( return ValueListenableBuilder<bool>(
valueListenable: BottomSheetMusicPlayer.isExpandedNotifier, valueListenable: BottomSheetMusicPlayer.isExpandedNotifier,
builder: (context, isPlayerExpanded, child) { builder: (context, isPlayerExpanded, child) {
return PopScope( return ValueListenableBuilder<bool>(
canPop: !isPlayerExpanded, valueListenable: BottomSheetMusicPlayer.isFullscreenNotifier,
onPopInvoked: (didPop) { builder: (context, isFullscreen, _) {
if (!didPop && isPlayerExpanded) { return PopScope(
BottomSheetMusicPlayer.isExpandedNotifier.value = false; canPop: !isPlayerExpanded,
} onPopInvoked: (didPop) {
}, if (!didPop && isPlayerExpanded) {
child: Scaffold( BottomSheetMusicPlayer.isExpandedNotifier.value = false;
appBar: AppBar(title: const Text('Музыка')), BottomSheetMusicPlayer.isFullscreenNotifier.value = false;
}
},
child: Scaffold(
appBar: isFullscreen
? null
: AppBar(title: const Text('Музыка')),
body: Stack( body: Stack(
children: [ children: [
_isLoading _isLoading
@@ -321,7 +327,9 @@ class _MusicLibraryScreenState extends State<MusicLibraryScreen> {
), ),
], ],
), ),
), ),
);
},
); );
}, },
); );

View File

@@ -56,7 +56,7 @@ class _OTPScreenState extends State<OTPScreen> {
if (payload != null && if (payload != null &&
payload['tokenAttrs']?['LOGIN']?['token'] != null) { payload['tokenAttrs']?['LOGIN']?['token'] != null) {
final String finalToken = payload['tokenAttrs']['LOGIN']['token']; final String finalToken = payload['tokenAttrs']['LOGIN']['token'];
final userId = payload['tokenAttrs']?['LOGIN']?['userId']; final userId = payload['payload']?['profile']?['contact']?['id'];
print('Успешная авторизация! Токен: $finalToken, UserID: $userId'); print('Успешная авторизация! Токен: $finalToken, UserID: $userId');
ApiService.instance ApiService.instance

View File

@@ -200,18 +200,16 @@ class _SettingsScreenState extends State<SettingsScreen> {
} }
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text("Настройки"), title: const Text("Настройки"),
leading: widget.showBackToChats /*leading: widget.showBackToChats
? IconButton( ? IconButton(
icon: const Icon(Icons.arrow_back), icon: const Icon(Icons.arrow_back),
onPressed: widget.onBackToChats, onPressed: widget.onBackToChats,
) )
: null, : null,*/
), ),
body: SafeArea( body: _buildSettingsContent(),
child: _buildSettingsContent(),
),
); );
} }
@@ -224,8 +222,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
final isSmallScreen = screenWidth < 600 || screenHeight < 800; final isSmallScreen = screenWidth < 600 || screenHeight < 800;
return Scaffold( return Scaffold(
backgroundColor: Colors.transparent, body: SafeArea(
body: Stack( child: Stack(
children: [ children: [
GestureDetector( GestureDetector(
onTap: () => Navigator.of(context).pop(), onTap: () => Navigator.of(context).pop(),
@@ -346,7 +344,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
), ),
), ),
], ],
), )),
); );
} }

View File

@@ -104,6 +104,7 @@ class MusicPlayerService extends ChangeNotifier {
StreamSubscription<Duration>? _positionSubscription; StreamSubscription<Duration>? _positionSubscription;
StreamSubscription<Duration?>? _durationSubscription; StreamSubscription<Duration?>? _durationSubscription;
StreamSubscription<PlayerState>? _playerStateSubscription; StreamSubscription<PlayerState>? _playerStateSubscription;
bool _wasCompleted = false;
MusicTrack? get currentTrack => MusicTrack? get currentTrack =>
_currentIndex >= 0 && _currentIndex < _playlist.length _currentIndex >= 0 && _currentIndex < _playlist.length
@@ -129,10 +130,20 @@ class MusicPlayerService extends ChangeNotifier {
}); });
_playerStateSubscription = _audioPlayer.playerStateStream.listen((state) { _playerStateSubscription = _audioPlayer.playerStateStream.listen((state) {
final wasCompleted = _wasCompleted;
_isPlaying = state.playing; _isPlaying = state.playing;
_isLoading = _isLoading =
state.processingState == ProcessingState.loading || state.processingState == ProcessingState.loading ||
state.processingState == ProcessingState.buffering; 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(); notifyListeners();
}); });
@@ -257,6 +268,20 @@ class MusicPlayerService extends ChangeNotifier {
await savePlaylist(); 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 { Future<void> addToPlaylist(MusicTrack track) async {
if (!_playlist.any((t) => t.id == track.id)) { if (!_playlist.any((t) => t.id == track.id)) {
_playlist.add(track); _playlist.add(track);

File diff suppressed because it is too large Load Diff