⚡ Optimized channel list
This commit is contained in:
parent
cc59814b55
commit
90daff5b97
@ -33,8 +33,10 @@ void main() async {
|
|||||||
appRunner: () async {
|
appRunner: () async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
_initializeFirebase();
|
await Future.wait([
|
||||||
_initializePlatformComponents();
|
_initializeFirebase(),
|
||||||
|
_initializePlatformComponents(),
|
||||||
|
]);
|
||||||
|
|
||||||
runApp(const SolianApp());
|
runApp(const SolianApp());
|
||||||
},
|
},
|
||||||
|
@ -3,7 +3,6 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:solian/models/channel.dart';
|
import 'package:solian/models/channel.dart';
|
||||||
import 'package:solian/providers/auth.dart';
|
import 'package:solian/providers/auth.dart';
|
||||||
import 'package:solian/providers/content/call.dart';
|
|
||||||
import 'package:solian/providers/content/channel.dart';
|
import 'package:solian/providers/content/channel.dart';
|
||||||
import 'package:solian/router.dart';
|
import 'package:solian/router.dart';
|
||||||
import 'package:solian/screens/account/notification.dart';
|
import 'package:solian/screens/account/notification.dart';
|
||||||
@ -65,7 +64,6 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final AuthProvider auth = Get.find();
|
final AuthProvider auth = Get.find();
|
||||||
final ChatCallProvider call = Get.find();
|
|
||||||
|
|
||||||
return Material(
|
return Material(
|
||||||
color: Theme.of(context).colorScheme.surface,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
@ -84,18 +82,6 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final prefixSlivers = [
|
|
||||||
Obx(() {
|
|
||||||
if (call.current.value != null) {
|
|
||||||
return const SliverToBoxAdapter(
|
|
||||||
child: ChatCallCurrentIndicator(),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return const SliverToBoxAdapter();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
|
|
||||||
return DefaultTabController(
|
return DefaultTabController(
|
||||||
length: 2,
|
length: 2,
|
||||||
child: NestedScrollView(
|
child: NestedScrollView(
|
||||||
@ -183,34 +169,37 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
|
|
||||||
return TabBarView(
|
return TabBarView(
|
||||||
children: [
|
children: [
|
||||||
RefreshIndicator(
|
Column(
|
||||||
|
children: [
|
||||||
|
const ChatCallCurrentIndicator(),
|
||||||
|
Expanded(
|
||||||
|
child: RefreshIndicator(
|
||||||
onRefresh: () => getChannels(),
|
onRefresh: () => getChannels(),
|
||||||
child: CustomScrollView(
|
child: ChannelListWidget(
|
||||||
slivers: [
|
|
||||||
...prefixSlivers,
|
|
||||||
ChannelListWidget(
|
|
||||||
channels:
|
channels:
|
||||||
_channels.where((x) => x.type == 0).toList(),
|
_channels.where((x) => x.type == 0).toList(),
|
||||||
selfId: _accountId ?? 0,
|
selfId: _accountId ?? 0,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
Column(
|
||||||
RefreshIndicator(
|
children: [
|
||||||
|
const ChatCallCurrentIndicator(),
|
||||||
|
Expanded(
|
||||||
|
child: RefreshIndicator(
|
||||||
onRefresh: () => getChannels(),
|
onRefresh: () => getChannels(),
|
||||||
child: CustomScrollView(
|
child: ChannelListWidget(
|
||||||
slivers: [
|
channels: _channels.where((x) => x.type == 1).toList(),
|
||||||
...prefixSlivers,
|
|
||||||
ChannelListWidget(
|
|
||||||
channels:
|
|
||||||
_channels.where((x) => x.type == 1).toList(),
|
|
||||||
selfId: _accountId ?? 0,
|
selfId: _accountId ?? 0,
|
||||||
noCategory: true,
|
noCategory: true,
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
@ -247,10 +247,9 @@ class RealmChannelListWidget extends StatelessWidget {
|
|||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
return RefreshIndicator(
|
return RefreshIndicator(
|
||||||
onRefresh: onRefresh,
|
onRefresh: onRefresh,
|
||||||
child: CustomScrollView(
|
child: Column(
|
||||||
slivers: [
|
children: [
|
||||||
SliverToBoxAdapter(
|
ListTile(
|
||||||
child: ListTile(
|
|
||||||
leading: const Icon(Icons.add_box),
|
leading: const Icon(Icons.add_box),
|
||||||
contentPadding: const EdgeInsets.only(left: 32, right: 8),
|
contentPadding: const EdgeInsets.only(left: 32, right: 8),
|
||||||
tileColor: Theme.of(context).colorScheme.surfaceContainer,
|
tileColor: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
@ -270,11 +269,12 @@ class RealmChannelListWidget extends StatelessWidget {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
Expanded(
|
||||||
ChannelListWidget(
|
child: ChannelListWidget(
|
||||||
channels: channels,
|
channels: channels,
|
||||||
selfId: snapshot.data?.body['id'] ?? 0,
|
selfId: snapshot.data?.body['id'] ?? 0,
|
||||||
noCategory: true,
|
noCategory: true,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -115,28 +115,45 @@ class _ChannelListWidgetState extends State<ChannelListWidget> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (widget.noCategory) {
|
if (widget.noCategory) {
|
||||||
return SliverList.builder(
|
return CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
SliverList.builder(
|
||||||
itemCount: _globalChannels.length,
|
itemCount: _globalChannels.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final element = _globalChannels[index];
|
final element = _globalChannels[index];
|
||||||
return buildItem(element);
|
return buildItem(element);
|
||||||
},
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SliverList.list(
|
return CustomScrollView(
|
||||||
children: [
|
slivers: [
|
||||||
..._globalChannels.map((e) => buildItem(e)),
|
SliverList.builder(
|
||||||
..._inRealms.entries.map((element) {
|
itemCount: _globalChannels.length,
|
||||||
return ExpansionTile(
|
itemBuilder: (context, index) {
|
||||||
tilePadding: const EdgeInsets.symmetric(horizontal: 24),
|
final element = _globalChannels[index];
|
||||||
title: Text(element.value.first.realm!.name),
|
return buildItem(element);
|
||||||
subtitle: Text(
|
},
|
||||||
element.value.first.realm!.description,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
),
|
||||||
children: element.value.map((e) => buildItem(e)).toList(),
|
..._inRealms.entries.map((element) {
|
||||||
|
return SliverList.builder(
|
||||||
|
itemCount: element.value.length + 1,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (index == 0) {
|
||||||
|
return ListTile(
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 28),
|
||||||
|
leading: const Icon(Icons.workspaces, size: 20)
|
||||||
|
.paddingOnly(left: 6, right: 10),
|
||||||
|
tileColor: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||||
|
title: Text(element.value.first.realm!.name),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final item = element.value[index - 1];
|
||||||
|
return buildItem(item);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user