This commit is contained in:
toly
2023-10-27 17:25:31 +08:00
parent 95e510d814
commit a1a70fae78
108 changed files with 7593 additions and 355 deletions

View File

@@ -0,0 +1,60 @@
import 'package:flutter/material.dart';
class DataPainter extends CustomPainter{
final List<int> data;
DataPainter({required this.data});
@override
void paint(Canvas canvas, Size size) {
double itemWidth = size.width/data.length;
double height = size.height;
Paint paint = Paint();
paint.strokeWidth = itemWidth;
paint.strokeCap = StrokeCap.round;
for(int i=0;i<data.length;i++){
int value = data[i];
if (value < 1000 * .10) {
paint.color = Colors.blue.shade100;
} else if (value < 1000 * .20) {
paint.color = Colors.blue.shade200;
} else if (value < 1000 * .30) {
paint.color = Colors.blue.shade300;
} else if (value < 1000 * .40) {
paint.color = Colors.blue.shade400;
} else if (value < 1000 * .50) {
paint.color = Colors.blue.shade500;
} else if (value < 1000 * .60) {
paint.color = Colors.blue.shade600;
} else if (value < 1000 * .70) {
paint.color = Colors.blue.shade700;
} else if (value < 1000 * .80) {
paint.color = Colors.blue.shade800;
} else if (value < 1000 * .90) {
paint.color = Colors.blue.shade900;
} else {
paint.color = const Color(0xFF011E51);
}
canvas.drawLine(
Offset(i * itemWidth+itemWidth/2, 0),
Offset(
i * itemWidth+itemWidth/2,
size.height*(value/1000),
),
paint);
}
}
@override
bool shouldRepaint(covariant DataPainter oldDelegate) {
return true;
}
}

View File

@@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
import 'package:iroute/components/components.dart';
import '../provider/state.dart';
import '../functions.dart';
import 'sort_button.dart';
class SortBar extends StatelessWidget {
const SortBar({super.key});
@override
Widget build(BuildContext context) {
SortState state = SortStateScope.of(context);
return Row(
children: [
const SortButton(),
const SizedBox(width: 10,),
DropSelectableWidget(
value: sortNameMap[state.config.name]!,
fontSize: 12,
data: sortNameMap.values.toList(),
iconSize: 20,
height: 28,
width: 200,
disableColor: const Color(0xff1F425F),
onDropSelected: (int index) async {
SortState state = SortStateScope.of(context);
state.config =state.config.copyWith(
name: sortNameMap.keys.toList()[index]
);
// curveAnim = CurvedAnimation(
// parent: _ctrl, curve: maps.values.toList()[index]);
// _startAnim();
},
),
const SizedBox(width: 10,),
GestureDetector(
onTap: (){
Scaffold.of(context).openEndDrawer();
// showDialog(
// useRootNavigator: false,
// context: context, builder: (ctx)=>AlertDialog());
},
child: const Icon(Icons.settings))
],
);
}
}

View File

@@ -0,0 +1,40 @@
import 'package:flutter/material.dart';
import '../provider/state.dart';
class SortButton extends StatelessWidget {
const SortButton({super.key});
@override
Widget build(BuildContext context) {
SortState state = SortStateScope.of(context);
VoidCallback? action;
IconData icon;
Color color;
switch (state.status) {
case SortStatus.none:
icon = Icons.not_started_outlined;
color = Colors.green;
action = state.sort;
break;
case SortStatus.sorting:
icon = Icons.stop_circle_outlined;
color = Colors.grey;
action = null;
break;
case SortStatus.sorted:
icon = Icons.refresh;
color = Colors.black;
action = state.reset;
break;
}
return GestureDetector(
onTap: action,
child: Icon(
icon,
color: color,
),
);
}
}

View File

@@ -0,0 +1,22 @@
import 'package:flutter/material.dart';
import '../provider/state.dart';
import 'data_painter.dart';
class SortPage extends StatelessWidget{
@override
Widget build(BuildContext context) {
SortState state = SortStateScope.of(context);
List<int> numbers = state.data;
return Scaffold(
body: CustomPaint(
painter: DataPainter(data: numbers),
child: ConstrainedBox(constraints: BoxConstraints.expand()),
),
);
}
}