Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Bug Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kaungsatthe1n committed Jan 27, 2022
1 parent ad4e173 commit a1c1e7f
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 78 deletions.
21 changes: 15 additions & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:logging/logging.dart';
import 'package:provider/provider.dart';
import 'package:sizer/sizer.dart';
import './provider/connectivitymanager.dart';
import './provider/navmanager.dart';
import './provider/tabmanager.dart';
import './screens/splash_screen.dart';
import './services/anime_service.dart';
import './theme/tako_theme.dart';

void main() {
void main() async {
_setUpLogging();
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([
await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]).then((_) => runApp(const MyApp()));
DeviceOrientation.portraitDown,
]);
runApp(const MyApp());
}

void _setUpLogging() {
Expand All @@ -40,8 +42,15 @@ class MyApp extends StatelessWidget {
dispose: (_, AnimeService service) => service.client.dispose(),
),
],
child: Sizer(
builder: (context, orientation, deviceType) => MaterialApp(
child: ScreenUtilInit(
designSize: const Size(360, 690),
builder: () => MaterialApp(
builder: (context, widget) {
ScreenUtil.setContext(context);
return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
child: widget!);
},
debugShowCheckedModeBanner: false,
title: 'Tako Anime Tracker',
theme: TakoTheme.dark(),
Expand Down
8 changes: 3 additions & 5 deletions lib/screens/anime_detail_screen.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import 'dart:convert';
import 'dart:ui';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:chopper/chopper.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import 'package:sizer/sizer.dart';
import 'package:tako/models/anime_model.dart';
import 'package:tako/provider/navmanager.dart';
import 'package:tako/screens/video_list_screen.dart';
Expand Down Expand Up @@ -64,7 +62,7 @@ class _AnimeDetailScreenState extends State<AnimeDetailScreen> {

return SingleChildScrollView(
child: SizedBox(
height: 100.h,
height: screenHeight,
child: Stack(
fit: StackFit.expand,
children: [
Expand All @@ -82,7 +80,7 @@ class _AnimeDetailScreenState extends State<AnimeDetailScreen> {
child: Container(
color: Colors.black87,
width: double.infinity,
height: 100.h,
height: screenHeight,
),
),
Positioned(
Expand Down Expand Up @@ -339,7 +337,7 @@ class _AnimeDetailScreenState extends State<AnimeDetailScreen> {
child: Container(
color: Colors.black87,
width: double.infinity,
height: 100.h,
height: screenHeight,
),
),
],
Expand Down
6 changes: 2 additions & 4 deletions lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'dart:ui';
import 'package:sizer/sizer.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:chopper/chopper.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
Expand All @@ -27,7 +25,7 @@ class _HomeScreenState extends State<HomeScreen> {
Widget build(BuildContext context) {
final animeService = Provider.of<AnimeService>(context);
const itemHeight = 300;
final itemWidth = 100.w / 2;
final itemWidth = screenWidth / 2;
return FutureBuilder<Response<APISeasonResult>>(
future: selectedCategory == 1
? animeService.getCurrentSeasonList(
Expand Down Expand Up @@ -200,7 +198,7 @@ class NoMoreResult extends StatelessWidget {
style: TakoTheme.darkTextTheme.subtitle2,
),
SizedBox(
height: 15.h,
height: screenHeight * .15,
),
MaterialButton(
onPressed: onTap,
Expand Down
13 changes: 6 additions & 7 deletions lib/screens/no_internet_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:sizer/sizer.dart';
import 'package:tako/theme/tako_theme.dart';
import 'package:tako/util/constant.dart';

Expand All @@ -14,26 +13,26 @@ class NoInternetScreen extends StatelessWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
const Icon(
Icons.wifi_off_rounded,
size: 80.sp,
size: 80,
),
SizedBox(height: 3.h),
const SizedBox(height: 3),
Text(
'Oops !',
style: TakoTheme.darkTextTheme.headline1,
),
SizedBox(height: 5.h),
const SizedBox(height: 15),
Text(
'There is no internet connection',
style: TakoTheme.darkTextTheme.subtitle2,
),
SizedBox(height: 02.h),
const SizedBox(height: 10),
Text(
'Please check your internet connection',
style: TakoTheme.darkTextTheme.subtitle2,
),
SizedBox(height: 05.h),
const SizedBox(height: 15),
MaterialButton(
onPressed: () {},
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 12),
Expand Down
3 changes: 1 addition & 2 deletions lib/screens/search_by_genre.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:chopper/chopper.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:sizer/sizer.dart';
import 'package:tako/components/anime_card.dart';
import 'package:tako/models/anime_model.dart';
import 'package:tako/models/genre.dart';
Expand All @@ -27,7 +26,7 @@ class _SearchByGenreScreenState extends State<SearchByGenreScreen> {
@override
Widget build(BuildContext context) {
const itemHeight = 300;
final itemWidth = 100.w / 2;
final itemWidth = screenWidth / 2;

return Scaffold(
appBar: AppBar(
Expand Down
9 changes: 4 additions & 5 deletions lib/screens/splash_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:sizer/sizer.dart';
import 'package:tako/screens/main_screen.dart';
import 'package:tako/util/constant.dart';

Expand Down Expand Up @@ -36,15 +35,15 @@ class _SplashScreenState extends State<SplashScreen> {
Container(
alignment: Alignment.center,
decoration: const BoxDecoration(color: tkDarkerBlue),
width: 100.w,
height: 80.h,
width: screenWidth,
height: screenHeight * .8,
child: Image.asset(
'assets/images/logo-nobackground.png',
width: 50.w,
width: screenWidth * .5,
),
),
Container(
width: 40.w,
width: screenWidth * .4,
decoration: BoxDecoration(borderRadius: BorderRadius.circular(15)),
child: const LinearProgressIndicator(
backgroundColor: Colors.grey,
Expand Down
7 changes: 4 additions & 3 deletions lib/screens/voice_actor_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:tako/models/anime_model.dart';
import 'package:tako/services/anime_service.dart';
import 'package:tako/theme/tako_theme.dart';
import 'package:tako/util/constant.dart';
import 'package:sizer/sizer.dart';

class VoiceActorScreen extends StatelessWidget {
const VoiceActorScreen({Key? key, required this.id}) : super(key: key);
Expand Down Expand Up @@ -47,7 +46,7 @@ class VoiceActorScreen extends StatelessWidget {
topLeft: Radius.circular(10),
bottomLeft: Radius.circular(10)),
child: CachedNetworkImage(
width: 40.w,
width: screenWidth * .4,
fit: BoxFit.cover,
// ignore: unnecessary_null_comparison
imageUrl: characters[index].voiceActors!.isEmpty
Expand Down Expand Up @@ -79,7 +78,9 @@ class VoiceActorScreen extends StatelessWidget {
// ignore: unnecessary_null_comparison
characters[index].voiceActors!.isEmpty
? ''
: characters[index].voiceActors![0].name!,
: characters[index]
.voiceActors![0]
.name!,
style: TakoTheme.darkTextTheme.headline4,
),
),
Expand Down
36 changes: 29 additions & 7 deletions lib/screens/youtubeview_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:tako/util/constant.dart';
import 'package:webview_flutter/webview_flutter.dart';

class YouTubeViewScreen extends StatefulWidget {
Expand All @@ -12,6 +13,24 @@ class YouTubeViewScreen extends StatefulWidget {
}

class _YouTubeViewScreenState extends State<YouTubeViewScreen> {
@override
void initState() {
super.initState();
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight
]);
}

@override
void dispose() {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
super.dispose();
}

final Completer<WebViewController> _controller =
Completer<WebViewController>();
@override
Expand All @@ -22,12 +41,15 @@ class _YouTubeViewScreenState extends State<YouTubeViewScreen> {
),
body: Builder(
builder: (BuildContext context) {
return WebView(
initialUrl: widget.url,
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webviewctrl) {
_controller.complete(webviewctrl);
},
return SizedBox.fromSize(
size: Size(screenWidth, screenHeight),
child: WebView(
initialUrl: widget.url,
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webviewctrl) {
_controller.complete(webviewctrl);
},
),
);
},
),
Expand Down
36 changes: 18 additions & 18 deletions lib/theme/tako_theme.dart
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:sizer/sizer.dart';
import 'package:tako/util/constant.dart';

class TakoTheme {
static TextTheme darkTextTheme = TextTheme(
bodyText1: GoogleFonts.lato(
fontSize: 14.0.sp,
static TextTheme darkTextTheme = const TextTheme(
bodyText1: TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.w700,
color: Colors.white,
),
subtitle1: GoogleFonts.lato(
fontSize: 12.0.sp,
subtitle1: TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.w700,
color: Colors.white,
),
subtitle2: GoogleFonts.lato(
fontSize: 14.0.sp,
subtitle2: TextStyle(
fontSize: 14.0,
color: Colors.white,
),
headline1: GoogleFonts.lato(
fontSize: 28.0.sp,
headline1: TextStyle(
fontSize: 24.0,
fontWeight: FontWeight.bold,
color: Colors.white,
),
headline2: GoogleFonts.lato(
fontSize: 17.0.sp,
headline2: TextStyle(
fontSize: 17.0,
fontWeight: FontWeight.w700,
color: Colors.white,
),
headline3: GoogleFonts.lato(
fontSize: 14.0.sp,
headline3: TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.w600,
color: Colors.white,
decoration: TextDecoration.none,
),
headline4: GoogleFonts.lato(
fontSize: 21.0.sp,
headline4: TextStyle(
fontSize: 21.0,
fontWeight: FontWeight.w700,
color: Colors.white,
decoration: TextDecoration.none,
),
headline6: GoogleFonts.lato(
fontSize: 16.0.sp,
headline6: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w600,
color: Colors.white,
),
Expand Down Expand Up @@ -74,6 +73,7 @@ class TakoTheme {
fillColor: MaterialStateProperty.all(tkLightGreen.withAlpha(205)),
),
textTheme: darkTextTheme,
fontFamily: GoogleFonts.poppins().fontFamily,
);
}
}
3 changes: 3 additions & 0 deletions lib/util/constant.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

// ignore: non_constant_identifier_names
Color HexColor(String hex) => Color(int.parse('0xFF$hex'));
Expand All @@ -11,3 +12,5 @@ const Color tkLightGreen = Color(0xFF28B67E);

const Color tkGrey = Color(0xFFD3DCDE);
const Color tkwhite = Color(0xFFECE9E9);
final screenWidth = ScreenUtil().screenWidth;
final screenHeight = ScreenUtil().screenHeight;
Loading

0 comments on commit a1c1e7f

Please sign in to comment.