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