90 lines
3.2 KiB
Dart
90 lines
3.2 KiB
Dart
import 'package:didvan/config/design_config.dart';
|
||
import 'package:didvan/config/theme_data.dart';
|
||
import 'package:didvan/constants/assets.dart';
|
||
import 'package:didvan/routes/routes.dart';
|
||
import 'package:didvan/views/widgets/didvan/text.dart';
|
||
import 'package:flutter/material.dart';
|
||
import 'package:flutter_svg/svg.dart';
|
||
|
||
class StatMenuItemType {
|
||
final String label;
|
||
final String asset;
|
||
final int id;
|
||
|
||
StatMenuItemType(
|
||
{required this.label, required this.asset, required this.id});
|
||
}
|
||
|
||
List<StatMenuItemType> statCat = [
|
||
StatMenuItemType(
|
||
label: "بازار ارز و طلا", asset: Assets.currencyGoldStatCat, id: 1),
|
||
StatMenuItemType(label: "ارزهای دیجیتال", asset: Assets.cryptoStatCat, id: 2),
|
||
StatMenuItemType(label: "فلزات پایه", asset: Assets.metalStatCat, id: 3),
|
||
StatMenuItemType(label: "کامودیتی ها", asset: Assets.commodityStatCat, id: 4),
|
||
StatMenuItemType(label: "صنعت فولاد", asset: Assets.steelStatCat, id: 5),
|
||
StatMenuItemType(label: "بازار سرمایه", asset: Assets.stockStatCat, id: 6),
|
||
];
|
||
|
||
class NewStatisticCategories extends StatelessWidget {
|
||
const NewStatisticCategories({super.key});
|
||
|
||
void _onTap(int id, String title, BuildContext context, BuildContext ctx) {
|
||
if (id != 6) {
|
||
// Future.delayed(Duration.zero, () {
|
||
Navigator.of(context)
|
||
.pushNamed(Routes.statGeneral, arguments: {"id": id, "title": title});
|
||
// });
|
||
} else {
|
||
Navigator.of(ctx).pushNamed(Routes.stock);
|
||
// Your code HERE
|
||
// Flutter will wait until the current build is completed before executing this code.
|
||
}
|
||
// Future.delayed(Duration.zero, () {
|
||
|
||
// });
|
||
}
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Wrap(
|
||
alignment: WrapAlignment.center,
|
||
children: statCat
|
||
.map(
|
||
(e) => GestureDetector(
|
||
onTap: () => _onTap(e.id, e.label, context, context),
|
||
child: Padding(
|
||
padding: const EdgeInsets.all(8.0),
|
||
child: SizedBox(
|
||
width: (MediaQuery.of(context).size.width - 40) / 4,
|
||
child: Column(
|
||
children: [
|
||
Container(
|
||
width: 56,
|
||
height: 56,
|
||
padding: const EdgeInsets.all(8),
|
||
decoration: BoxDecoration(
|
||
color: Theme.of(context).colorScheme.surface,
|
||
borderRadius: DesignConfig.lowBorderRadius,
|
||
boxShadow: DesignConfig.defaultShadow,
|
||
),
|
||
child: SvgPicture.asset(e.asset),
|
||
),
|
||
const SizedBox(height: 4),
|
||
DidvanText(
|
||
e.label,
|
||
color: Theme.of(context).colorScheme.title,
|
||
style: Theme.of(context).textTheme.labelSmall,
|
||
fontWeight: FontWeight.w600,
|
||
),
|
||
const SizedBox(height: 12),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
),
|
||
)
|
||
.toList(),
|
||
);
|
||
}
|
||
}
|