Skip to content

Commit

Permalink
- added flutter screen utils
Browse files Browse the repository at this point in the history
- added some text styles
- added home rich text
  • Loading branch information
AbdoAlHady committed Aug 21, 2024
1 parent dbf376c commit 19cd6fb
Show file tree
Hide file tree
Showing 10 changed files with 284 additions and 15 deletions.
10 changes: 10 additions & 0 deletions lib/core/helper/spacing.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

SizedBox verticalSpace(double height) {
return SizedBox(height: height.h);
}

SizedBox horizontalSpace(double width) {
return SizedBox(width: width.w);
}
29 changes: 29 additions & 0 deletions lib/core/theme/app_text_styles.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:google_fonts/google_fonts.dart';

abstract class AppTextStyles {
static TextStyle font32BlackW700 = GoogleFonts.poppins(
textStyle: TextStyle(
fontSize: 32.sp,
fontWeight: FontWeight.w700,
color: Colors.black,
),
);

static TextStyle font32PinkW700 = GoogleFonts.poppins(
textStyle: TextStyle(
fontSize: 32.sp,
fontWeight: FontWeight.w700,
color: Colors.pink.withOpacity(0.3),
),
);

static TextStyle font14BlakW300 = GoogleFonts.poppins(
textStyle: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.w300,
color: Colors.black,
),
);
}
17 changes: 13 additions & 4 deletions lib/translator_app.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:translator_app/core/routing/app_router.dart';
import 'package:translator_app/core/routing/routes.dart';

Expand All @@ -7,10 +8,18 @@ class TranslatorApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
onGenerateRoute: AppRouter().generateRoute,
initialRoute: Routes.homeScreen,
return ScreenUtilInit(
designSize: const Size(360, 690),
minTextAdapt: true,
splitScreenMode: true,
// Use builder only if you need to use library outside ScreenUtilInit context
builder: (_, child) {
return MaterialApp(
debugShowCheckedModeBanner: false,
onGenerateRoute: AppRouter().generateRoute,
initialRoute: Routes.homeScreen,
);
},
);
}
}
12 changes: 5 additions & 7 deletions lib/ui/screens/home_screen.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import 'package:flutter/material.dart';

import '../widgets/home/home_screen_body.dart';

class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Home Screen'),
),
body: const Center(
child: Text('Home Screen'),
),
return const Scaffold(
backgroundColor: Color(0xFFffffff),
body: HomeScreenBody(),
);
}
}
45 changes: 45 additions & 0 deletions lib/ui/widgets/home/home_rich_text.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:translator_app/core/helper/spacing.dart';
import 'package:translator_app/core/theme/app_text_styles.dart';

class HomeRichText extends StatelessWidget {
const HomeRichText({
super.key,
});

@override
Widget build(BuildContext context) {
return Text.rich(
TextSpan(
children: [
TextSpan(
text: 'Translate',
style: AppTextStyles.font32BlackW700,
),
TextSpan(
text: ' Every \n',
style: AppTextStyles.font32PinkW700,
),
TextSpan(
text: 'Type Word \n',
style: AppTextStyles.font32BlackW700,
),
WidgetSpan(child: verticalSpace(35)),
TextSpan(
text: 'Help you communicate in \n',
style: AppTextStyles.font14BlakW300,
),
TextSpan(
text: 'Different Language \n',
style: AppTextStyles.font14BlakW300,
),
],
),
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
height: 1.5,
),
);
}
}
39 changes: 39 additions & 0 deletions lib/ui/widgets/home/home_screen_body.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:translator_app/core/helper/spacing.dart';
import 'package:translator_app/core/utils/app_images.dart';
import 'package:translator_app/ui/widgets/home/home_rich_text.dart';

