@@ -15,11 +15,8 @@ class UploadStatusPage extends StatefulWidget {
1515}
1616
1717class _UploadStatusPageState extends State <UploadStatusPage > {
18- final PageController _pageController = PageController ();
1918 final ScrollController _scrollController = ScrollController ();
2019
21- int _page = 0 ;
22-
2320 @override
2421 Widget build (BuildContext context) {
2522 return Scaffold (
@@ -31,110 +28,67 @@ class _UploadStatusPageState extends State<UploadStatusPage> {
3128 style: Theme .of (context).appBarTheme.titleTextStyle,
3229 ),
3330 ),
34- body: PageView (
35- controller: _pageController,
36- onPageChanged: (page) => setState (() {
37- _page = page;
38- }),
39- children: [
40- _buildUploadList,
41- _buildHistoryList,
42- ],
43- ),
31+ body: _buildUploadList,
4432 floatingActionButton: ScrollUpFloatingButton (
4533 controller: _scrollController,
4634 ),
47- bottomNavigationBar: BottomNavigationBar (
48- currentIndex: _page,
49- onTap: (index) => _pageController.animateToPage (
50- index,
51- duration: const Duration (milliseconds: 300 ),
52- curve: Curves .ease,
53- ),
54- items: [
55- BottomNavigationBarItem (
56- icon: Icon (Icons .list),
57- label: appStrings.uploadList_uploading,
58- ),
59- BottomNavigationBarItem (
60- icon: Icon (Icons .history),
61- label: appStrings.uploadList_history,
62- ),
63- ],
64- ),
6535 );
6636 }
6737
6838 Widget get _buildUploadList {
6939 return Consumer <UploadNotifier >(builder: (context, uploadNotifier, child) {
70- if (uploadNotifier.uploadList.isEmpty) {
40+ if (uploadNotifier.uploadList.isEmpty && uploadNotifier.uploadHistoryList.isEmpty ) {
7141 return Center (
7242 child: Text (appStrings.uploadList_empty),
7343 );
7444 }
7545 return ListView .separated (
7646 padding: EdgeInsets .symmetric (vertical: 8.0 ),
77- itemCount: uploadNotifier.uploadList.length,
47+ controller: _scrollController,
48+ itemCount: uploadNotifier.uploadList.length + uploadNotifier.uploadHistoryList.length,
7849 itemBuilder: (context, index) {
79- UploadItem item = uploadNotifier.uploadList[index];
80- return ListTile (
81- dense: true ,
82- leading: ClipRRect (
83- borderRadius: BorderRadius .circular (5.0 ),
84- child: AspectRatio (
85- aspectRatio: 1 ,
86- child: Image .file (
87- item.file,
88- fit: BoxFit .cover,
50+ late UploadItem item;
51+ if (index < uploadNotifier.uploadList.length) {
52+ item = uploadNotifier.uploadList[index];
53+ return ListTile (
54+ dense: true ,
55+ leading: ClipRRect (
56+ borderRadius: BorderRadius .circular (5.0 ),
57+ child: AspectRatio (
58+ aspectRatio: 1 ,
59+ child: Image .file (
60+ item.file,
61+ fit: BoxFit .cover,
62+ ),
8963 ),
9064 ),
91- ),
92- title: Text (
93- item.file.path.split ('/' ).last,
94- style: Theme .of (context).textTheme.bodyMedium,
95- ),
96- subtitle: StreamBuilder <double >(
97- stream: item.progress.stream,
98- initialData: 0.0 ,
99- builder: (context, snapshot) {
100- if (snapshot.hasData) {
101- return LinearProgressIndicator (
102- backgroundColor: Theme .of (context).colorScheme.secondary.withOpacity (0.3 ),
103- value: min (snapshot.data! , 1.0 ),
104- );
105- }
106- return LinearProgressIndicator ();
107- },
108- ),
109- trailing: IconButton (
110- onPressed: () {
111- item.cancelToken.cancel ();
112- uploadNotifier.itemUploadCompleted (item);
113- },
114- icon: Icon (Icons .close),
115- ),
116- );
117- },
118- separatorBuilder: (context, index) {
119- return const Divider ();
120- },
121- );
122- });
123- }
124-
125- Widget get _buildHistoryList {
126- return Consumer <UploadNotifier >(builder: (context, uploadNotifier, child) {
127- if (uploadNotifier.uploadHistoryList.isEmpty) {
128- return Center (
129- child: Text (appStrings.uploadList_empty),
130- );
131- }
132- return ListView .separated (
133- controller: _scrollController,
134- padding: EdgeInsets .symmetric (vertical: 8.0 ),
135- itemCount: uploadNotifier.uploadHistoryList.length,
136- itemBuilder: (context, index) {
137- UploadItem item = uploadNotifier.uploadHistoryList[index];
65+ title: Text (
66+ item.file.path.split ('/' ).last,
67+ style: Theme .of (context).textTheme.bodyMedium,
68+ ),
69+ subtitle: StreamBuilder <double >(
70+ stream: item.progress.stream,
71+ initialData: 0.0 ,
72+ builder: (context, snapshot) {
73+ if (snapshot.hasData) {
74+ return LinearProgressIndicator (
75+ backgroundColor: Theme .of (context).colorScheme.secondary.withOpacity (0.3 ),
76+ value: min (snapshot.data! , 1.0 ),
77+ );
78+ }
79+ return LinearProgressIndicator ();
80+ },
81+ ),
82+ trailing: IconButton (
83+ onPressed: () {
84+ item.cancelToken.cancel ();
85+ uploadNotifier.itemUploadCompleted (item);
86+ },
87+ icon: Icon (Icons .close),
88+ ),
89+ );
90+ }
91+ item = uploadNotifier.uploadHistoryList[index - uploadNotifier.uploadList.length];
13892 return ListTile (
13993 dense: true ,
14094 leading: ClipRRect (
0 commit comments