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

errors fixed, upgraded #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
.pub-cache/
.pub/
/build/
assets/secrets.json

# Web related
lib/generated_plugin_registrant.dart
Expand Down
6 changes: 3 additions & 3 deletions lib/app/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ class _HomeScreenState extends State<HomeScreen> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
height: setContainerHeight(290),
height: setContainerHeight(307),
decoration: BoxDecoration(
color: isThemeChange.mTheme == false
? Colors.white
: Colors.grey[900],
: Colors.grey.shade900,
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(33),
bottomRight: Radius.circular(33),
),
),
child: Container(
height: setContainerHeight(290),
height: setContainerHeight(307),
child: Column(
children: <Widget>[
Container(
Expand Down
59 changes: 33 additions & 26 deletions lib/custom_theme.dart
Original file line number Diff line number Diff line change
@@ -1,70 +1,77 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:wp_blog_app/const_values.dart';

ThemeData buildLightTheme() => ThemeData.light().copyWith(
cardColor: Colors.white,
backgroundColor: Colors.grey[100],
accentColor: Colors.grey[800],
hoverColor: Colors.grey[800],
scaffoldBackgroundColor: Colors.white,
iconTheme: IconThemeData(
iconTheme: const IconThemeData(
color: defaultBlack,
),
cardTheme: CardTheme(
cardTheme: const CardTheme(
color: Colors.white,
),
dialogTheme: DialogTheme(
dialogTheme: const DialogTheme(
backgroundColor: defaultWhite,
),
dividerColor: defaultWhite,
appBarTheme: AppBarTheme(
centerTitle: true,
brightness: Brightness.dark,
elevation: 0.0,
color: defaultWhite,
textTheme: TextTheme(
headline6: TextStyle(
iconTheme: IconThemeData(
color: Colors.grey[900],
), systemOverlayStyle: SystemUiOverlayStyle.light, toolbarTextStyle: const TextTheme(
titleLarge: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
iconTheme: IconThemeData(
color: Colors.grey[900],
),
).bodyMedium, titleTextStyle: const TextTheme(
titleLarge: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.black,
),
).titleLarge,
),
textTheme: Typography.blackCupertino,
textTheme: Typography.blackCupertino, colorScheme: ColorScheme(primary: Colors.grey.shade50, brightness: Brightness.dark, onPrimary: Colors.grey.shade50, secondary: Colors.black, onSecondary: Colors.black12, error: Colors.red.shade50, onError:Colors.red.shade100, onBackground: Colors.blueGrey, surface: Colors.green.shade100, onSurface: Colors.green.shade50, background: Colors.grey.shade900),
);

ThemeData buildDarkTheme() => ThemeData.dark().copyWith(
cardColor: Colors.grey[850],
backgroundColor: Colors.grey[900],
accentColor: Colors.grey[400],
hoverColor: Colors.grey[400],
scaffoldBackgroundColor: darkColor,
dividerColor: defaultBlack,
iconTheme: IconThemeData(
iconTheme: const IconThemeData(
color: defaultWhite,
),
cardTheme: CardTheme(
color: cardColor,
),
dialogTheme: DialogTheme(
dialogTheme: const DialogTheme(
backgroundColor: defaultBlack,
),
appBarTheme: AppBarTheme(
centerTitle: true,
brightness: Brightness.dark,
elevation: 0.0,
textTheme: TextTheme(
headline6: TextStyle(
color: Colors.grey[900],
iconTheme: IconThemeData(
color: Colors.grey[400],
), toolbarTextStyle: const TextTheme(
titleLarge: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
color: Colors.grey[900],
iconTheme: IconThemeData(
color: Colors.grey[400],
),
).bodyMedium, titleTextStyle: const TextTheme(
titleLarge: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.white,
),
).titleLarge, systemOverlayStyle: SystemUiOverlayStyle.light,
),
textTheme: Typography.whiteCupertino,
textTheme: Typography.whiteCupertino, colorScheme: ColorScheme(primary: Colors.grey.shade50, brightness: Brightness.dark, onPrimary: Colors.grey.shade50, secondary: Colors.black, onSecondary: Colors.black12, error: Colors.red.shade50, onError:Colors.red.shade100, onBackground: Colors.blueGrey, surface: Colors.green.shade100, onSurface: Colors.green.shade50, background: Colors.grey.shade900),
);
10 changes: 5 additions & 5 deletions lib/models/posts.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 13 additions & 11 deletions lib/size_config.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import 'package:flutter/rendering.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';

class SizeConfig {
static double? _screenWidth;
static double? _screenHeight;
static double? _blockWidth = 0;
static double? _blockHeight = 0;
static double? _screenWidth=392.7;
static double? _screenHeight=309.2;
static double? _blockWidth = 30;
static double? _blockHeight = 30;

static double? textMultiplier;
static double? imageSizeMultiplier;
static double? heightMultiplier;
static double? widthMultiplier;
static double? textMultiplier=1;
static double? imageSizeMultiplier=1;
static double? heightMultiplier=1;
static double? widthMultiplier=1;
static bool isPortrait = true;
static bool isMobilePortrait = false;

Expand Down Expand Up @@ -38,7 +38,9 @@ class SizeConfig {
heightMultiplier = _blockHeight;
widthMultiplier = _blockWidth;

print(_blockWidth);
print(_blockHeight);
if (kDebugMode) {
print(_blockWidth);
print(_blockHeight);
}
}
}
93 changes: 53 additions & 40 deletions lib/wp_api.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';

import 'package:flutter/foundation.dart';
import 'package:html/parser.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
Expand All @@ -22,10 +23,10 @@ class WpApi {
List<Posts> posts = [];
try {
var response = await http.get(
Uri.parse("$api/posts?_embed&per_page=20"),
Uri.parse("${api}posts?_embed&per_page=20"),
headers: headers,
);

if (response.statusCode == 200) {
var convertDataToJson = json.decode(response.body);
convertDataToJson.forEach((post) {
String title = _parseHtmlString(post['title']['rendered']);
Expand All @@ -40,88 +41,100 @@ class WpApi {

var imageUrl = post['_embedded']['wp:featuredmedia'] != null
? post['_embedded']['wp:featuredmedia'][0]['source_url']
: '';
: 'https://www.naijatechguy.com/wp-content/uploads/2019/02/ntg2019-1.png';

posts.add(Posts(
title: title,
image: imageUrl,
contents: content,
time: time,
authur: "admin"
));
});
} else {
if (kDebugMode) {
print("posts?_embed&per_page=20 web service error code:${response.statusCode}");
}
}
} catch (e) {
print(e.toString());
throw (e);
if (kDebugMode) {
print(e.toString());
}
rethrow;
}

return posts;
}

// call for all Game articles
// call for all Game articles 467
Future<List<Posts>> fetchListPosts() async {
var response = await http.get(
Uri.parse(listApi + "posts?_embed&categories=467"),
Uri.parse("${listApi}posts?_embed&categories=467"),
headers: headers,
);

var convertDataToJson = jsonDecode(response.body);

List<Posts> posts = [];

if (response.statusCode == 200) {
convertDataToJson.forEach((post) {
String title = _parseHtmlString(post['title']['rendered']);

var content = _parseHtmlString(post['content']['rendered']);
var time = post['date'];

var imageUrl = post['_embedded']['wp:featuredmedia'] != null
? post['_embedded']['wp:featuredmedia'][0]['source_url']
: Image.network(
'assets/images/img_error.jpg',
fit: BoxFit.cover,
width: 100,
height: 90,
);
var imageUrl;
if (post['_embedded']['wp:featuredmedia'] != null) {
imageUrl = post['_embedded']['wp:featuredmedia'][0]['source_url'];
} else {
imageUrl = "https://www.naijatechguy.com/wp-content/uploads/2019/02/ntg2019-1.png";
}

posts.add(
Posts(title: title, image: imageUrl, contents: content, time: time));
Posts(title: title, image: imageUrl, contents: content, time: time,authur:"admin"));
});

} else {
if (kDebugMode) {
print("posts?_embed&categories=467 web service error code:${response.statusCode}");
}
}
return posts;
}

// api call for categories sections
Future<List<Posts>> fetchOtherCategories(int cartCode) async {
var response = await http.get(
Uri.parse(listApi + "posts?_embed&categories=$cartCode"),
Uri.parse("${listApi}posts?_embed&categories=$cartCode"),
headers: headers,
);

var convertDataToJson = jsonDecode(response.body);

List<Posts> posts = [];
if (response.statusCode == 200) {
var convertDataToJson = jsonDecode(response.body);

convertDataToJson.forEach((post) {
String title = _parseHtmlString(post['title']['rendered']);
convertDataToJson.forEach((post) async {
String title = _parseHtmlString(post['title']['rendered']);

var content = _parseHtmlString(post['content']['rendered']);
var time = post['date'];
var content = _parseHtmlString(post['content']['rendered']);
var time = post['date'];

var imageUrl = post['_embedded']['wp:featuredmedia'] != null
? post['_embedded']['wp:featuredmedia'][0]['source_url']
: Image.network(
'assets/images/img_error.jpg',
fit: BoxFit.cover,
width: 100,
height: 90,
);
var imageUrl;
if (post['_embedded']['wp:featuredmedia'] != null) {
imageUrl = post['_embedded']['wp:featuredmedia'][0]['source_url'];
} else {
imageUrl = "https://www.naijatechguy.com/wp-content/uploads/2019/02/ntg2019-1.png";
}

// var time = post['date'];
// var time = post['date'];

posts.add(
Posts(title: title, image: imageUrl, contents: content, time: time));
});
posts.add(
Posts(title: title, image: imageUrl, contents: content, time: time,authur:"admin"));
});
} else {
if (kDebugMode) {
print("posts?_embed&categories=$cartCode web service error code:${response.statusCode}");
}
}

return posts;
return posts;
}
}
Loading