class HomeScreenBody extends StatelessWidget {
const HomeScreenBody({super.key});

@override
Widget build(BuildContext context) {
return Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(AppImages.imagesWorldmap),
fit: BoxFit.cover,
),
),
child: Padding(
padding: EdgeInsets.only(
top: 80.h,
left: 16.w,
right: 16.w,
),
child: SizedBox(
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// Rich Text
const HomeRichText(),
verticalSpace(35)
],
),
),
),
);
}
}
2 changes: 2 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import FlutterMacOS
import Foundation

import path_provider_foundation

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
}
138 changes: 137 additions & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.18.0"
crypto:
dependency: transitive
description:
name: crypto
sha256: ec30d999af904f33454ba22ed9a86162b35e52b44ac4807d1d93c288041d7d27
url: "https://pub.dev"
source: hosted
version: "3.0.5"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -57,6 +65,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.1"
ffi:
dependency: transitive
description:
name: ffi
sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6"
url: "https://pub.dev"
source: hosted
version: "2.1.3"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -70,11 +86,43 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.0"
flutter_screenutil:
dependency: "direct main"
description:
name: flutter_screenutil
sha256: "8239210dd68bee6b0577aa4a090890342d04a136ce1c81f98ee513fc0ce891de"
url: "https://pub.dev"
source: hosted
version: "5.9.3"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
google_fonts:
dependency: "direct main"
description:
name: google_fonts
sha256: b1ac0fe2832c9cc95e5e88b57d627c5e68c223b9657f4b96e1487aa9098c7b82
url: "https://pub.dev"
source: hosted
version: "6.2.1"
http:
dependency: transitive
description:
name: http
sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
url: "https://pub.dev"
source: hosted
version: "1.2.2"
http_parser:
dependency: transitive
description:
name: http_parser
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
leak_tracker:
dependency: transitive
description:
Expand Down Expand Up @@ -139,6 +187,70 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.9.0"
path_provider:
dependency: transitive
description:
name: path_provider
sha256: fec0d61223fba3154d87759e3cc27fe2c8dc498f6386c6d6fc80d1afdd1bf378
url: "https://pub.dev"
source: hosted
version: "2.1.4"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
sha256: "6f01f8e37ec30b07bc424b4deabac37cacb1bc7e2e515ad74486039918a37eb7"
url: "https://pub.dev"
source: hosted
version: "2.2.10"
path_provider_foundation:
dependency: transitive
description:
name: path_provider_foundation
sha256: f234384a3fdd67f989b4d54a5d73ca2a6c422fa55ae694381ae0f4375cd1ea16
url: "https://pub.dev"
source: hosted
version: "2.4.0"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279
url: "https://pub.dev"
source: hosted
version: "2.2.1"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7
url: "https://pub.dev"
source: hosted
version: "2.3.0"
platform:
dependency: transitive
description:
name: platform
sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65"
url: "https://pub.dev"
source: hosted
version: "3.1.5"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev"
source: hosted
version: "2.1.8"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -192,6 +304,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.2"
typed_data:
dependency: transitive
description:
name: typed_data
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
url: "https://pub.dev"
source: hosted
version: "1.3.2"
vector_math:
dependency: transitive
description:
Expand All @@ -208,6 +328,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "14.2.4"
web:
dependency: transitive
description:
name: web
sha256: d43c1d6b787bf0afad444700ae7f4db8827f701bc61c255ac8d328c6f4d52062
url: "https://pub.dev"
source: hosted
version: "1.0.0"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d
url: "https://pub.dev"
source: hosted
version: "1.0.4"
sdks:
dart: ">=3.5.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
flutter: ">=3.22.0"
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.8
flutter_screenutil: ^5.9.3
google_fonts: ^6.2.1

dev_dependencies:
flutter_test:
Expand Down
5 changes: 2 additions & 3 deletions test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:translator_app/main.dart';
import 'package:translator_app/translator_app.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
await tester.pumpWidget(const TranslatorApp());

// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
Expand Down

0 comments on commit 19cd6fb

Please sign in to comment.