|
@@ -1,5 +1,4 @@
|
|
import 'dart:async';
|
|
import 'dart:async';
|
|
-import 'dart:math';
|
|
|
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/material.dart';
|
|
@@ -8,9 +7,7 @@ import 'package:photos/events/user_details_changed_event.dart';
|
|
import 'package:photos/models/user_details.dart';
|
|
import 'package:photos/models/user_details.dart';
|
|
import 'package:photos/services/user_service.dart';
|
|
import 'package:photos/services/user_service.dart';
|
|
import 'package:photos/ui/loading_widget.dart';
|
|
import 'package:photos/ui/loading_widget.dart';
|
|
-import 'package:photos/utils/data_util.dart';
|
|
|
|
-import 'package:photos/utils/toast_util.dart';
|
|
|
|
-import 'package:pie_chart/pie_chart.dart';
|
|
|
|
|
|
+import 'package:photos/ui/settings/usage_details_widget.dart';
|
|
|
|
|
|
class DetailsSectionWidget extends StatefulWidget {
|
|
class DetailsSectionWidget extends StatefulWidget {
|
|
DetailsSectionWidget({Key key}) : super(key: key);
|
|
DetailsSectionWidget({Key key}) : super(key: key);
|
|
@@ -50,92 +47,12 @@ class _DetailsSectionWidgetState extends State<DetailsSectionWidget> {
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
return SizedBox(
|
|
- height: 140,
|
|
|
|
|
|
+ height: 196,
|
|
child: _userDetails == null ? loadWidget : getContainer(),
|
|
child: _userDetails == null ? loadWidget : getContainer(),
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- Container getContainer() {
|
|
|
|
- return Container(
|
|
|
|
- decoration: BoxDecoration(
|
|
|
|
- color: Colors.grey.withBlue(210).withOpacity(0.1),
|
|
|
|
- borderRadius: BorderRadius.circular(10),
|
|
|
|
- ),
|
|
|
|
- width: double.infinity,
|
|
|
|
- padding: EdgeInsets.fromLTRB(20, 20, 20, 20),
|
|
|
|
- margin: EdgeInsets.fromLTRB(12, 8, 12, 8),
|
|
|
|
- child: Row(
|
|
|
|
- mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
|
- crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
- children: [
|
|
|
|
- GestureDetector(
|
|
|
|
- onTap: () {
|
|
|
|
- showToast(formatBytes(
|
|
|
|
- _userDetails.subscription.storage - _userDetails.usage) +
|
|
|
|
- " / " +
|
|
|
|
- convertBytesToReadableFormat(
|
|
|
|
- _userDetails.subscription.storage) +
|
|
|
|
- " free");
|
|
|
|
- },
|
|
|
|
- child: PieChart(
|
|
|
|
- dataMap: {
|
|
|
|
- "used": _userDetails.usage.toDouble(),
|
|
|
|
- "free": max(
|
|
|
|
- _userDetails.subscription.storage.toDouble() -
|
|
|
|
- _userDetails.usage.toDouble(),
|
|
|
|
- 0),
|
|
|
|
- },
|
|
|
|
- colorList: const [
|
|
|
|
- Colors.redAccent,
|
|
|
|
- Color.fromRGBO(50, 194, 100, 1.0),
|
|
|
|
- ],
|
|
|
|
- legendOptions: LegendOptions(
|
|
|
|
- showLegends: false,
|
|
|
|
- ),
|
|
|
|
- chartValuesOptions: ChartValuesOptions(
|
|
|
|
- showChartValues: false,
|
|
|
|
- showChartValueBackground: false,
|
|
|
|
- ),
|
|
|
|
- chartRadius: 80,
|
|
|
|
- ringStrokeWidth: 4,
|
|
|
|
- chartType: ChartType.ring,
|
|
|
|
- centerText:
|
|
|
|
- convertBytesToReadableFormat(_userDetails.usage) + "\nused",
|
|
|
|
- centerTextStyle: TextStyle(
|
|
|
|
- fontSize: 12,
|
|
|
|
- ),
|
|
|
|
- initialAngleInDegree: 270,
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- Padding(padding: EdgeInsets.all(4)),
|
|
|
|
- Expanded(
|
|
|
|
- child: Column(
|
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
- children: [
|
|
|
|
- Text(
|
|
|
|
- _userDetails.email,
|
|
|
|
- style: TextStyle(
|
|
|
|
- fontSize: 16,
|
|
|
|
- ),
|
|
|
|
- overflow: TextOverflow.ellipsis,
|
|
|
|
- ),
|
|
|
|
- Padding(padding: EdgeInsets.all(6)),
|
|
|
|
- Text(
|
|
|
|
- _userDetails.fileCount.toString() + " memories preserved",
|
|
|
|
- style: Theme.of(context).textTheme.caption,
|
|
|
|
- ),
|
|
|
|
- Padding(padding: EdgeInsets.all(3)),
|
|
|
|
- Text(
|
|
|
|
- _userDetails.sharedCollectionsCount.toString() +
|
|
|
|
- " albums shared",
|
|
|
|
- style: Theme.of(context).textTheme.caption,
|
|
|
|
- ),
|
|
|
|
- ],
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- ],
|
|
|
|
- ),
|
|
|
|
- );
|
|
|
|
|
|
+ Widget getContainer() {
|
|
|
|
+ return UsageDetailsWidget(_userDetails);
|
|
}
|
|
}
|
|
}
|
|
}
|