|
|
|
|
@ -5,6 +5,7 @@ import 'package:fluffychat/pangea/enum/construct_type_enum.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/enum/time_span.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/pages/analytics/analytics_language_button.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/pages/analytics/analytics_list_tile.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/pages/analytics/analytics_view_button.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/pages/analytics/base_analytics.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/pages/analytics/construct_list.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/pages/analytics/messages_bar_chart.dart';
|
|
|
|
|
@ -24,11 +25,7 @@ class BaseAnalyticsView extends StatelessWidget {
|
|
|
|
|
final BaseAnalyticsController controller;
|
|
|
|
|
|
|
|
|
|
Widget chartView(BuildContext context) {
|
|
|
|
|
if (controller.widget.selectedView == null) {
|
|
|
|
|
return const SizedBox();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (controller.widget.selectedView!) {
|
|
|
|
|
switch (controller.currentView) {
|
|
|
|
|
case BarChartViewSelection.messages:
|
|
|
|
|
return MessagesBarChart(
|
|
|
|
|
chartAnalytics: controller.chartData,
|
|
|
|
|
@ -75,26 +72,12 @@ class BaseAnalyticsView extends StatelessWidget {
|
|
|
|
|
if (controller.activeSpace != null)
|
|
|
|
|
TextSpan(
|
|
|
|
|
text: controller.activeSpace!.getLocalizedDisplayname(),
|
|
|
|
|
style: const TextStyle(decoration: TextDecoration.underline),
|
|
|
|
|
recognizer: TapGestureRecognizer()
|
|
|
|
|
..onTap = () {
|
|
|
|
|
if (controller.widget.selectedView == null) return;
|
|
|
|
|
String route =
|
|
|
|
|
"/rooms/${controller.widget.defaultSelected.type.route}";
|
|
|
|
|
if (controller.widget.defaultSelected.type ==
|
|
|
|
|
AnalyticsEntryType.space) {
|
|
|
|
|
route += "/${controller.widget.defaultSelected.id}";
|
|
|
|
|
}
|
|
|
|
|
context.go(route);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
if (controller.widget.selectedView != null)
|
|
|
|
|
const TextSpan(
|
|
|
|
|
text: " > ",
|
|
|
|
|
),
|
|
|
|
|
if (controller.widget.selectedView != null)
|
|
|
|
|
TextSpan(
|
|
|
|
|
text: controller.widget.selectedView!.string(context),
|
|
|
|
|
text: controller.currentView.string(context),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
@ -104,24 +87,20 @@ class BaseAnalyticsView extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
body: MaxWidthBody(
|
|
|
|
|
withScrolling: false,
|
|
|
|
|
child: controller.widget.selectedView != null
|
|
|
|
|
? Column(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
// if (controller.widget.defaultSelected.type ==
|
|
|
|
|
// AnalyticsEntryType.student)
|
|
|
|
|
// IconButton(
|
|
|
|
|
// icon: const Icon(Icons.refresh),
|
|
|
|
|
// onPressed: controller.onRefresh,
|
|
|
|
|
// tooltip: L10n.of(context)!.refresh,
|
|
|
|
|
// ),
|
|
|
|
|
TimeSpanMenuButton(
|
|
|
|
|
value: controller.currentTimeSpan,
|
|
|
|
|
onChange: (TimeSpan value) =>
|
|
|
|
|
controller.toggleTimeSpan(context, value),
|
|
|
|
|
),
|
|
|
|
|
AnalyticsViewButton(
|
|
|
|
|
value: controller.currentView,
|
|
|
|
|
onChange: controller.toggleView,
|
|
|
|
|
),
|
|
|
|
|
AnalyticsLanguageButton(
|
|
|
|
|
value: controller
|
|
|
|
|
.pangeaController.analytics.currentAnalyticsLang,
|
|
|
|
|
@ -130,6 +109,9 @@ class BaseAnalyticsView extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 10,
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
flex: 1,
|
|
|
|
|
child: chartView(context),
|
|
|
|
|
@ -158,8 +140,7 @@ class BaseAnalyticsView extends StatelessWidget {
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: SizedBox(
|
|
|
|
|
height: max(
|
|
|
|
|
controller.widget.tabs[0].items.length +
|
|
|
|
|
1,
|
|
|
|
|
controller.widget.tabs[0].items.length + 1,
|
|
|
|
|
controller.widget.tabs[1].items.length,
|
|
|
|
|
) *
|
|
|
|
|
72,
|
|
|
|
|
@ -167,16 +148,14 @@ class BaseAnalyticsView extends StatelessWidget {
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment:
|
|
|
|
|
CrossAxisAlignment.stretch,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
children: [
|
|
|
|
|
...controller.widget.tabs[0].items.map(
|
|
|
|
|
(item) => AnalyticsListTile(
|
|
|
|
|
refreshStream:
|
|
|
|
|
controller.refreshStream,
|
|
|
|
|
refreshStream: controller.refreshStream,
|
|
|
|
|
avatar: item.avatar,
|
|
|
|
|
defaultSelected: controller
|
|
|
|
|
.widget.defaultSelected,
|
|
|
|
|
defaultSelected:
|
|
|
|
|
controller.widget.defaultSelected,
|
|
|
|
|
selected: AnalyticsSelected(
|
|
|
|
|
item.id,
|
|
|
|
|
controller.widget.tabs[0].type,
|
|
|
|
|
@ -184,8 +163,7 @@ class BaseAnalyticsView extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
isSelected:
|
|
|
|
|
controller.isSelected(item.id),
|
|
|
|
|
onTap: (_) =>
|
|
|
|
|
controller.toggleSelection(
|
|
|
|
|
onTap: (_) => controller.toggleSelection(
|
|
|
|
|
AnalyticsSelected(
|
|
|
|
|
item.id,
|
|
|
|
|
controller.widget.tabs[0].type,
|
|
|
|
|
@ -193,33 +171,27 @@ class BaseAnalyticsView extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
allowNavigateOnSelect: controller
|
|
|
|
|
.widget
|
|
|
|
|
.tabs[0]
|
|
|
|
|
.allowNavigateOnSelect,
|
|
|
|
|
.widget.tabs[0].allowNavigateOnSelect,
|
|
|
|
|
pangeaController:
|
|
|
|
|
controller.pangeaController,
|
|
|
|
|
controller: controller,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
if (controller
|
|
|
|
|
.widget.defaultSelected.type ==
|
|
|
|
|
if (controller.widget.defaultSelected.type ==
|
|
|
|
|
AnalyticsEntryType.space)
|
|
|
|
|
AnalyticsListTile(
|
|
|
|
|
refreshStream:
|
|
|
|
|
controller.refreshStream,
|
|
|
|
|
defaultSelected: controller
|
|
|
|
|
.widget.defaultSelected,
|
|
|
|
|
refreshStream: controller.refreshStream,
|
|
|
|
|
defaultSelected:
|
|
|
|
|
controller.widget.defaultSelected,
|
|
|
|
|
avatar: null,
|
|
|
|
|
selected: AnalyticsSelected(
|
|
|
|
|
controller
|
|
|
|
|
.widget.defaultSelected.id,
|
|
|
|
|
controller.widget.defaultSelected.id,
|
|
|
|
|
AnalyticsEntryType.privateChats,
|
|
|
|
|
L10n.of(context)!.allPrivateChats,
|
|
|
|
|
),
|
|
|
|
|
allowNavigateOnSelect: false,
|
|
|
|
|
isSelected: controller.isSelected(
|
|
|
|
|
controller
|
|
|
|
|
.widget.defaultSelected.id,
|
|
|
|
|
controller.widget.defaultSelected.id,
|
|
|
|
|
),
|
|
|
|
|
onTap: controller.toggleSelection,
|
|
|
|
|
pangeaController:
|
|
|
|
|
@ -229,28 +201,24 @@ class BaseAnalyticsView extends StatelessWidget {
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment:
|
|
|
|
|
CrossAxisAlignment.stretch,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
children: controller.widget.tabs[1].items
|
|
|
|
|
.map(
|
|
|
|
|
(item) => AnalyticsListTile(
|
|
|
|
|
refreshStream:
|
|
|
|
|
controller.refreshStream,
|
|
|
|
|
refreshStream: controller.refreshStream,
|
|
|
|
|
avatar: item.avatar,
|
|
|
|
|
defaultSelected: controller
|
|
|
|
|
.widget.defaultSelected,
|
|
|
|
|
defaultSelected:
|
|
|
|
|
controller.widget.defaultSelected,
|
|
|
|
|
selected: AnalyticsSelected(
|
|
|
|
|
item.id,
|
|
|
|
|
controller.widget.tabs[1].type,
|
|
|
|
|
item.displayName,
|
|
|
|
|
),
|
|
|
|
|
isSelected: controller
|
|
|
|
|
.isSelected(item.id),
|
|
|
|
|
isSelected:
|
|
|
|
|
controller.isSelected(item.id),
|
|
|
|
|
onTap: controller.toggleSelection,
|
|
|
|
|
allowNavigateOnSelect: controller
|
|
|
|
|
.widget
|
|
|
|
|
.tabs[1]
|
|
|
|
|
.allowNavigateOnSelect,
|
|
|
|
|
allowNavigateOnSelect: controller.widget
|
|
|
|
|
.tabs[1].allowNavigateOnSelect,
|
|
|
|
|
pangeaController:
|
|
|
|
|
controller.pangeaController,
|
|
|
|
|
controller: controller,
|
|
|
|
|
@ -268,55 +236,6 @@ class BaseAnalyticsView extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: Column(
|
|
|
|
|
children: [
|
|
|
|
|
const Divider(height: 1),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text(L10n.of(context)!.grammarAnalytics),
|
|
|
|
|
leading: CircleAvatar(
|
|
|
|
|
backgroundColor:
|
|
|
|
|
Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
|
foregroundColor:
|
|
|
|
|
Theme.of(context).textTheme.bodyLarge!.color,
|
|
|
|
|
child: Icon(BarChartViewSelection.grammar.icon),
|
|
|
|
|
),
|
|
|
|
|
trailing: const Icon(Icons.chevron_right),
|
|
|
|
|
onTap: () {
|
|
|
|
|
String route =
|
|
|
|
|
"/rooms/${controller.widget.defaultSelected.type.route}";
|
|
|
|
|
if (controller.widget.defaultSelected.type ==
|
|
|
|
|
AnalyticsEntryType.space) {
|
|
|
|
|
route += "/${controller.widget.defaultSelected.id}";
|
|
|
|
|
}
|
|
|
|
|
route += "/${BarChartViewSelection.grammar.route}";
|
|
|
|
|
context.go(route);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const Divider(height: 1),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text(L10n.of(context)!.messageAnalytics),
|
|
|
|
|
leading: CircleAvatar(
|
|
|
|
|
backgroundColor:
|
|
|
|
|
Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
|
foregroundColor:
|
|
|
|
|
Theme.of(context).textTheme.bodyLarge!.color,
|
|
|
|
|
child: Icon(BarChartViewSelection.messages.icon),
|
|
|
|
|
),
|
|
|
|
|
trailing: const Icon(Icons.chevron_right),
|
|
|
|
|
onTap: () {
|
|
|
|
|
String route =
|
|
|
|
|
"/rooms/${controller.widget.defaultSelected.type.route}";
|
|
|
|
|
if (controller.widget.defaultSelected.type ==
|
|
|
|
|
AnalyticsEntryType.space) {
|
|
|
|
|
route += "/${controller.widget.defaultSelected.id}";
|
|
|
|
|
}
|
|
|
|
|
route += "/${BarChartViewSelection.messages.route}";
|
|
|
|
|
context.go(route);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const Divider(height: 1),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|