This commit is contained in:
toly
2024-01-22 08:26:35 +08:00
parent 2a69cb706b
commit 89eebe3ad8
5 changed files with 268 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
import 'dart:ffi';
import 'package:flutter/material.dart';
import '../navigation/left_navigation/left_router_delegate.dart';
import '../navigation/right_navigation/right_router_delegate.dart';
class DetailPage extends StatefulWidget {
final String id;
const DetailPage({super.key, required this.id});
@override
State<DetailPage> createState() => _DetailPageState();
}
class _DetailPageState extends State<DetailPage> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: BackButton(
onPressed: (){
leftRouterDelegate.value = '/home';
rightRouterDelegate.value = '/detail?id=${widget.id}';
},
),
title: Text('商品详情'),),
body: Center(child: Column(
children: [
Text('商品${widget.id}'),
const SizedBox(height: 30,),
Text('这是商品${widget.id}的详细信息\n'*10),
ElevatedButton(onPressed: (){
leftRouterDelegate.value = '/detail?id=${widget.id}';
rightRouterDelegate.value = '/detail?id=100';
}, child: Text('推荐 100'))
],
),),
);
}
}

View File

@@ -0,0 +1,31 @@
import 'dart:ffi';
import 'package:flutter/material.dart';
import '../navigation/right_navigation/right_router_delegate.dart';
class HomeListPage extends StatefulWidget {
const HomeListPage({super.key});
@override
State<HomeListPage> createState() => _HomeListPageState();
}
class _HomeListPageState extends State<HomeListPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('商品列表'),),
body: ListView.builder(itemBuilder: (_,index)=>ListTile(
onTap: ()=>_onTap(index),
title: Text('商品$index'),
)),
);
}
void _onTap(int index) {
rightRouterDelegate.value = '/detail?id=$index';
}
}