Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

necessary token passed for unnecessary image api #29

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 26 additions & 14 deletions lib/widgets/buy_sell/buy_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
import 'package:onestop_dev/functions/food/rest_frame_builder.dart';
import 'package:onestop_dev/globals/my_colors.dart';
import 'package:onestop_dev/globals/my_fonts.dart';
import '../../functions/utility/auth_user_helper.dart';
import '../../globals/endpoints.dart';
import 'details_dialog.dart';

class BuyTile extends StatelessWidget {
Expand Down Expand Up @@ -75,20 +77,30 @@ class BuyTile extends StatelessWidget {
),
),
),
Expanded(
flex: 4,
child: ClipRRect(
borderRadius: const BorderRadius.only(
topRight: Radius.circular(21),
bottomRight: Radius.circular(21)),
child: Image.network(
model.imageURL,
fit: BoxFit.cover,
cacheWidth: 100,
frameBuilder: restaurantTileFrameBuilder,
errorBuilder: (_, __, ___) => Container(),
),
),
FutureBuilder(
future: AuthUserHelpers.getAccessToken(),
builder: (context, snapshot) {
if(snapshot.hasError || !snapshot.hasData)
{
return Container();
}
return Expanded(
flex: 4,
child: ClipRRect(
borderRadius: const BorderRadius.only(
topRight: Radius.circular(21),
bottomRight: Radius.circular(21)),
child: Image.network(
model.imageURL,
fit: BoxFit.cover,
cacheWidth: 100,
headers: {'Content-Type': 'application/json', 'security-key': Endpoints.apiSecurityKey, 'Authorization': "Bearer ${snapshot.data}"},
frameBuilder: restaurantTileFrameBuilder,
errorBuilder: (_, __, ___) => Container(),
),
),
);
}
),
],
),
Expand Down
31 changes: 22 additions & 9 deletions lib/widgets/buy_sell/details_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import 'package:onestop_dev/models/buy_sell/sell_model.dart';
import 'package:onestop_dev/models/lostfound/found_model.dart';
import 'package:onestop_dev/widgets/lostfound/claim_call_button.dart';

import '../../functions/utility/auth_user_helper.dart';
import '../../globals/endpoints.dart';

void detailsDialogBox(context, dynamic model, [parentContext]) {
final screenWidth = MediaQuery.of(context).size.width;
final screenHeight = MediaQuery.of(context).size.height;
Expand Down Expand Up @@ -95,15 +98,25 @@ void detailsDialogBox(context, dynamic model, [parentContext]) {
constraints: BoxConstraints(
maxHeight: screenHeight * 0.3,
maxWidth: screenWidth - 30),
child: SingleChildScrollView(
child: Image.network(
model.imageURL,
fit: BoxFit.cover,
frameBuilder: restaurantTileFrameBuilder,
width: screenWidth - 30,
cacheWidth: (screenWidth - 30).round(),
errorBuilder: (_, __, ___) => Container(),
),
child: FutureBuilder(
future: AuthUserHelpers.getAccessToken(),
builder: (context, snapshot) {
if(snapshot.hasError || !snapshot.hasData)
{
return Container();
}
return SingleChildScrollView(
child: Image.network(
model.imageURL,
fit: BoxFit.cover,
frameBuilder: restaurantTileFrameBuilder,
width: screenWidth - 30,
headers: {'Content-Type': 'application/json', 'security-key': Endpoints.apiSecurityKey, 'Authorization': "Bearer ${snapshot.data}"},
cacheWidth: (screenWidth - 30).round(),
errorBuilder: (_, __, ___) => Container(),
),
);
}
),
),
),
Expand Down
37 changes: 25 additions & 12 deletions lib/widgets/lostfound/ads_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import 'package:onestop_dev/models/lostfound/lost_model.dart';
import 'package:onestop_dev/services/api.dart';
import 'package:onestop_dev/widgets/buy_sell/details_dialog.dart';

import '../../functions/utility/auth_user_helper.dart';
import '../../globals/endpoints.dart';

class MyAdsTile extends StatefulWidget {
// ignore: prefer_typing_uninitialized_variables
final model;
Expand Down Expand Up @@ -116,18 +119,28 @@ class _MyAdsTileState extends State<MyAdsTile> {
),
),
),
Expanded(
flex: 4,
child: ClipRRect(
borderRadius: const BorderRadius.only(
topRight: Radius.circular(21),
bottomRight: Radius.circular(21)),
child: Image.network(widget.model.imageURL,
cacheWidth: 100,
fit: BoxFit.cover,
errorBuilder: (_, __, ___) => Container(),
frameBuilder: restaurantTileFrameBuilder),
),
FutureBuilder(
future: AuthUserHelpers.getAccessToken(),
builder: (context, snapshot) {
if(snapshot.hasError || !snapshot.hasData)
{
return Container();
}
return Expanded(
flex: 4,
child: ClipRRect(
borderRadius: const BorderRadius.only(
topRight: Radius.circular(21),
bottomRight: Radius.circular(21)),
child: Image.network(widget.model.imageURL,
cacheWidth: 100,
fit: BoxFit.cover,
errorBuilder: (_, __, ___) => Container(),
headers: {'Content-Type': 'application/json', 'security-key': Endpoints.apiSecurityKey, 'Authorization': "Bearer ${snapshot.data}"},
frameBuilder: restaurantTileFrameBuilder),
),
);
}
),
],
),
Expand Down
43 changes: 28 additions & 15 deletions lib/widgets/lostfound/lost_found_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import 'package:onestop_dev/models/lostfound/found_model.dart';
import 'package:onestop_dev/widgets/buy_sell/details_dialog.dart';
import 'package:timeago/timeago.dart' as timeago;

import '../../functions/utility/auth_user_helper.dart';
import '../../globals/endpoints.dart';

class LostFoundTile extends StatefulWidget {
final dynamic currentModel;
final BuildContext? parentContext;
Expand Down Expand Up @@ -84,21 +87,31 @@ class _LostFoundTileState extends State<LostFoundTile> {
),
),
),
ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 105, maxWidth: 135),
child: ClipRRect(
borderRadius: const BorderRadius.only(
topRight: Radius.circular(21),
bottomRight: Radius.circular(21)),
child: Image.network(
widget.currentModel.compressedImageURL,
width: screenWidth * 0.35,
cacheWidth: (screenWidth * 0.35).round(),
fit: BoxFit.cover,
frameBuilder: restaurantTileFrameBuilder,
errorBuilder: (_, __, ___) => Container(),
),
),
FutureBuilder(
future: AuthUserHelpers.getAccessToken(),
builder: (context, snapshot) {
if(snapshot.hasError || !snapshot.hasData)
{
return Container();
}
return ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 105, maxWidth: 135),
child: ClipRRect(
borderRadius: const BorderRadius.only(
topRight: Radius.circular(21),
bottomRight: Radius.circular(21)),
child: Image.network(
widget.currentModel.compressedImageURL,
width: screenWidth * 0.35,
cacheWidth: (screenWidth * 0.35).round(),
fit: BoxFit.cover,
frameBuilder: restaurantTileFrameBuilder,
errorBuilder: (_, __, ___) => Container(),
headers: {'Content-Type': 'application/json', 'security-key': Endpoints.apiSecurityKey, 'Authorization': "Bearer ${snapshot.data}"},
),
),
);
}
)
],
),
Expand Down
Loading