Delete login page and add function for http requet
This commit is contained in:
12
motula_translate_app/lib/model/word.dart
Normal file
12
motula_translate_app/lib/model/word.dart
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class Word {
|
||||||
|
bool status;
|
||||||
|
String name;
|
||||||
|
String translation;
|
||||||
|
|
||||||
|
Word.fromJson(Map<String, dynamic> json):
|
||||||
|
status = json['status'],
|
||||||
|
name = json['name'],
|
||||||
|
translation = json['translation'];
|
||||||
|
}
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
|
||||||
|
|
||||||
class CourseCard extends StatelessWidget {
|
|
||||||
const CourseCard({
|
|
||||||
Key? key,
|
|
||||||
required this.title,
|
|
||||||
this.color = const Color(0xFF7553F6),
|
|
||||||
this.iconSrc = "assets/icons/ios.svg",
|
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
final String title, iconSrc;
|
|
||||||
final Color color;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Container(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
|
|
||||||
height: 280,
|
|
||||||
width: 260,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: color,
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(30)),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 6, right: 8),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
title,
|
|
||||||
style: Theme.of(context).textTheme.titleLarge!.copyWith(
|
|
||||||
color: Colors.white, fontWeight: FontWeight.w600),
|
|
||||||
),
|
|
||||||
const Padding(
|
|
||||||
padding: EdgeInsets.only(top: 12, bottom: 8),
|
|
||||||
child: Text(
|
|
||||||
"Build and animate an iOS app from scratch",
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white38,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Text(
|
|
||||||
"61 SECTIONS - 11 HOURS",
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white38,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
Row(
|
|
||||||
children: List.generate(
|
|
||||||
3,
|
|
||||||
(index) => Transform.translate(
|
|
||||||
offset: Offset((-10 * index).toDouble(), 0),
|
|
||||||
child: CircleAvatar(
|
|
||||||
radius: 20,
|
|
||||||
backgroundImage: AssetImage(
|
|
||||||
"assets/avaters/Avatar ${index + 1}.jpg",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SvgPicture.asset(iconSrc),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_svg/svg.dart';
|
|
||||||
|
|
||||||
class SecondaryCourseCard extends StatelessWidget {
|
|
||||||
const SecondaryCourseCard({
|
|
||||||
Key? key,
|
|
||||||
required this.title,
|
|
||||||
this.iconsSrc = "assets/icons/ios.svg",
|
|
||||||
this.colorl = const Color(0xFF7553F6),
|
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
final String title, iconsSrc;
|
|
||||||
final Color colorl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Container(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: colorl,
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(20))),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
title,
|
|
||||||
style: Theme.of(context).textTheme.headlineSmall!.copyWith(
|
|
||||||
color: Colors.white,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
const Text(
|
|
||||||
"Watch video - 15 mins",
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white60,
|
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 40,
|
|
||||||
child: VerticalDivider(
|
|
||||||
// thickness: 5,
|
|
||||||
color: Colors.white70,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
SvgPicture.asset(iconsSrc)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import '../../../model/word.dart';
|
||||||
|
|
||||||
|
|
||||||
|
class WordsScreen extends StatefulWidget {
|
||||||
|
const WordsScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<WordsScreen> createState() => _WordsScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _WordsScreenState extends State<WordsScreen> {
|
||||||
|
Future<Word> fetchWord() async {
|
||||||
|
final response = await http.get(
|
||||||
|
Uri.parse("https://5ddc-37-101-56-133.ngrok-free.app/api/words/tasto"));
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return Word.fromJson(jsonDecode(response.body));
|
||||||
|
} else {
|
||||||
|
throw Exception('Failed to fetch Word');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return FutureBuilder<Word>(
|
||||||
|
future: fetchWord(),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.hasData) {
|
||||||
|
// Display the fetched joke when data is available
|
||||||
|
return Center(child: Text(
|
||||||
|
snapshot.data!.translation,
|
||||||
|
style: TextStyle(fontSize: 30, color: Colors.grey[800])
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else if (snapshot.hasError) {
|
||||||
|
// Display an error message if there's an error
|
||||||
|
return Text('${snapshot.error}');
|
||||||
|
} else {
|
||||||
|
// Display a loading indicator while waiting for data
|
||||||
|
return Center(child: CircularProgressIndicator());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../model/course.dart';
|
import '../../model/word.dart';
|
||||||
import 'components/course_card.dart';
|
import 'components/words_screen.dart';
|
||||||
import 'components/secondary_course_card.dart';
|
|
||||||
|
|
||||||
class HomePage extends StatelessWidget {
|
class HomePage extends StatelessWidget {
|
||||||
const HomePage({super.key});
|
const HomePage({super.key});
|
||||||
@@ -10,37 +10,46 @@ class HomePage extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: SafeArea(
|
body: SingleChildScrollView(
|
||||||
bottom: false,
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 30),
|
|
||||||
Image(
|
Image(
|
||||||
image: AssetImage('assets/Logo/LogoHome.png'),
|
image: AssetImage('assets/Logo/LogoHome.png'),
|
||||||
),
|
),
|
||||||
|
Row(children: [
|
||||||
|
Text('TO', style: TextStyle(fontSize: 30, color: Colors.grey[800])),
|
||||||
|
Text('--->', style: TextStyle(fontSize: 30, color: Colors.grey[800])),
|
||||||
|
Text('DO', style: TextStyle(fontSize: 30, color: Colors.grey[800])),
|
||||||
|
]),
|
||||||
|
const SizedBox(height: 20),
|
||||||
TextField(
|
TextField(
|
||||||
keyboardType: TextInputType.text,
|
keyboardType: TextInputType.multiline,
|
||||||
|
maxLines: null,
|
||||||
|
style: TextStyle(fontSize: 20, color: Colors.grey[800]),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'Parola Italiana'
|
hintText: 'Parola Italiana',
|
||||||
|
hintStyle: TextStyle(fontSize: 20)
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {},
|
onPressed: () {
|
||||||
|
|
||||||
|
},
|
||||||
child: const Text('Traduci'),
|
child: const Text('Traduci'),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Colors.orange,
|
backgroundColor: Colors.orange,
|
||||||
padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20),
|
padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20),
|
||||||
textStyle: TextStyle(
|
textStyle: TextStyle(
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
fontWeight: FontWeight.bold)),
|
fontWeight: FontWeight.bold)),
|
||||||
),
|
),
|
||||||
Text('')
|
const SizedBox(height: 30),
|
||||||
|
WordsScreen(),
|
||||||
|
//Text('ToDo', style: TextStyle(fontSize: 30, color: Colors.grey[800]))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:rive/rive.dart';
|
import 'package:rive/rive.dart';
|
||||||
|
|
||||||
|
import '../entryPoint/entry_point.dart';
|
||||||
import 'components/animated_btn.dart';
|
import 'components/animated_btn.dart';
|
||||||
import 'components/sign_in_dialog.dart';
|
import 'components/sign_in_dialog.dart';
|
||||||
|
|
||||||
@@ -97,17 +98,26 @@ class _OnbodingScreenState extends State<OnbodingScreen> {
|
|||||||
btnAnimationController: _btnAnimationController,
|
btnAnimationController: _btnAnimationController,
|
||||||
press: () {
|
press: () {
|
||||||
_btnAnimationController.isActive = true;
|
_btnAnimationController.isActive = true;
|
||||||
|
|
||||||
Future.delayed(
|
Future.delayed(
|
||||||
const Duration(milliseconds: 800),
|
const Duration(milliseconds: 800),
|
||||||
() {
|
() {
|
||||||
setState(() {
|
setState(() {
|
||||||
isShowSignInDialog = true;
|
isShowSignInDialog = true;
|
||||||
});
|
});
|
||||||
showCustomDialog(
|
Future.delayed(const Duration(milliseconds: 800), () {
|
||||||
context,
|
// Navigator.pop(context);
|
||||||
onValue: (_) {},
|
Navigator.push(
|
||||||
);
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => const EntryPoint(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
//EntryPoint();
|
||||||
|
//showCustomDialog(
|
||||||
|
// context,
|
||||||
|
// onValue: (_) {},
|
||||||
|
//);
|
||||||
// showCustomDialog(
|
// showCustomDialog(
|
||||||
// context,
|
// context,
|
||||||
// onValue: (_) {
|
// onValue: (_) {
|
||||||
|
|||||||
Reference in New Issue
Block a user