improving ui elements
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:qpay/http/http.dart';
|
||||
import 'package:qpay/models/pageable_model.dart';
|
||||
|
||||
part 'home_controller.freezed.dart';
|
||||
part 'home_controller.g.dart';
|
||||
@@ -116,11 +115,14 @@ class HomeController extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
List<dynamic> response = await http.get(
|
||||
'/transaction?userId=$userId&type=REQUEST',
|
||||
Map<String, dynamic> response = await http.get(
|
||||
'/transaction?sort=createdAt,desc&size=3&page=0&userId=$userId&type=REQUEST',
|
||||
);
|
||||
|
||||
PageableModel pageableModel = PageableModel.fromJson(response);
|
||||
|
||||
model.transactions =
|
||||
response.map((e) => e as Map<String, dynamic>).toList();
|
||||
pageableModel.content.map((e) => e as Map<String, dynamic>).toList();
|
||||
} catch (e) {
|
||||
logger.e(e);
|
||||
_showErrorSnackBar(
|
||||
|
||||
@@ -221,18 +221,6 @@ class _HomeScreenState extends State<HomeScreen>
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
context.go('/history');
|
||||
},
|
||||
child: Text(
|
||||
'View All',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
@@ -250,13 +238,26 @@ class _HomeScreenState extends State<HomeScreen>
|
||||
],
|
||||
),
|
||||
if (homeController.model.transactions.isNotEmpty)
|
||||
ListView(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
Column(
|
||||
children: [
|
||||
...homeController.model.transactions.map(
|
||||
(e) => _buildTransactionItem(e, context),
|
||||
ListView(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: [
|
||||
...homeController.model.transactions.map(
|
||||
(e) => _buildTransactionItem(e, context),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
if (homeController.model.transactions.length >
|
||||
2)
|
||||
OutlinedButton(
|
||||
child: Text('View All'),
|
||||
onPressed: () {
|
||||
context.go('/history');
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user