⚡ Basic optimization of repainting
This commit is contained in:
parent
867b024285
commit
20a82da2fa
@ -33,30 +33,37 @@ void main() async {
|
||||
appRunner: () async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
_initializeFirebase();
|
||||
_initializePlatformComponents();
|
||||
|
||||
runApp(const SolianApp());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _initializeFirebase() async {
|
||||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
||||
}
|
||||
|
||||
Future<void> _initializePlatformComponents() async {
|
||||
if (!PlatformInfo.isWeb) {
|
||||
await protocolHandler.register('solink');
|
||||
}
|
||||
|
||||
await Firebase.initializeApp(
|
||||
options: DefaultFirebaseOptions.currentPlatform,
|
||||
);
|
||||
|
||||
if (PlatformInfo.isDesktop) {
|
||||
await Window.initialize();
|
||||
|
||||
if (PlatformInfo.isMacOS) {
|
||||
await Window.hideTitle();
|
||||
await Window.hideCloseButton();
|
||||
await Window.hideMiniaturizeButton();
|
||||
await Window.hideZoomButton();
|
||||
await Window.makeTitlebarTransparent();
|
||||
await Window.enableFullSizeContentView();
|
||||
await Future.wait([
|
||||
Window.hideTitle(),
|
||||
Window.hideCloseButton(),
|
||||
Window.hideMiniaturizeButton(),
|
||||
Window.hideZoomButton(),
|
||||
Window.makeTitlebarTransparent(),
|
||||
Window.enableFullSizeContentView(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
runApp(const SolianApp());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
class SolianApp extends StatelessWidget {
|
||||
@ -75,7 +82,18 @@ class SolianApp extends StatelessWidget {
|
||||
translations: SolianMessages(),
|
||||
locale: Get.deviceLocale,
|
||||
fallbackLocale: const Locale('en', 'US'),
|
||||
onInit: () {
|
||||
onInit: () => _initializeProviders(context),
|
||||
builder: (context, child) {
|
||||
return ListenerShell(
|
||||
child: ScaffoldMessenger(
|
||||
child: child ?? Container(),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _initializeProviders(BuildContext context) {
|
||||
Get.lazyPut(() => AuthProvider());
|
||||
Get.lazyPut(() => FriendProvider());
|
||||
Get.lazyPut(() => PostProvider());
|
||||
@ -96,19 +114,11 @@ class SolianApp extends StatelessWidget {
|
||||
try {
|
||||
Get.find<AccountProvider>().registerPushNotifications();
|
||||
} catch (err) {
|
||||
context.showSnackbar('pushNotifyRegisterFailed'
|
||||
.trParams({'reason': err.toString()}));
|
||||
context.showSnackbar(
|
||||
'pushNotifyRegisterFailed'.trParams({'reason': err.toString()}),
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
builder: (context, child) {
|
||||
return ListenerShell(
|
||||
child: ScaffoldMessenger(
|
||||
child: child ?? Container(),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/exts.dart';
|
||||
import 'package:solian/router.dart';
|
||||
import 'package:solian/services.dart';
|
||||
|
||||
class SignUpPopup extends StatefulWidget {
|
||||
|
@ -46,7 +46,9 @@ class _AttachmentItemState extends State<AttachmentItem> {
|
||||
_chewieController = ChewieController(
|
||||
aspectRatio: widget.item.metadata?['ratio'] ?? 16 / 9,
|
||||
videoPlayerController: _videoPlayerController!,
|
||||
customControls: const MaterialControls(showPlayButton: true),
|
||||
customControls: PlatformInfo.isMobile
|
||||
? const MaterialControls()
|
||||
: const MaterialDesktopControls(),
|
||||
materialProgressColors: ChewieProgressColors(
|
||||
playedColor: Theme.of(context).colorScheme.primary,
|
||||
handleColor: Theme.of(context).colorScheme.primary,
|
||||
|
@ -102,7 +102,8 @@ class _AttachmentListState extends State<AttachmentList> {
|
||||
}
|
||||
|
||||
Widget buildEntry(Attachment element, int idx) {
|
||||
return GestureDetector(
|
||||
return RepaintBoundary(
|
||||
child: GestureDetector(
|
||||
child: Container(
|
||||
width: widget.width ?? MediaQuery.of(context).size.width,
|
||||
decoration: BoxDecoration(
|
||||
@ -175,6 +176,7 @@ class _AttachmentListState extends State<AttachmentList> {
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,8 @@ class PostListWidget extends StatelessWidget {
|
||||
pagingController: controller,
|
||||
builderDelegate: PagedChildBuilderDelegate<Post>(
|
||||
itemBuilder: (context, item, index) {
|
||||
return GestureDetector(
|
||||
return RepaintBoundary(
|
||||
child: GestureDetector(
|
||||
child: PostItem(
|
||||
key: Key('p${item.alias}'),
|
||||
item: item,
|
||||
@ -49,6 +50,7 @@ class PostListWidget extends StatelessWidget {
|
||||
if (value != null) controller.refresh();
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user