repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/tutorial_app/lib
mirrored_repositories/tutorial_app/lib/pages/register_page.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:tutorial_app/components/my_button.dart'; import 'package:tutorial_app/components/my_textfield.dart'; import 'package:tutorial_app/components/square_tile.dart'; import 'package:tutorial_app/controllers/user_controller.dart'; import 'package:tutorial_app/services/auth_service.dart'; class RegisterPage extends StatefulWidget { const RegisterPage({super.key,required this.onTap}); final Function()? onTap; @override State<RegisterPage> createState() => _RegisterPageState(); } class _RegisterPageState extends State<RegisterPage> { final emailController=TextEditingController(); final passwordController=TextEditingController(); final confirmPasswordController=TextEditingController(); final ProfileController profileController=Get.find(); void errorPop(String text){ showDialog(context: context, builder: (context){ return AlertDialog( title:Text(text), ); }); } void signUserUp()async{ try{ if(emailController.text==''){ errorPop('Invalid Email'); }else if(passwordController.text!=confirmPasswordController.text){ errorPop('Password Miss Match'); }else{ // showDialog(context: context, builder: (context){ // return Center(child: CircularProgressIndicator(),); // }); final result=await FirebaseAuth.instance.createUserWithEmailAndPassword( email: emailController.text, password: passwordController.text ); if (result.user!=null){ final user=result.user; print('EMAIL SIGN IN USER'+user.toString()); await profileController.createUserProfile(user!.uid, user.email.toString()); await profileController.loadUserProfile(user!.uid); } //Navigator.pop(context); } }on FirebaseAuthException catch(e){ errorPop(e.code); } } @override Widget build(BuildContext context) { return Scaffold( body: SafeArea( child: SingleChildScrollView( child: Column( children: [ SizedBox(height: 20,), Center( child: Icon(Icons.key,size: 100,), ), SizedBox(height: 30,), Text('Let\'s create an account',style: TextStyle( color: Colors.grey[700], fontSize: 16 ),), SizedBox(height: 50,), MyTextField( controller: emailController, hintText: 'Email', obscureText: false, ), SizedBox(height: 20,), MyTextField(controller: passwordController, hintText: 'Password', obscureText: true), SizedBox(height: 20,), MyTextField(controller: confirmPasswordController, hintText: 'Confirm Password', obscureText: true) ,SizedBox(height: 10,), MyButton(onTap: signUserUp,text:'Sign Up'), SizedBox(height:50), Row( children: [ Expanded(child: Divider( thickness: 0.5, color: Colors.grey[400], )),Text(' Or Register With ',style: TextStyle( color: Colors.grey[700] ),), Expanded(child: Divider( thickness: 0.5, color: Colors.grey[400], )) ], ), SizedBox(height: 25,), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ SquareTile(imagePath: 'assets/google.png',onTap:(){ AuthService().signInWithGoogle(); }), SizedBox(width: 10,), SquareTile(imagePath: 'assets/apple.png',onTap: () { },), ], ), SizedBox(height:25 ,), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text('Already Have an account?'), SizedBox(width: 4,), GestureDetector( onTap: widget.onTap, child: Text('Log In',style: TextStyle(color: Colors.amberAccent,fontWeight: FontWeight.bold),), ) ], ) ], ), ), ), ); } }
0
mirrored_repositories/tutorial_app/lib
mirrored_repositories/tutorial_app/lib/pages/story_page.dart
import 'package:flutter/material.dart'; import 'package:flutter_tts/flutter_tts.dart'; import 'package:get/get.dart'; import 'package:tutorial_app/controllers/story_controller.dart'; class StoryPage extends StatefulWidget { StoryPage({super.key,required this.name}); final String name; @override State<StoryPage> createState() => _StoryPageState(); } class _StoryPageState extends State<StoryPage> { final StoryController storyController=Get.find(); int index=0; int maxIndex=0; bool isPlaying=false; FlutterTts flutterTts=FlutterTts(); Future<void> configureTts()async{ await flutterTts.setLanguage('en-US'); await flutterTts.setSpeechRate(0.3); await flutterTts.setVolume(1.0); } void speakText(String text)async{ await flutterTts.speak(text); setState(() { isPlaying=true; }); } void stopSpeaking()async{ await flutterTts.stop(); setState(() { isPlaying=false; }); } @override void dispose() { //TODO: implement dispose super.dispose(); flutterTts.stop(); } @override void initState() { //TODO: implement initState super.initState(); storyController.fetchStories(widget.name); configureTts(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: AppBar(), body: Container( height: MediaQuery.of(context).size.height, decoration: BoxDecoration( image: DecorationImage(image: AssetImage('assets/storytell.jpeg'),fit: BoxFit.fitWidth) ), child: Obx((){ if(storyController.isLoading.value){ return Center( child: CircularProgressIndicator(), ); }else if(storyController.isEmpty.value){ return Center( child: Text('No stories to show!'), ); }else{ maxIndex=storyController.stories.length-1; return Center( child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Text(storyController.stories[index]['title'],style: TextStyle( fontSize: 25, fontWeight: FontWeight.bold ),), Row( children: [ IconButton(onPressed: (){ !isPlaying?speakText(storyController.stories[index]['story']):stopSpeaking(); }, icon: !isPlaying?Icon(Icons.play_circle_outline,color: Colors.blue,size: 50,):Icon(Icons.stop_circle_outlined,color: Color.fromARGB(255, 179, 10, 5),size: 50,)), ], ), Text(storyController.stories[index]['story'],style: TextStyle(fontSize: 18),), SizedBox(height: 30,), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ TextButton( style: TextButton.styleFrom( backgroundColor: Color.fromARGB(255, 170, 199, 8) ), onPressed: (){ setState(() { if(index+1<=maxIndex){ index++; } }); }, child: Text('Next')), ], ) ], ), ), ); } }), ), ); } }
0
mirrored_repositories/tutorial_app/lib
mirrored_repositories/tutorial_app/lib/pages/admin_page.dart
import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:get/get.dart'; import 'package:tutorial_app/controllers/tutorial_controller.dart'; class AddQuestionPage extends StatefulWidget { const AddQuestionPage({super.key,required this.name}); final String name; @override State<AddQuestionPage> createState() => _AddQuestionPageState(); } class _AddQuestionPageState extends State<AddQuestionPage> { TextEditingController questionNumberController=TextEditingController(); TextEditingController questionController=TextEditingController(); TextEditingController answerController=TextEditingController(); TextEditingController answersController=TextEditingController(); final TutorialController tutorialController=Get.find(); void addQuestion()async{ final question=questionController.text; final answer=answerController.text; final answers=answersController.text.split(','); if(question!='' && answer!=''&& answers.length>3&& answers.length<5){ final result=await tutorialController.addNewQuestion(question, answer, answers, widget.name); if(result){ questionController.text=''; answerController.text=''; answersController.text=''; } }else{ Get.snackbar('Error', 'All the fields must be filled'); } } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, appBar: AppBar( backgroundColor: Color.fromARGB(255, 46, 46, 46), ), body: Container( width: MediaQuery.of(context).size.width, height:MediaQuery.of(context).size.height, color: Color.fromARGB(255, 12, 12, 12), child: SingleChildScrollView( child: Column( children: [ Form(child: Column( children: [ SizedBox(height: 10,), Center( child: Container( width: 300, height: 300, decoration: BoxDecoration( borderRadius: BorderRadius.circular(200), image: DecorationImage(image: AssetImage('assets/questionback2.jpeg'),fit: BoxFit.cover)), ), ), SizedBox(height: 10,), Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ FormFieldWid(controller: questionController, label: 'Question'), SizedBox(height: 10,), FormFieldWid(controller: answerController, label: 'Correct Answer'), SizedBox(height: 10,), FormFieldWid(controller: answersController, label: 'List of Answers (comma-separated)'), ], ), ), ElevatedButton( style: ButtonStyle( ), onPressed: (){ addQuestion(); }, child: Text('Add Question')) ], )) ], ), ), ), ); } } class FormFieldWid extends StatelessWidget { const FormFieldWid({super.key,required this.controller,required this.label}); final TextEditingController controller; final String label; @override Widget build(BuildContext context) { return TextFormField( controller: controller, style: TextStyle(color: Colors.white), decoration: InputDecoration( focusedBorder: OutlineInputBorder( borderSide: BorderSide( width: 3, color: const Color.fromARGB(255, 202, 105, 240)), borderRadius: BorderRadius.circular(10) ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( color: Colors.white ), borderRadius: BorderRadius.circular(10) ), labelText: label), ); } }
0
mirrored_repositories/tutorial_app/lib
mirrored_repositories/tutorial_app/lib/pages/add_story_page.dart
import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:get/get.dart'; import 'package:tutorial_app/controllers/story_controller.dart'; class AddStoryPage extends StatefulWidget { const AddStoryPage({super.key,required this.name}); final String name; @override State<AddStoryPage> createState() => _AddStoryPageState(); } class _AddStoryPageState extends State<AddStoryPage> { StoryController storyController=Get.find(); final TextEditingController tytleController=TextEditingController(); final TextEditingController storytextController=TextEditingController(); @override void initState() { // TODO: implement initState super.initState(); } void addStory()async{ if(tytleController.text!=''&& storytextController.text!=''){ final result=await storyController.uploadStory(widget.name,tytleController.text ,storytextController.text); if(result){ Get.snackbar('Success', '${tytleController.text} Added to the DB'); tytleController.text=''; storytextController.text=''; } }else{ Get.snackbar('Error', 'Field cannot be empty'); } } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, appBar: AppBar( title: Text(widget.name,style: TextStyle(color: Colors.white),), iconTheme: IconThemeData(color: Colors.white), backgroundColor: Colors.black12, ), body: Padding( padding: const EdgeInsets.all(8.0), child: SingleChildScrollView( child: Column( children: [ Container( width: 150, height: 150, decoration: BoxDecoration( image: DecorationImage(image: AssetImage('assets/addstory.jpeg')) ), ), SizedBox(height: 10,), Text('Add a Story',style: TextStyle(color: Colors.white,fontSize: 25,fontWeight: FontWeight.bold),), SizedBox(height: 20,), TextField( style: TextStyle(color: Colors.white), controller: tytleController, decoration: InputDecoration( label: Text('Title'), focusedBorder: OutlineInputBorder( borderSide: BorderSide( color: Colors.green ), borderRadius: BorderRadius.circular(10) ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( color: const Color.fromARGB(255, 239, 243, 239) ), borderRadius: BorderRadius.circular(10) ) ), ), SizedBox(height: 10,), TextField( controller: storytextController, maxLines: 10, style: TextStyle(color: Colors.white), decoration: InputDecoration( label: Text('Story'), focusedBorder: OutlineInputBorder( borderSide: BorderSide( color: Colors.green ), borderRadius: BorderRadius.circular(10) ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( color: const Color.fromARGB(255, 239, 243, 239) ), borderRadius: BorderRadius.circular(10) ) ), ), SizedBox(height:10), TextButton(onPressed: (){ addStory(); }, style: TextButton.styleFrom( backgroundColor: Colors.white ), child:Text('Add Story')) ] ), ), ), ); } }
0
mirrored_repositories/tutorial_app/lib
mirrored_repositories/tutorial_app/lib/pages/lesson_page.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:tutorial_app/controllers/lessons_controller.dart'; class LessonPage extends StatefulWidget { const LessonPage({super.key,required this.subject}); final String subject; @override State<LessonPage> createState() => _LessonPageState(); } class _LessonPageState extends State<LessonPage> { final LessonController lessonController=Get.find(); int index=0; @override void initState() { // TODO: implement initState super.initState(); lessonController.fetchLessons(widget.subject); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(), body: Obx((){ if(lessonController.isLoading.value){ return Center(child: CircularProgressIndicator()); }else if(lessonController.isEmpty.value){ return Center( child: Text('No lessons yet!'), ); }else{ return TutorialBox(index: index,controller: lessonController,); } }), ); } } class TutorialBox extends StatefulWidget { TutorialBox({super.key,required this.index,required this.controller}); final LessonController controller; final int index; @override State<TutorialBox> createState() => _TutorialBoxState(); } class _TutorialBoxState extends State<TutorialBox> { @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.all(8.0), child: Container( child: SingleChildScrollView( child: Column( children: [ Container( decoration: BoxDecoration( border: Border(bottom: BorderSide( color: Color.fromARGB(255, 3, 30, 61), width: 3 )) ), child: Center(child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Icon(Icons.book_online_rounded,color: Colors.orange,size: 50,), Expanded( child: Text( widget.controller.lessons[0]['title'],style: TextStyle( color: const Color.fromARGB(255, 39, 39, 41),fontSize: 24,fontWeight: FontWeight.bold),), ), ], )), ), SizedBox(height: 10,), Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Color.fromARGB(97, 193, 206, 9) ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('Objective',style: TextStyle(color: Colors.black,fontSize: 20,fontWeight: FontWeight.w500),), Text('* '+widget.controller.lessons[widget.index]['objective']), ], ), ), ), SizedBox(height: 10,), Image.network( widget.controller.lessons[widget.index]['imageUrl'], loadingBuilder: (BuildContext context,Widget child,ImageChunkEvent? loadingProgress){ if(loadingProgress==null){ return child; }else{ return Center( child: CircularProgressIndicator(value:loadingProgress.expectedTotalBytes!=null?loadingProgress.cumulativeBytesLoaded/loadingProgress.expectedTotalBytes!:null), ); } },errorBuilder: (BuildContext context,Object exception,StackTrace? stackTrace) { return Center( child: Text('Faild to load the image'), ); }, ), SizedBox(height: 10,), Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Color.fromARGB(96, 9, 176, 206) ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('Introduction',style: TextStyle(color: Colors.black,fontSize: 20,fontWeight: FontWeight.w500),), Text(widget.controller.lessons[widget.index]['intro']), ], ), ), ), SizedBox(height: 10,), Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Color.fromARGB(95, 223, 23, 163) ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('Content',style: TextStyle(color: Colors.black,fontSize: 20,fontWeight: FontWeight.w500),), Text(widget.controller.lessons[widget.index]['lesson']), ], ), ), ), SizedBox(height: 10,), Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Color.fromARGB(166, 203, 238, 3) ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('Activity',style: TextStyle(color: Colors.black,fontSize: 20,fontWeight: FontWeight.w500),), Text(widget.controller.lessons[widget.index]['activity']), ], ), ), ), ], ), ), ), ); } }
0
mirrored_repositories/tutorial_app/lib
mirrored_repositories/tutorial_app/lib/pages/auth_page.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:tutorial_app/controllers/user_controller.dart'; import 'package:tutorial_app/pages/home_page.dart'; import 'package:tutorial_app/pages/login_or_register.dart'; import 'package:tutorial_app/pages/login_page.dart'; class AuthPage extends StatelessWidget { const AuthPage({super.key}); @override Widget build(BuildContext context) { final ProfileController profileController=Get.find(); return Scaffold( body:StreamBuilder<User?>(stream: FirebaseAuth.instance.authStateChanges(), builder: (context,snapshot){ if(snapshot.hasData){ return Obx((){ if(profileController.isLoading.value){ return Container(); }else{ return HomePage(); } }); }else{ return LoginOrRegisterPage(); } }), ); } }
0
mirrored_repositories/tutorial_app/lib
mirrored_repositories/tutorial_app/lib/pages/login_page.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:tutorial_app/components/my_button.dart'; import 'package:tutorial_app/components/my_textfield.dart'; import 'package:tutorial_app/components/square_tile.dart'; import 'package:tutorial_app/controllers/user_controller.dart'; import 'package:tutorial_app/services/auth_service.dart'; class LoginPage extends StatefulWidget { LoginPage({super.key, required this.onTap}); final Function()? onTap; @override State<LoginPage> createState() => _LoginPageState(); } class _LoginPageState extends State<LoginPage> { //Text Editing controllers final emailController=TextEditingController(); final passwordController=TextEditingController(); void wrongCredPop(bool? error){ showDialog(context: context, builder: (context){ return AlertDialog( icon: Icon(Icons.logout_sharp), title:error==null? Text('Invalid Email or Password',style: TextStyle(fontSize: 12),): Text('Something went wrong!',style: TextStyle(fontSize: 12),), ); }); } void signUserIn()async{ showDialog(context: context, builder: (cotext){ return Center(child: CircularProgressIndicator()); }); try{ final result= await FirebaseAuth.instance.signInWithEmailAndPassword( email: emailController.text, password: passwordController.text); Navigator.pop(context); if(result.user!=null){ final user=result.user; ProfileController().loadUserProfile(user!.uid); } }on FirebaseAuthException catch(e){ if(e.code=='INVALID_LOGIN_CREDENTIALS'){ wrongCredPop(null); print('Invalid email or password'); }else{ wrongCredPop(true); } } } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.grey, body: SafeArea( child: Center( child: SingleChildScrollView( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const SizedBox(height: 50,), const Icon(Icons.lock,size: 100,), const SizedBox(height: 50,), const Text('Welcome Back You\'ve been missed!', style: TextStyle( fontSize: 16, color: Color.fromARGB(255, 43, 42, 42)),) , const SizedBox(height: 50,), MyTextField( controller: emailController, hintText: 'Username', obscureText: false, ), const SizedBox(height: 20,), MyTextField( controller: passwordController, hintText: 'Password', obscureText: true, ), const SizedBox(height: 10,), const Padding( padding: EdgeInsets.symmetric(horizontal: 10), child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Text('Forgot Password?',style: TextStyle(color: const Color.fromARGB(255, 97, 97, 97)),) ], ), ), const SizedBox(height: 25,), MyButton( onTap: signUserIn, text: 'Sign In', ),SizedBox(height: 50,), Row( children: [ Expanded(child: Divider( thickness: 0.5, color: Colors.grey[400] )), Text(' Or Continue With ',style: TextStyle(color: Colors.grey[700]),), Expanded(child: Divider( thickness: 0.5, color: Colors.grey[400], )), ], ), SizedBox(height: 25,), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ SquareTile(imagePath: 'assets/google.png',onTap: () => AuthService().signInWithGoogle(),), SizedBox(width: 10,), SquareTile(imagePath: 'assets/apple.png',onTap: () { },), ], ),SizedBox(height: 25,), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text('Not a member?',style: TextStyle(color: Colors.grey[700]),), SizedBox(width: 4,), GestureDetector( onTap: widget.onTap, child: Text('Register now!',style: TextStyle(color: Colors.blueAccent,fontWeight: FontWeight.bold),)) ], ) ], ), ), ), ), ); } }
0
mirrored_repositories/tutorial_app/lib
mirrored_repositories/tutorial_app/lib/pages/quiz_page.dart
import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:get/get.dart'; import 'package:loading_animation_widget/loading_animation_widget.dart'; import 'package:tutorial_app/components/quiz_box.dart'; import 'package:tutorial_app/controllers/tutorial_controller.dart'; class QuizPage extends StatefulWidget { const QuizPage({super.key,required this.name}); final String name; @override State<QuizPage> createState() => _QuizPageState(); } class _QuizPageState extends State<QuizPage> { final TutorialController tutorialController=Get.find(); @override Widget build(BuildContext context) { return Scaffold( extendBodyBehindAppBar: true, backgroundColor: Colors.white, appBar: AppBar( backgroundColor: Colors.transparent, ), body: Container( decoration: BoxDecoration( image: DecorationImage(image: AssetImage('assets/background.jpeg'),fit: BoxFit.cover) ), child: Obx( (){ if(tutorialController.isLoading.value){ return Center( child: LoadingAnimationWidget.waveDots( color: Colors.red, size: 40 ), ); }else if(tutorialController.Data.isEmpty){ return Center( child: Column( children: [ SizedBox(height: 250,), Container( height: 150, decoration: BoxDecoration( image: DecorationImage(image: NetworkImage('https://media.tenor.com/YoAqt_jAr-UAAAAi/sad-broken-heart.gif'),fit: BoxFit.contain) ), ), Text('No Quizes Available',style: TextStyle(fontSize: 25,fontWeight: FontWeight.bold),), ], ), ); }else{ return Column( children: [ SizedBox(height: 100,), Text(widget.name,style: TextStyle(fontSize: 30,fontWeight: FontWeight.bold),), SizedBox(height: 30,), QuizBox(name: widget.name,) ], ); } } ), ) ); } }
0
mirrored_repositories/tutorial_app/lib
mirrored_repositories/tutorial_app/lib/components/quiz_button.dart
import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:tutorial_app/controllers/tutorial_controller.dart'; import 'package:tutorial_app/pages/quiz_page.dart'; class QuizButton extends StatefulWidget { const QuizButton({super.key,required this.name,required this.color}); final String name; final Color color; @override State<QuizButton> createState() => _QuizButtonState(); } class _QuizButtonState extends State<QuizButton> { final TutorialController tutorialController=Get.find(); @override Widget build(BuildContext context) { double width=MediaQuery.of(context).size.width; double height=MediaQuery.of(context).size.height; return GestureDetector( onTap: () { tutorialController.fetchData(widget.name); Get.to(QuizPage(name:widget.name)); }, child: Padding( padding: const EdgeInsets.all(8.0), child: Container( width: 125, height: 40, decoration: BoxDecoration( boxShadow: [BoxShadow( blurRadius: 1, spreadRadius: 2, color: Color.fromARGB(255, 56, 56, 56), offset: Offset(1, 3) )], borderRadius: BorderRadius.circular(20), color:widget.color), child: Center( child: Text(widget.name,style: TextStyle( color: Colors.black, fontSize: 16, fontWeight: FontWeight.bold ),), ), ), ), ); } }
0
mirrored_repositories/tutorial_app/lib
mirrored_repositories/tutorial_app/lib/components/lesson_button.dart
import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:tutorial_app/pages/lesson_page.dart'; class LessonButton extends StatelessWidget { const LessonButton({super.key,required this.subject}); final String subject; @override Widget build(BuildContext context) { return GestureDetector( onTap: () { Get.to(LessonPage(subject: subject)); }, child: Container( height: 40, width: 110, decoration: BoxDecoration( boxShadow: [BoxShadow( blurRadius: 1, spreadRadius: 2, offset: Offset(2, 3) )], borderRadius: BorderRadius.circular(10), gradient: LinearGradient(colors: [Color.fromARGB(124, 17, 148, 224),Color.fromARGB(160, 208, 209, 212)]) ), child: Center( child: Text(subject,style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold,color:Color.fromARGB(255, 32, 32, 31)),), ), ), ); } }
0
mirrored_repositories/tutorial_app/lib
mirrored_repositories/tutorial_app/lib/components/square_tile.dart
import 'package:flutter/material.dart'; class SquareTile extends StatelessWidget { const SquareTile({super.key,required this.imagePath,required this.onTap}); final String imagePath; final Function()? onTap; @override Widget build(BuildContext context) { return GestureDetector( onTap:onTap , child: Container( padding: EdgeInsets.all(20), decoration: BoxDecoration( border: Border.all(color: Colors.white), borderRadius: BorderRadius.circular(16), color: Colors.grey[200] ), child: Image.asset(imagePath,height: 40,), ), ); } }
0
mirrored_repositories/tutorial_app/lib
mirrored_repositories/tutorial_app/lib/components/my_button.dart
import 'package:flutter/material.dart'; class MyButton extends StatefulWidget { const MyButton({super.key,required this.onTap,required this.text}); final Function()? onTap; final String text; @override State<MyButton> createState() => _MyButtonState(); } class _MyButtonState extends State<MyButton> { @override Widget build(BuildContext context) { return GestureDetector( onTap: widget.onTap, child: Container( padding:const EdgeInsets.all(25), width: MediaQuery.of(context).size.width*0.8, decoration: BoxDecoration( color: Colors.black, borderRadius: BorderRadius.circular(8)), child: Center(child: Text(widget.text,style: TextStyle(color: Colors.white,fontSize: 16,fontWeight: FontWeight.bold),)), ), ); } }
0
mirrored_repositories/tutorial_app/lib
mirrored_repositories/tutorial_app/lib/components/my_textfield.dart
import 'package:flutter/material.dart'; class MyTextField extends StatelessWidget { const MyTextField({super.key,required this.controller,required this.hintText,required this.obscureText}); final controller; final String hintText; final bool obscureText; @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.symmetric(horizontal: 25), child: TextField( controller: controller, obscureText: obscureText, decoration: InputDecoration( hintText: hintText, hintStyle: TextStyle(color: Colors.grey), fillColor: Color.fromARGB(255, 235, 235, 235), filled: true, focusedBorder: OutlineInputBorder( borderSide: BorderSide( color: Color.fromARGB(255, 51, 50, 50) ) ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( color: Colors.white ) ) ), ), ); } }
0
mirrored_repositories/tutorial_app/lib
mirrored_repositories/tutorial_app/lib/components/quiz_box.dart
import 'dart:ffi'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:giffy_dialog/giffy_dialog.dart'; import 'package:tutorial_app/controllers/user_controller.dart'; import '../controllers/tutorial_controller.dart'; class QuizBox extends StatefulWidget { const QuizBox({super.key,required this.name}); final String name; @override State<QuizBox> createState() => _QuizBoxState(); } class _QuizBoxState extends State<QuizBox> { final TutorialController tutorialController=Get.find(); final ProfileController profileController=Get.find(); int currentIndex=0; TextEditingController userAnswerController=TextEditingController(); String selectedAns=''; String correctAns=''; List<bool> isSelected=[]; @override void initState() { // TODO: implement initState super.initState(); //profileController.loadUserProfile(profileController.userProfile.value!.uid); getLastAnswerIndex(); generateList(); } getLastAnswerIndex(){ profileController.userProfile.value!.lcqNumber.forEach((map){ final name=widget.name.toLowerCase(); if(map.containsKey(name)){ setState(() { currentIndex=map[name]!; print('CURRENT INDEX at start'+currentIndex.toString()); }); } }); } //[{'name':'samith','marks': [{maths: 0}, {science: 25}, {english: 0}, {history: 0}, {ict: 0}, {geography: 0}]}] void generateList(){ print('length'+tutorialController.Data.length.toString()); if(currentIndex<=tutorialController.Data.length-1){ List<bool> isselected = List.generate( tutorialController.Data[currentIndex]['answers'].length, (index) => false, ); setState(() { isSelected=isselected; }); } } void checkAnswer(){ print(correctAns.length.toString() +' '+ selectedAns.length.toString()); print(selectedAns.trim()==correctAns.trim()); if (selectedAns.trim()==correctAns.trim()){ profileController.updateSubject(widget.name.toLowerCase()); setState(() { isSelected=[]; }); getLastAnswerIndex(); // print('tutorials lenght'+tutorialController.Data.length.toString()); // print('CURRENT INDEX'+currentIndex.toString()); if(currentIndex<=tutorialController.Data.length-1){ print('CURRENT INDEX'+currentIndex.toString()); generateList(); }else{ Get.snackbar('End', 'No more quizes'); } setState(() { }); showDialog(context:context,builder:(context) { return GiffyDialog.image( Image.network('https://media.tenor.com/qg8K8VOmzJwAAAAi/party-popper-confetti.gif',height: 200,fit: BoxFit.cover, errorBuilder: (context, error, stackTrace) { return Container( width: 150, height: 150, decoration: BoxDecoration( borderRadius: BorderRadius.circular(100), image: DecorationImage(image: AssetImage('assets/correct.jpeg'),fit: BoxFit.cover) ), ); }, ), title: Text('Answer Correct'), content: Container( //width: 150, //height: 150, decoration: BoxDecoration( borderRadius: BorderRadius.circular(100), //image: DecorationImage(image: AssetImage('assets/correct.jpeg'),fit: BoxFit.cover) ), child: Text('Congratulations! Your are Correct.'), ) , actions: [ TextButton(onPressed: (){ Navigator.of(context).pop(); }, child:Text('Next') ) ], ); },); }else{ showDialog(context: context, builder:(context){ return GiffyDialog.image( Image.network('https://media.tenor.com/oxG6Jka0LPUAAAAi/machiko-rabbit.gif',height: 200,fit: BoxFit.cover, errorBuilder: (context, error, stackTrace) { return Container(); },), title: Text('Incorrect Answer'), content: Text('Oooops!'), actions: [ TextButton(onPressed:() { Navigator.of(context).pop(); }, child:Text('Try again')) ], ); }); } } @override Widget build(BuildContext context) { double width=MediaQuery.of(context).size.width; double height=MediaQuery.of(context).size.height; return isSelected.isNotEmpty? Center( child: Container( width: width-20, height: height*0.6, decoration: BoxDecoration( image: DecorationImage(image: AssetImage('assets/qzans.jpeg'),fit: BoxFit.cover), boxShadow: [BoxShadow( blurRadius: 7, )], borderRadius: BorderRadius.circular(10), //linear LinearGradient(colors: [Color.fromARGB(255, 45, 49, 51),Color.fromARGB(255, 93, 96, 99)]) ), child: Padding( padding: const EdgeInsets.all(8.0), child: SingleChildScrollView( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text('Q'+tutorialController.Data[currentIndex]['questionNumber'].toString()+'/ ',style: TextStyle(fontSize: 30,fontWeight: FontWeight.bold),), Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Color.fromARGB(221, 31, 30, 30) ), child: Padding( padding: const EdgeInsets.all(8.0), child: Text(tutorialController.Data[currentIndex]['question'],style: TextStyle(color: const Color.fromARGB(255, 252, 251, 249),fontSize: 25),), )), SizedBox( width: width, height:300, child: ListView.builder( itemCount: tutorialController.Data[currentIndex]['answers'].length, itemBuilder:(context,index){ final item=tutorialController.Data[currentIndex]['answers'][index]; if (item is String){ return GestureDetector( onTap: () { setState(() { if (isSelected[index]) { // If the item was already selected, deselect it isSelected[index] = false; } else { // If the item was not selected, select it and deselect others for (int i = 0; i < isSelected.length; i++) { isSelected[i] = false; } isSelected[index] = true; } correctAns=tutorialController.Data[currentIndex]['answer']; selectedAns=item; }); }, child: Container(decoration: BoxDecoration( boxShadow: [BoxShadow( blurRadius: 7 )], color:isSelected[index]? Colors.grey[200]:Color.fromARGB(255, 100, 98, 94), borderRadius: BorderRadius.circular(10), border:Border.all(color: Color.fromARGB(255, 6, 122, 143),width: 2) ), margin: EdgeInsets.symmetric(vertical: 5), padding: EdgeInsets.all(10), child: Text(index.toString()+'). '+item), ), ); } return Container(); }), ), SizedBox(height: 10,), GestureDetector( onTap: () { checkAnswer(); }, child: Container( width: 100, decoration: BoxDecoration( color: Colors.white, borderRadius:BorderRadius.circular(10), boxShadow: [BoxShadow(blurRadius: 7)] ), child: Padding( padding: const EdgeInsets.all(8.0), child: Center( child: Text('Submit',style: TextStyle( color: Colors.black,fontSize: 16,fontWeight: FontWeight.bold ),), ), ), ), ) //text field to get the answer //submit button //if answer correct go to next question //else show retry button to answer again //view answer button to view the answer go to next question ], ), ), ), ), ):Center( child: Padding( padding: const EdgeInsets.all(8.0), child: Container( height: 350, decoration: BoxDecoration( image: DecorationImage(image: NetworkImage('https://media.tenor.com/eaTvhJLzFBsAAAAi/%E3%82%8F%E3%83%BC%E3%81%84-%E5%AC%89%E3%81%97%E3%81%84%E3%81%AA.gif', ),fit: BoxFit.cover) ), child: Text( textAlign:TextAlign.center, 'You have completed all the quizes in this subject!',style: TextStyle( fontSize: 25,fontWeight: FontWeight.bold),), ), ), ); } }
0
mirrored_repositories/tutorial_app/lib
mirrored_repositories/tutorial_app/lib/services/auth_service.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:get/get.dart'; import 'package:google_sign_in/google_sign_in.dart'; import 'package:tutorial_app/controllers/user_controller.dart'; class AuthService{ final ProfileController profileController=Get.find(); signInWithGoogle()async{ final GoogleSignInAccount? gUser=await GoogleSignIn().signIn(); final GoogleSignInAuthentication gAuth=await gUser!.authentication; final credential=GoogleAuthProvider.credential( accessToken: gAuth.accessToken, idToken: gAuth.idToken ); try{ final result=await FirebaseAuth.instance.signInWithCredential(credential); if(result.user!=null){ final user=result.user; print('USER PROFILE google '+user.toString()); await profileController.createUserProfile(user!.uid, user.displayName.toString()); await profileController.loadUserProfile(user.uid); // ProfileController().isLoading.value=false; } }catch(error){ Get.snackbar('Something Went Wrong', error.toString()); profileController.isLoading.value = false; } } }
0
mirrored_repositories/tutorial_app
mirrored_repositories/tutorial_app/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility in the flutter_test package. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:tutorial_app/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/weather_apps
mirrored_repositories/weather_apps/lib/app.dart
import 'package:flutter/material.dart'; import 'package:weather_apps/pages/home_page.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'cubits/cubits.dart'; import 'repositories/repositories.dart'; import 'services/services.dart'; class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return RepositoryProvider( create: (_) => WeatherRepository( weatherApiServices: WeatherApiServices(), ), child: MultiBlocProvider( providers: [ BlocProvider<WeatherCubit>( create: (context) => WeatherCubit( weatherRepository: context.read<WeatherRepository>(), ), ), BlocProvider<TempSettingsCubit>( create: (context) => TempSettingsCubit(), ), BlocProvider<BackgroundImageCubit>( create: (context) => BackgroundImageCubit(), ), BlocProvider<TextThemeCubit>( create: (context) => TextThemeCubit(), ), ], child: MaterialApp( title: 'Weather Apps', debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.blue, ), home: const HomePage(), ), ), ); } }
0
mirrored_repositories/weather_apps
mirrored_repositories/weather_apps/lib/main.dart
import 'package:flutter/material.dart'; import 'app.dart'; void main() { runApp(const MyApp()); }
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/constants/temperature.dart
double kCoolOrHot = 297.15; //kelvin temp
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/constants/text_styles.dart
import 'package:flutter/material.dart'; class HomeTextStyles { HomeTextStyles._(); static const TextStyle primary = TextStyle( fontSize: 20.0, color: Colors.white, ); static const TextStyle destination = TextStyle( fontSize: 40.0, fontWeight: FontWeight.bold, color: Colors.white, ); static const TextStyle temp = TextStyle( fontSize: 30.0, fontWeight: FontWeight.bold, color: Colors.white, ); static const TextStyle tempMaxMin = TextStyle( fontSize: 16.0, fontWeight: FontWeight.w500, color: Colors.white, ); static const TextStyle description = TextStyle( fontSize: 25.0, color: Colors.white, ); }
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/constants/constants.dart
export 'secrets.dart'; export 'temperature.dart'; export 'text_styles.dart';
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/widgets/create_route.dart
import 'package:flutter/material.dart'; ///Constructing page route builder in order to navigate to other [Route] with ///custom [SlideTransition] animation instead of default animation. Route<String> createRoute(Widget widget) { return PageRouteBuilder( pageBuilder: (_, animation, secondaryAnimation) => widget, transitionsBuilder: (_, animation, secondaryAnimation, child) { const begin = Offset(1.0, 0.0); const end = Offset.zero; var curve = Curves.bounceInOut; final tween = Tween(begin: begin, end: end).chain(CurveTween(curve: curve)); return SlideTransition( position: animation.drive(tween), child: child, ); }, ); }
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/widgets/widgets.dart
export 'create_route.dart'; export 'error_dialog.dart';
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/widgets/error_dialog.dart
import 'package:flutter/material.dart'; void errorDialog(BuildContext context, String errorMsg) { showDialog( context: context, builder: (context) { return AlertDialog( title: const Text('Error'), content: Text(errorMsg), actions: [ TextButton( onPressed: () { Navigator.of(context).pop(); }, child: const Text('OK'), ), ], ); }, ); }
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/cubits/cubits.dart
export 'package:weather_apps/cubits/weather/weather_cubit.dart'; export 'package:weather_apps/cubits/temp_settings/temp_settings_cubit.dart'; export 'package:weather_apps/cubits/background_images/background_images_cubit.dart'; export 'package:weather_apps/cubits/text_theme/text_theme_cubit.dart';
0
mirrored_repositories/weather_apps/lib/cubits
mirrored_repositories/weather_apps/lib/cubits/background_images/background_images_cubit.dart
import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; import '../../constants/temperature.dart'; part 'background_images_state.dart'; class BackgroundImageCubit extends Cubit<BackgroundImageState> { BackgroundImageCubit() : super(BackgroundImageState.initial()); void analyzeWeather(double currentTemp) { if (currentTemp > kCoolOrHot) { emit(state.copyWith(isHot: true)); } else { emit(state.copyWith(isHot: false)); } } }
0
mirrored_repositories/weather_apps/lib/cubits
mirrored_repositories/weather_apps/lib/cubits/background_images/background_images_state.dart
part of 'background_images_cubit.dart'; class BackgroundImageState extends Equatable { final bool isHot; const BackgroundImageState({ required this.isHot, }); @override List<Object> get props => [isHot]; BackgroundImageState copyWith({ bool? isHot, }) { return BackgroundImageState( isHot: isHot ?? this.isHot, ); } factory BackgroundImageState.initial() { return const BackgroundImageState( isHot: false, ); } @override String toString() => 'BackgroundImageState(isHot: $isHot)'; }
0
mirrored_repositories/weather_apps/lib/cubits
mirrored_repositories/weather_apps/lib/cubits/weather/weather_cubit.dart
import 'dart:async'; import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:weather_apps/repositories/weather_repository.dart'; import '../../models/custom_error.dart'; import '../../models/weather.dart'; part 'weather_state.dart'; class WeatherCubit extends Cubit<WeatherState> { final WeatherRepository weatherRepository; WeatherCubit({required this.weatherRepository}) : super(WeatherState.initial()); Future<void> fetchWeather(String cityName) async { emit(state.copyWith(status: WeatherStatus.loading)); try { await weatherRepository.fetchWeather(cityName).then((weather) { emit(state.copyWith( status: WeatherStatus.loaded, weather: weather, )); }); } on CustomError catch (e) { emit(state.copyWith( status: WeatherStatus.error, error: e, )); } } }
0
mirrored_repositories/weather_apps/lib/cubits
mirrored_repositories/weather_apps/lib/cubits/weather/weather_state.dart
part of 'weather_cubit.dart'; enum WeatherStatus { initial, loading, loaded, error, } class WeatherState extends Equatable { final WeatherStatus status; final Weather weather; final CustomError error; const WeatherState({ required this.status, required this.weather, required this.error, }); WeatherState copyWith({ WeatherStatus? status, Weather? weather, CustomError? error, }) { return WeatherState( status: status ?? this.status, weather: weather ?? this.weather, error: error ?? this.error, ); } factory WeatherState.initial() { return WeatherState( status: WeatherStatus.initial, weather: Weather.initial(), error: const CustomError()); } @override List<Object> get props => [status, weather, error]; @override bool? get stringify => true; @override String toString() => 'WeatherState(status: $status, weather: $weather, error: $error)'; }
0
mirrored_repositories/weather_apps/lib/cubits
mirrored_repositories/weather_apps/lib/cubits/text_theme/text_theme_state.dart
// ignore_for_file: constant_identifier_names part of 'text_theme_cubit.dart'; enum TextThemes { Light, Dark, } class TextThemeState extends Equatable { final TextThemes textTheme; const TextThemeState({ required this.textTheme, }); @override List<Object> get props => [textTheme]; factory TextThemeState.initial() => const TextThemeState(textTheme: TextThemes.Light); TextThemeState copyWith({ TextThemes? textTheme, }) { return TextThemeState( textTheme: textTheme ?? this.textTheme, ); } @override String toString() => 'TextThemeState(textTheme: $textTheme)'; }
0
mirrored_repositories/weather_apps/lib/cubits
mirrored_repositories/weather_apps/lib/cubits/text_theme/text_theme_cubit.dart
import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; part 'text_theme_state.dart'; class TextThemeCubit extends Cubit<TextThemeState> { TextThemeCubit() : super(TextThemeState.initial()); void changeTextTheme() { if (state.textTheme == TextThemes.Dark) { emit(state.copyWith(textTheme: TextThemes.Light)); } else { emit(state.copyWith(textTheme: TextThemes.Dark)); } } }
0
mirrored_repositories/weather_apps/lib/cubits
mirrored_repositories/weather_apps/lib/cubits/temp_settings/temp_settings_state.dart
// ignore_for_file: constant_identifier_names part of 'temp_settings_cubit.dart'; enum TempUnit { Celsius, Fahrenheit, } class TempSettingsState extends Equatable { final TempUnit tempUnit; const TempSettingsState({ this.tempUnit = TempUnit.Celsius, }); factory TempSettingsState.initial() { return const TempSettingsState(); } @override List<Object> get props => [tempUnit]; @override bool get stringify => true; TempSettingsState copyWith({ TempUnit? tempUnit, }) { return TempSettingsState( tempUnit: tempUnit ?? this.tempUnit, ); } @override String toString() => 'TempSettingsState(tempUnit: $tempUnit)'; }
0
mirrored_repositories/weather_apps/lib/cubits
mirrored_repositories/weather_apps/lib/cubits/temp_settings/temp_settings_cubit.dart
import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; part 'temp_settings_state.dart'; class TempSettingsCubit extends Cubit<TempSettingsState> { TempSettingsCubit() : super(TempSettingsState.initial()); void toggleTempUnit() { if (state.tempUnit == TempUnit.Celsius) { emit(state.copyWith(tempUnit: TempUnit.Fahrenheit)); } else { emit(state.copyWith(tempUnit: TempUnit.Celsius)); } } }
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/pages/home_page.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:weather_apps/pages/settings_page.dart'; import '../constants/text_styles.dart'; import '../cubits/cubits.dart'; import '../widgets/widgets.dart'; import 'search_page.dart'; enum _HomePageSession { destination, temp, description } class HomePage extends StatelessWidget { const HomePage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { String? cityName; return Scaffold( extendBodyBehindAppBar: true, backgroundColor: Colors.white70.withOpacity(0.85), appBar: AppBar( backgroundColor: Colors.transparent, elevation: 0, centerTitle: true, title: const Text('Weather'), actions: [ IconButton( icon: const Icon(Icons.settings), onPressed: () { Navigator.of(context).push(createRoute(const SettingsPage())); }, ), ], ), body: BlocConsumer<WeatherCubit, WeatherState>( listener: (context, state) { if (state.status == WeatherStatus.error) { errorDialog(context, state.error.errMsg); } context .read<BackgroundImageCubit>() .analyzeWeather(state.weather.temp ?? 0); }, builder: (context, state) { var isHot = context.watch<BackgroundImageCubit>().state.isHot; return Container( constraints: const BoxConstraints.expand(), decoration: BoxDecoration( image: DecorationImage( image: isHot == true ? const AssetImage("assets/images/hot.jpg") : const AssetImage("assets/images/cool.jpg"), fit: BoxFit.cover, ), ), child: _showWeather(context, state), ); }, ), floatingActionButton: FloatingActionButton( backgroundColor: Colors.white.withOpacity(0.8), onPressed: () async { cityName = await Navigator.of(context).push(createRoute(const SearchPage())); if (context.mounted) { if (cityName != null) { context.read<WeatherCubit>().fetchWeather(cityName ?? ''); } } }, child: const Icon(Icons.search, color: Colors.black), ), ); } Widget _showWeather(BuildContext context, WeatherState state) { switch (state.status) { case WeatherStatus.initial: return Center( child: Text( 'Tap the 🔍 icon to find a city.', style: HomeTextStyles.primary.change(context), ), ); case WeatherStatus.loading: return const Center( child: CircularProgressIndicator(color: Colors.white)); default: } return ListView.separated( padding: EdgeInsets.symmetric( vertical: MediaQuery.of(context).size.height * 0.3), itemBuilder: _itemBuilder, separatorBuilder: _separatorBuilder, itemCount: _HomePageSession.values.length, ); } Widget? _itemBuilder(BuildContext context, int index) { return BlocBuilder<WeatherCubit, WeatherState>( builder: (context, state) { switch (_HomePageSession.values[index]) { case _HomePageSession.destination: return Text(state.weather.destination ?? 'N/A', textAlign: TextAlign.center, style: HomeTextStyles.destination.change(context)); case _HomePageSession.temp: return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( _showTemperature(context, state.weather.temp), style: HomeTextStyles.temp.change(context), ), const SizedBox(width: 15.0), Column( children: [ Text( '${_showTemperature(context, state.weather.tempMax)} (max)', style: HomeTextStyles.tempMaxMin.change(context), ), const SizedBox(height: 10.0), Text( '${_showTemperature(context, state.weather.tempMin)} (min)', style: HomeTextStyles.tempMaxMin.change(context), ), ], ), ], ); case _HomePageSession.description: return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ const Spacer(), _showIcon(state.weather.weatherStateIcon), Text( state.weather.weatherStateDescription ?? 'N/A', style: HomeTextStyles.description.change(context), ), const Spacer(), ], ); } }, ); } Widget _separatorBuilder(BuildContext context, int index) { switch (_HomePageSession.values[index]) { case _HomePageSession.destination: return const SizedBox(height: 60.0); case _HomePageSession.temp: return const SizedBox(height: 40.0); case _HomePageSession.description: return const SizedBox.shrink(); } } } Widget _showIcon(String? icon) { return FadeInImage.assetNetwork( placeholder: 'assets/images/loading.gif', image: 'http://openweathermap.org/img/wn/[email protected]', imageErrorBuilder: (context, error, stackTrace) { return const Icon(Icons.error_outline); }, height: 100, width: 100, ); } ///Helper method to show temperature in Celsius or Fahrenheit. String _showTemperature(BuildContext context, double? temperature) { final tempUnit = context.watch<TempSettingsCubit>().state.tempUnit; if (temperature != null) { if (tempUnit == TempUnit.Fahrenheit) { return '${((temperature - 273.15) * 1.8 + 32).toStringAsFixed(2)}℉'; } else { return '${(temperature - 273.15).toStringAsFixed(2)}℃'; } } else { return 'N/A'; } } ///Helper method to show text color based on the [TextThemeState] state. Color _textColor(BuildContext context) { final textTheme = context.watch<TextThemeCubit>().state.textTheme; if (textTheme == TextThemes.Light) { return Colors.white; } return Colors.black.withOpacity(0.8); } extension CopyTextStyles on TextStyle { ///Extension method for copying [TextStyle] with a new color according to the associated [BuildContext] ///and the [TextThemeState] state. TextStyle change(BuildContext ctx) => copyWith(color: _textColor(ctx)); }
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/pages/search_page.dart
import 'package:flutter/material.dart'; class SearchPage extends StatefulWidget { const SearchPage({Key? key}) : super(key: key); @override State<SearchPage> createState() => _SearchPageState(); } class _SearchPageState extends State<SearchPage> { final _formKey = GlobalKey<FormState>(); String? _cityName; bool isValidating = false; AutovalidateMode autovalidateMode = AutovalidateMode.disabled; void _submit() async { setState(() { isValidating = true; }); await Future.delayed(const Duration(milliseconds: 1000)); if (_formKey.currentState?.validate() ?? false) { _formKey.currentState?.save(); if (context.mounted) { Navigator.of(context).pop(_cityName?.trim()); } } else { setState(() { isValidating = false; autovalidateMode = AutovalidateMode.onUserInteraction; }); } } @override Widget build(BuildContext context) { return Scaffold( resizeToAvoidBottomInset: false, appBar: AppBar( centerTitle: true, title: const Text('Search'), ), body: Stack( children: [ Align( alignment: const Alignment(0, -0.65), child: Image.asset( 'assets/images/weather.png', height: 160, width: 160, ), ), Form( key: _formKey, autovalidateMode: autovalidateMode, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 60), child: TextFormField( textCapitalization: TextCapitalization.words, style: const TextStyle(fontSize: 18), decoration: InputDecoration( labelText: 'City Name', hintText: 'Enter City Name', prefixIcon: const Icon(Icons.search), border: OutlineInputBorder( borderRadius: BorderRadius.circular(12)), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(12)), ), validator: (String? input) { if (input != null) { if (input.isEmpty || input.trim().length < 2) { return 'Please enter a valid city name'; } } return null; }, onSaved: (String? input) { _cityName = input; }, ), ), const SizedBox(height: 25), SizedBox( height: 50, width: 220, child: ElevatedButton.icon( onPressed: _submit, icon: isValidating ? const SizedBox.shrink() : const Icon(Icons.search), label: isValidating ? const SizedBox( height: 28, width: 28, child: Center( child: CircularProgressIndicator( color: Colors.white, ), ), ) : const Text( 'How\'s the weather?', style: TextStyle(fontSize: 18), ), ), ) ], ), ), ], ), ); } }
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/pages/settings_page.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:weather_apps/utils/utils.dart'; import '../cubits/cubits.dart'; enum _SettingPageSession { tempUnit, textTheme } class SettingsPage extends StatelessWidget { const SettingsPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(centerTitle: true, title: const Text('Settings')), body: ListView.builder( padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), itemBuilder: _itemBuilder, itemCount: _SettingPageSession.values.length, ), ); } Widget _itemBuilder(BuildContext context, int index) { switch (_SettingPageSession.values[index]) { case _SettingPageSession.tempUnit: return BlocBuilder<TempSettingsCubit, TempSettingsState>( builder: (context, state) { return ListTile( title: Text('Temparature Unit: ${state.tempUnit.enumToString()}'), subtitle: const Text('Celsius/Fahrenheit (Default: Celsius)'), trailing: Switch( value: state.tempUnit == TempUnit.Celsius, onChanged: (_) { context.read<TempSettingsCubit>().toggleTempUnit(); }, ), ); }, ); case _SettingPageSession.textTheme: return BlocBuilder<TextThemeCubit, TextThemeState>( builder: (context, state) { return ListTile( title: Text('Text Theme: ${state.textTheme.enumToString()}'), subtitle: const Text('Light/Dark (Default: Light)'), trailing: Switch( value: state.textTheme == TextThemes.Light, onChanged: (_) { context.read<TextThemeCubit>().changeTextTheme(); }, ), ); }, ); } } }
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/models/custom_error.dart
import 'package:equatable/equatable.dart'; class CustomError extends Equatable { final String errMsg; const CustomError({ this.errMsg = '', }); @override List<Object?> get props => [ errMsg, ]; @override bool get stringify => true; }
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/models/weather.dart
import 'package:equatable/equatable.dart'; class Weather extends Equatable { final String? destination; final double? temp; final double? tempMin; final double? tempMax; final String? weatherStateDescription; final String? weatherStateIcon; const Weather({ required this.destination, required this.temp, required this.tempMin, required this.tempMax, required this.weatherStateDescription, required this.weatherStateIcon, }); @override List<Object?> get props => [ destination, temp, tempMin, tempMax, weatherStateDescription, weatherStateIcon, ]; factory Weather.fromJson(Map<String, dynamic> json) { final main = json['main']; final weather = json['weather'][0]; return Weather( destination: json['name'] ?? '', temp: main['temp'] ?? 0.0, tempMin: main['temp_min'] ?? 0.0, tempMax: main['temp_max'] ?? 0.0, weatherStateDescription: weather['description'] ?? '', weatherStateIcon: weather['icon'] ?? '', ); } factory Weather.initial() => const Weather( destination: '', temp: 0.0, tempMin: 0.0, tempMax: 0.0, weatherStateDescription: '', weatherStateIcon: '', ); @override bool get stringify => true; Map<String, dynamic> toMap() { return { 'destination': destination, 'temp': temp, 'tempMin': tempMin, 'tempMax': tempMax, 'weatherStateDescription': weatherStateDescription, 'weatherStateIcon': weatherStateIcon, }; } factory Weather.fromMap(Map<String, dynamic> map) { return Weather( destination: map['destination'] ?? '', temp: map['temp']?.toDouble() ?? 0.0, tempMin: map['tempMin']?.toDouble() ?? 0.0, tempMax: map['tempMax']?.toDouble() ?? 0.0, weatherStateDescription: map['weatherStateDescription'] ?? '', weatherStateIcon: map['weatherStateIcon'] ?? '', ); } }
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/repositories/weather_repository.dart
import 'package:weather_apps/exceptions/weather_exception.dart'; import 'package:weather_apps/models/custom_error.dart'; import 'package:weather_apps/services/services.dart'; import '../models/weather.dart'; class WeatherRepository { final WeatherApiServices weatherApiServices; WeatherRepository({ required this.weatherApiServices, }); Future<Weather> fetchWeather(String cityName) async { try { final Weather weather = await weatherApiServices.getWeather(cityName); final weatherMap = Weather.fromMap(weather.toMap()); return weatherMap; } on WeatherException catch (e) { throw CustomError(errMsg: e.message); } catch (e) { throw CustomError(errMsg: e.toString()); } } }
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/repositories/repositories.dart
export 'weather_repository.dart';
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/exceptions/weather_exception.dart
class WeatherException implements Exception { String message; WeatherException([this.message = 'Something went wrong']) { message = 'Weather exception $message'; } @override String toString() { return message; } }
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/utils/enum_to_string.dart
extension EnumToString on Enum { ///Extension method to convert [Enum] to [String]. String enumToString() { return toString().split('.').last.split(')').first; } }
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/utils/utils.dart
export 'enum_to_string.dart';
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/services/http_error_handler.dart
import 'package:http/http.dart' as http; String httpErrorHandler(http.Response response) { final statusCode = response.statusCode; final reasonPhrase = response.reasonPhrase; final String errMsg = 'Requested failed\nStatus Code: $statusCode\nReason Phrase: $reasonPhrase'; return errMsg; }
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/services/services.dart
export 'http_error_handler.dart'; export 'weather_api_services.dart';
0
mirrored_repositories/weather_apps/lib
mirrored_repositories/weather_apps/lib/services/weather_api_services.dart
import 'dart:convert'; import 'package:http/http.dart' as http; import '../constants/secrets.dart'; import '../exceptions/weather_exception.dart'; import '../models/weather.dart'; import 'http_error_handler.dart'; class WeatherApiServices { Future<Weather> getWeather(String city) async { final Uri uri = Uri( scheme: 'https', host: kHostApi, path: '/data/2.5/weather', queryParameters: { 'q': city, 'appid': kApiKey, }, ); try { final response = await http.get(uri); if (response.statusCode != 200) { throw Exception(httpErrorHandler(response)); } else { late final responseBody = json.decode(response.body); if (responseBody.isEmpty) { throw WeatherException('Cannot get the weather of the city'); } return Weather.fromJson(responseBody); } } catch (e) { rethrow; } } }
0
mirrored_repositories/weather_apps
mirrored_repositories/weather_apps/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility in the flutter_test package. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:weather_apps/app.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/Simple-interest-App
mirrored_repositories/Simple-interest-App/lib/main.dart
import 'package:flutter/material.dart'; void main(){ runApp( MaterialApp( debugShowCheckedModeBanner: false, title: "Simple Interest Calculator App", home: SIForm(), theme: ThemeData( brightness: Brightness.dark, primaryColor: Colors.indigoAccent, accentColor: Colors.indigo, ), ) ); } class SIForm extends StatefulWidget{ @override State<StatefulWidget> createState() { return _SIFormState(); } } class _SIFormState extends State<SIForm>{ var _currencies=['Rupees','Dollars','Ponds']; final _minimumPadding=5.0; var _currentItemSlected="Rupees"; TextEditingController principalController=TextEditingController(); TextEditingController roiController=TextEditingController(); TextEditingController termController=TextEditingController(); var displayResult=""; @override Widget build(BuildContext context) { TextStyle textStyle=Theme.of(context).textTheme.title; return Scaffold( //resizeToAvoidBottomPadding: false, appBar: AppBar( title: Text("Simple interest Calculator"), ), body:Container( child: ListView( children: <Widget>[ getImageAsset(), Padding( padding: EdgeInsets.only(top: _minimumPadding,bottom: _minimumPadding), child:TextField( keyboardType: TextInputType.number, style: textStyle, controller: principalController, decoration: InputDecoration( labelText: "Principal", hintText: "Enter principal eg:1234", labelStyle: textStyle, border: OutlineInputBorder( borderRadius: BorderRadius.circular(5.0) ), ), )), Padding( padding: EdgeInsets.only(top: _minimumPadding,bottom: _minimumPadding), child:TextField( keyboardType: TextInputType.number, style: textStyle, controller: roiController, decoration: InputDecoration( labelText: "Rate of Interest", hintText: "IN percentage", labelStyle: textStyle, border: OutlineInputBorder( borderRadius: BorderRadius.circular(5.0) ), ), )), Padding( padding: EdgeInsets.only(top: _minimumPadding,bottom: _minimumPadding), child:Row( children: <Widget>[ Expanded( child:TextField( keyboardType: TextInputType.number, style: textStyle, controller: termController, decoration: InputDecoration( labelText: "Terms", hintText: "Time in Year", border: OutlineInputBorder( borderRadius: BorderRadius.circular(5.0) ), ), )), Container(width: _minimumPadding*5,), Expanded( child:DropdownButton<String>( items:_currencies.map((String value){ return DropdownMenuItem<String>( value: value, child: Text(value,style: textStyle,), ); } ).toList(), value: _currentItemSlected, onChanged: (String newValueSelected){ _onDropDownItemSelected(newValueSelected); }, )) ], )), Padding( padding: EdgeInsets.only(top: _minimumPadding,bottom: _minimumPadding), child:Row( children: <Widget>[ Expanded( child: RaisedButton( color: Theme.of(context).accentColor, textColor: Theme.of(context).primaryColorDark, child: Text("Calculate",style: textStyle,), onPressed: (){ setState(() { this.displayResult=calculateTotalReturns(); }); }, )), Expanded( child: RaisedButton( color: Theme.of(context).primaryColorDark, textColor: Theme.of(context).accentColor, child: Text("Reset"), onPressed: (){ setState(() { _reset(); }); }, )), ], )), Padding( padding: EdgeInsets.all(_minimumPadding), child:Text(this.displayResult,style: textStyle,), ) ], ), ), ); } Widget getImageAsset(){ AssetImage assetImage=AssetImage("images/money.png"); Image image=Image(image: assetImage,width: 125.0,height: 125.0,); return Container(child: image, margin: EdgeInsets.all(_minimumPadding*10),); } void _onDropDownItemSelected(String newValueSelected){ setState(() { this._currentItemSlected=newValueSelected; }); } String calculateTotalReturns(){ double principal=double.parse(principalController.text); double roi=double.parse(roiController.text); double term=double.parse(termController.text); double totalAmountPayable=principal+(principal*roi*term)/100; String result="After $term years,your investment will be worth $totalAmountPayable $_currentItemSlected"; return result; } void _reset(){ principalController.text=""; roiController.text=""; termController.text=""; displayResult=""; _currentItemSlected=_currencies[0]; } }
0
mirrored_repositories/Simple-interest-App
mirrored_repositories/Simple-interest-App/test/Testswegit.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_app1/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/Simple-interest-App
mirrored_repositories/Simple-interest-App/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_app1/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/TinderGoldRedesign
mirrored_repositories/TinderGoldRedesign/lib/main.dart
import 'package:flutter/material.dart'; import 'package:tinder_clone/views/chat_screen.dart'; void main(){ runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: ChatScreen(), debugShowCheckedModeBanner: false, ); } }
0
mirrored_repositories/TinderGoldRedesign/lib
mirrored_repositories/TinderGoldRedesign/lib/views/conversation_screen.dart
import 'package:flutter/material.dart'; import 'package:tinder_clone/model/conversation_model.dart'; class ConversationScreen extends StatefulWidget { final String name, profilePicPath; ConversationScreen({this.name, this.profilePicPath}); @override _ConversationScreenState createState() => _ConversationScreenState(); } class _ConversationScreenState extends State<ConversationScreen> { int tabSelected = 3; List<ConversationModel> conversations = new List<ConversationModel>(); var textController = new TextEditingController(); String myAwesomeMessage = ""; @override void initState() { // TODO: implement initState super.initState(); /// just adding three predifined messages ConversationModel conversationModel = new ConversationModel(); conversationModel.setMessage("Lorem ipsum dolor sit amet"); conversationModel.setSendByMe(false); conversations.add(conversationModel); ConversationModel conversationModel2 = new ConversationModel(); conversationModel2.setMessage("Lorem ipsum dolor sit amet consectetur " "adipiscing elit, sed do eiusmod tempor"); conversationModel2.setSendByMe(false); conversations.add(conversationModel2); ConversationModel conversationModel3 = new ConversationModel(); conversationModel3.setMessage("Lorem ipsum dolor sit amet"); conversationModel3.setSendByMe(true); conversations.add(conversationModel3); print(conversations.toString() + "data"); } @override Widget build(BuildContext context) { return Scaffold( body: Container( height: MediaQuery.of(context).size.height, child: Stack( children: <Widget>[ Container( decoration: BoxDecoration( gradient: LinearGradient( colors: [ const Color(0xff213A50), const Color(0xff071930) ], begin: FractionalOffset.topLeft, end: FractionalOffset.bottomRight)), ), LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) { return SingleChildScrollView( child: ConstrainedBox( constraints: BoxConstraints( minHeight: viewportConstraints.maxHeight, ), child: Column( children: <Widget>[ SizedBox( height: 90, ), /// Tab Options /// Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Column( children: <Widget>[ Container( padding: EdgeInsets.all(10), decoration: tabSelected == 1 ? BoxDecoration( borderRadius: BorderRadius.circular(60), gradient: LinearGradient( colors: [ const Color(0xffA2834D), const Color(0xffBC9A5F) ], begin: FractionalOffset.topRight, end: FractionalOffset.bottomLeft)) : BoxDecoration(), child: Image.asset( "assets/images/profile.png", width: 35, height: 35, )), SizedBox( height: 16, ), Text( "Chat", style: TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.w500), ), ], ), SizedBox( width: 60, ), Column( children: <Widget>[ Container( padding: EdgeInsets.all(10), decoration: tabSelected == 1 ? BoxDecoration( borderRadius: BorderRadius.circular(60), gradient: LinearGradient( colors: [ const Color(0xffA2834D), const Color(0xffBC9A5F) ], begin: FractionalOffset.topRight, end: FractionalOffset.bottomLeft)) : BoxDecoration(), child: Image.asset( "assets/images/tindergoldlogo.png", width: 35, height: 35, ), ), SizedBox( height: 16, ), Text( "Pairs", style: TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.w500), ), ], ), SizedBox( width: 60, ), Column( children: <Widget>[ Container( padding: EdgeInsets.all(15), decoration: BoxDecoration( borderRadius: BorderRadius.circular(60), gradient: LinearGradient( colors: [ const Color(0xffA2834D), const Color(0xffBC9A5F) ], begin: FractionalOffset.topRight, end: FractionalOffset.bottomLeft)), child: Image.asset( "assets/images/chatbubble.png", width: 30, height: 30, )), SizedBox( height: 16, ), Text( "Activities", style: TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.w500), ), ], ), ], ), SizedBox( height: 16, ), Container( child: Column( children: <Widget>[ /// Header /// Container( padding: EdgeInsets.symmetric( horizontal: 25, vertical: 8), child: Column( children: <Widget>[ Container( height: 0.2, color: Colors.white70, ), SizedBox( height: 16, ), Row( children: <Widget>[ Container( width: 60.0, height: 60.0, decoration: new BoxDecoration( color: const Color(0xff213A50), image: new DecorationImage( image: AssetImage(widget.profilePicPath), fit: BoxFit.cover, ), borderRadius: new BorderRadius.all( new Radius.circular(30.0)), ), ), SizedBox( width: 16, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( widget.name, style: TextStyle( color: Colors.white, fontSize: 20, fontWeight: FontWeight.w400), ), SizedBox( height: 4, ), Text( "Online", style: TextStyle( fontSize: 12, color: Colors.white70), ), // TODO add Spacer(), ], ), Spacer(), Container( padding: EdgeInsets.all(15), decoration: BoxDecoration( borderRadius: BorderRadius.circular(60), gradient: LinearGradient( colors: [ const Color(0xffA2834D), const Color(0xffBC9A5F) ], begin: FractionalOffset.topRight, end: FractionalOffset .bottomLeft)), child: Image.asset( "assets/images/call_icon.png", width: 20, height: 20, )), ], ), ], ), ), SizedBox( height: 8, ), /// ---- ListView.builder( itemCount: conversations.length, scrollDirection: Axis.vertical, shrinkWrap: true, itemBuilder: (context, index) { return ConversationTile( sendByMe: conversations[index].getSendByMe(), message: conversations[index].getMessage(), ); }) ], ), ) ], ), )); }), Container( height: MediaQuery.of(context).size.height, alignment: Alignment.bottomLeft, child: Container( color: Color(0x54FFFFFF), padding: EdgeInsets.symmetric(vertical: 23, horizontal: 16), child: Row( children: <Widget>[ Container( child: Image.asset( "assets/images/smiley.png", width: 25, height: 25, ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(25), gradient: LinearGradient( colors: [ const Color(0x36FFFFFF), const Color(0x0FFFFFFF) ], begin: FractionalOffset.topLeft, end: FractionalOffset.bottomRight)), padding: EdgeInsets.all(10), ), SizedBox( width: 16, ), Expanded( child: Container( margin: EdgeInsets.only(right: 16), child: TextField( controller: textController, style: TextStyle(color: Colors.white, fontSize: 15), decoration: InputDecoration( hintText: "Message ...", hintStyle: TextStyle(color: Colors.white, fontSize: 15), ), maxLines: 1, ), ), ), Container( child: Image.asset( "assets/images/microphone.png", width: 25, height: 25, ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(25), gradient: LinearGradient( colors: [ const Color(0x36FFFFFF), const Color(0x0FFFFFFF) ], begin: FractionalOffset.topLeft, end: FractionalOffset.bottomRight)), padding: EdgeInsets.all(10), ), SizedBox( width: 16, ), GestureDetector( onTap: () { setState(() { myAwesomeMessage = textController.text; print("pajji aee lo"+ myAwesomeMessage); ConversationModel conversatModel3 = new ConversationModel(); conversatModel3.setMessage(myAwesomeMessage); conversatModel3.setSendByMe(true); conversations.add(conversatModel3); FocusScope.of(context).unfocus(); textController.text = ""; }); }, child: Container( child: Image.asset( "assets/images/send.png", width: 23, height: 23, ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(25), gradient: LinearGradient( colors: [ const Color(0xffA2834D), const Color(0xffBC9A5F) ], begin: FractionalOffset.topRight, end: FractionalOffset.bottomLeft)), padding: EdgeInsets.all(10), ), ), ], ), ), ) ], ), ), ); } } class ConversationTile extends StatelessWidget { final bool sendByMe; final String message; ConversationTile({this.sendByMe, this.message}); @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.symmetric(vertical: 8), alignment: sendByMe ? Alignment.centerRight : Alignment.centerLeft, child: Container( margin: sendByMe ? EdgeInsets.only(left: 30) : EdgeInsets.only(right: 30), padding: EdgeInsets.only(top: 17, bottom: 17, left: 20, right: 20), decoration: BoxDecoration( gradient: LinearGradient( colors: sendByMe ? [const Color(0xffD9B372), const Color(0xffA2834D)] : [const Color(0x1AFFFFFF), const Color(0x1AFFFFFF)], begin: FractionalOffset.centerLeft, end: FractionalOffset.centerRight), borderRadius: sendByMe ? BorderRadius.only( topLeft: Radius.circular(23), bottomLeft: Radius.circular(23)) : BorderRadius.only( topRight: Radius.circular(23), bottomRight: Radius.circular(23))), child: Text( message, textAlign: TextAlign.start, style: TextStyle( color: Colors.white, fontSize: 14, fontWeight: FontWeight.w300), ), ), ); } }
0
mirrored_repositories/TinderGoldRedesign/lib
mirrored_repositories/TinderGoldRedesign/lib/views/chat_screen.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:tinder_clone/model/ChatModel.dart'; import 'package:tinder_clone/views/conversation_screen.dart'; class ChatScreen extends StatefulWidget { @override _ChatScreenState createState() => _ChatScreenState(); } class _ChatScreenState extends State<ChatScreen> { int tabSelected = 3; List<ChatModel> chats = new List<ChatModel>(); @override void initState() { // TODO: implement initState super.initState(); /// Filling up some data /// //1 ChatModel chatModel = new ChatModel(); chatModel.setUserName("Sanskar"); chatModel.setUserPicAssetPath("assets/images/profilepic.jpg"); chatModel.setLastMessage("This is strange i can send message to myself"); chatModel.setTime("2 hours"); chatModel.setUnreadMessage(4); chatModel.setLastMessageSendByMe(false); chats.add(chatModel); //2 ChatModel chatModel2 = new ChatModel(); chatModel2.setUserName("Jessica"); chatModel2.setUserPicAssetPath("assets/images/profilepic2.png"); chatModel2.setLastMessage("Hahaha, yeah!"); chatModel2.setTime("22 min"); chatModel2.setUnreadMessage(0); chatModel2.setLastMessageSendByMe(true); chats.add(chatModel2); //3 ChatModel chatModel3 = new ChatModel(); chatModel3.setUserName("Adrianne"); chatModel3.setUserPicAssetPath("assets/images/profilepic3.png"); chatModel3.setLastMessage("Let's catch up sometime sanskar"); chatModel3.setTime("2 min"); chatModel3.setUnreadMessage(0); chatModel3.setLastMessageSendByMe(false); chats.add(chatModel3); //4 ChatModel chatModel4 = new ChatModel(); chatModel4.setUserName("Marlene"); chatModel4.setUserPicAssetPath("assets/images/profilepic4.png"); chatModel4.setLastMessage("Hey Sanskar how are you?"); chatModel4.setTime("22 min"); chatModel4.setUnreadMessage(0); chatModel4.setLastMessageSendByMe(false); chats.add(chatModel4); //5 ChatModel chatModel5 = new ChatModel(); chatModel5.setUserName("Samanta"); chatModel5.setUserPicAssetPath("assets/images/profilepic5.png"); chatModel5.setLastMessage("That's awesome sanskar"); chatModel5.setTime("15 minutes"); chatModel5.setUnreadMessage(0); chatModel5.setLastMessageSendByMe(false); chats.add(chatModel5); print(chats.toString() + "this is the data we are saving"); } @override Widget build(BuildContext context) { return Scaffold( body: Container( child: Stack( children: <Widget>[ Container( decoration: BoxDecoration( gradient: LinearGradient( colors: [const Color(0xff213A50), const Color(0xff071930)], begin: FractionalOffset.topLeft, end: FractionalOffset.bottomRight)), ), Column( children: <Widget>[ SizedBox( height: 90, ), /// Tab Options /// Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Column( children: <Widget>[ Container( padding: EdgeInsets.all(10), decoration: tabSelected == 1 ? BoxDecoration( borderRadius: BorderRadius.circular(60), gradient: LinearGradient( colors: [ const Color(0xffA2834D), const Color(0xffBC9A5F) ], begin: FractionalOffset.topRight, end: FractionalOffset.bottomLeft)) : BoxDecoration(), child: Image.asset( "assets/images/profile.png", width: 35, height: 35, )), SizedBox( height: 16, ), Text( "Chat", style: TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.w500), ), ], ), SizedBox( width: 60, ), Column( children: <Widget>[ Container( padding: EdgeInsets.all(10), decoration: tabSelected == 1 ? BoxDecoration( borderRadius: BorderRadius.circular(60), gradient: LinearGradient( colors: [ const Color(0xffA2834D), const Color(0xffBC9A5F) ], begin: FractionalOffset.topRight, end: FractionalOffset.bottomLeft)) : BoxDecoration(), child: Image.asset( "assets/images/tindergoldlogo.png", width: 35, height: 35, ), ), SizedBox( height: 16, ), Text( "Pairs", style: TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.w500), ), ], ), SizedBox( width: 60, ), Column( children: <Widget>[ Container( padding: EdgeInsets.all(15), decoration: BoxDecoration( borderRadius: BorderRadius.circular(60), gradient: LinearGradient( colors: [ const Color(0xffA2834D), const Color(0xffBC9A5F) ], begin: FractionalOffset.topRight, end: FractionalOffset.bottomLeft)), child: Image.asset( "assets/images/chatbubble.png", width: 30, height: 30, )), SizedBox( height: 16, ), Text( "Activities", style: TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.w500), ), ], ), ], ), SizedBox( height: 16, ), Expanded( flex: 1, child: LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) { return SingleChildScrollView( child: ConstrainedBox( constraints: BoxConstraints( minHeight: viewportConstraints.maxHeight, ), child: Container( padding: EdgeInsets.symmetric(horizontal: 25, vertical: 8), child: Column( children: <Widget>[ Container( height: 0.2, color: Colors.white70, ), SizedBox( height: 16, ), ListView.builder( scrollDirection: Axis.vertical, shrinkWrap: true, itemCount: chats.length, itemBuilder: (context, index) { return ChatTile( userName: chats[index].getUserName() ?? '', userPicAssetPath: chats[index].getUserPicAssetPath() ?? '', lastMessage: chats[index].getLastMessage() ?? '', time: chats[index].getTme() ?? '', unreadMessages: chats[index].getUnreadMessages() ?? 0, lastMessageSendByMe: chats[index].getlastMessageSendByMe() ?? false, ); }) ], ), ), ), ); }), ) ], ) ], ), )); } } class ChatTile extends StatelessWidget { final String userName, userPicAssetPath, lastMessage, time; int unreadMessages = 0; bool lastMessageSendByMe = false; ChatTile( {this.userName, this.userPicAssetPath, this.lastMessage, this.time, this.unreadMessages, this.lastMessageSendByMe}); @override Widget build(BuildContext context) { return GestureDetector( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => ConversationScreen( name: userName, profilePicPath: userPicAssetPath, ))); }, child: Container( padding: EdgeInsets.only(bottom: 16), width: MediaQuery.of(context).size.width, child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Container( width: 70.0, height: 70.0, decoration: new BoxDecoration( color: const Color(0xff213A50), image: new DecorationImage( image: AssetImage(userPicAssetPath), fit: BoxFit.cover, ), borderRadius: new BorderRadius.all(new Radius.circular(40.0)), border: unreadMessages > 0 ? Border.all( color: Color(0xffD9B372), width: 2.0, ) : null, ), ), SizedBox( width: 16, ), Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ SizedBox( height: 8, ), Container( width: MediaQuery.of(context).size.width - 136, alignment: Alignment.topLeft, child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Text( userName, style: TextStyle( color: Colors.white, fontSize: 17, fontWeight: FontWeight.w400), ), SizedBox( width: 6, ), unreadMessages > 0 ? Row( children: <Widget>[ Container( width: 6, height: 6, decoration: BoxDecoration( shape: BoxShape.circle, color: Color(0xffD9B372), ), ), SizedBox( width: 6, ), Text( "$unreadMessages", style: TextStyle( color: Colors.white, fontSize: 14), ), ], ) : Container(), // TODO add Spacer(), Spacer(), Text( time, style: TextStyle(fontSize: 12, color: Colors.white70), ), ], ), ), SizedBox( height: 8, ), Row( children: <Widget>[ lastMessageSendByMe ? Row( children: <Widget>[ Image.asset( "assets/images/back_arrow.png", width: 14, height: 14, ), SizedBox( width: 8, ), ], ) : Container(), Container( width: MediaQuery.of(context).size.width - 158, child: Text( lastMessage, maxLines: 3, style: TextStyle( fontSize: 14, color: unreadMessages > 0 ? Colors.white : Colors.white70, ), ), ), ], ), SizedBox( height: 20, ), Container( width: MediaQuery.of(context).size.width - 136, height: 0.2, color: Colors.white70, ), SizedBox( height: 8, ) ], ) ], ), ), ); } } ///
0
mirrored_repositories/TinderGoldRedesign/lib
mirrored_repositories/TinderGoldRedesign/lib/model/ChatModel.dart
class ChatModel{ String userName; String userPicAssetPath; String lastMessage; String time; int unreadMessages; bool lastMessageSendByMe; ChatModel({this.userName,this.userPicAssetPath,this.lastMessage, this.time,this.unreadMessages,this.lastMessageSendByMe}); void setUserName(String name){ userName = name; } void setUserPicAssetPath(String userAssetPath){ userPicAssetPath = userAssetPath; } void setLastMessage(String mLastMessage){ lastMessage = mLastMessage; } void setTime(String mTime){ time = mTime; } void setUnreadMessage(int mUnreadMessages){ unreadMessages = mUnreadMessages; } void setLastMessageSendByMe(bool islastMessageSendByMe){ lastMessageSendByMe = islastMessageSendByMe; } String getUserName(){ return userName; } String getUserPicAssetPath(){ return userPicAssetPath; } String getLastMessage(){ return lastMessage; } String getTme(){ return time; } int getUnreadMessages(){ return unreadMessages; } bool getlastMessageSendByMe(){ return lastMessageSendByMe; } }
0
mirrored_repositories/TinderGoldRedesign/lib
mirrored_repositories/TinderGoldRedesign/lib/model/conversation_model.dart
class ConversationModel{ bool sendByMe; String message; ConversationModel({this.sendByMe,this.message}); void setMessage(String s) { message = s ; } void setSendByMe(bool sendByme) { sendByMe = sendByme; } String getMessage(){ return message; } bool getSendByMe(){ return sendByMe; } }
0
mirrored_repositories/judou
mirrored_repositories/judou/lib/main.dart
import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'main_page.dart'; void main() { // debugPaintSizeEnabled = true; debugDefaultTargetPlatformOverride = TargetPlatform.iOS; runApp(JuDouApp()); } class JuDouApp extends StatelessWidget { /// 强制设置splashColor和highlightColor为transparent /// 可以去除material的点击波纹效果 @override Widget build(BuildContext context) { return MaterialApp( home: MainPage(), theme: ThemeData( primaryColor: Colors.white, splashColor: Colors.transparent, highlightColor: Colors.transparent, ), ); } }
0
mirrored_repositories/judou
mirrored_repositories/judou/lib/main_page.dart
import 'package:flutter/material.dart'; import './index/pages/index_page.dart'; import './discovery/pages/discovery_page.dart'; import './profile/pages/profile_page.dart'; class MainPage extends StatefulWidget { MainPage({Key key}) : super(key: key); @override _MainPageState createState() => _MainPageState(); } class _MainPageState extends State<MainPage> with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin { int _selectedIndex = 0; static IndexPage _indexPage = IndexPage(); static DiscoveryPage _discoveryPage = DiscoveryPage(); static ProfilePage _profilePage = ProfilePage(); final _pages = [_indexPage, _discoveryPage, _profilePage]; @override void initState() { super.initState(); } void _onItemTapped(int index) { setState(() { _selectedIndex = index; }); } @override bool get wantKeepAlive => true; @override Widget build(BuildContext context) { super.build(context); return Scaffold( body: IndexedStack( index: _selectedIndex, children: _pages, ), bottomNavigationBar: BottomAppBar( child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ IconButton( icon: _selectedIndex == 0 ? Icon(Icons.autorenew) : Icon(Icons.adjust), onPressed: () => this._onItemTapped(0), ), IconButton( icon: _selectedIndex == 1 ? Icon(Icons.explore) : ImageIcon(AssetImage('assets/descovery.png')), onPressed: () => this._onItemTapped(1), ), IconButton( icon: _selectedIndex == 2 ? Icon(Icons.person) : Icon(Icons.person_outline), onPressed: () => this._onItemTapped(2), ) ], ), ), ); } }
0
mirrored_repositories/judou
mirrored_repositories/judou/lib/bloc_provider.dart
import 'package:flutter/cupertino.dart'; abstract class BlocBase { void dispose(); } // Generic BLoC provider class BlocProvider<T extends BlocBase> extends StatefulWidget { BlocProvider({ Key key, @required this.child, @required this.bloc, }) : super(key: key); final T bloc; final Widget child; @override _BlocProviderState<T> createState() => _BlocProviderState<T>(); static T of<T extends BlocBase>(BuildContext context) { final type = _typeOf<BlocProvider<T>>(); BlocProvider<T> provider = context.ancestorWidgetOfExactType(type); return provider.bloc; } static Type _typeOf<T>() => T; } class _BlocProviderState<T> extends State<BlocProvider<BlocBase>> { @override void dispose() { widget.bloc.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return widget.child; } }
0
mirrored_repositories/judou/lib
mirrored_repositories/judou/lib/network/path.dart
class RequestPath { /// 首页接口地址 static const String daily = '/v6/op/sentences/daily?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&page=1&per_page=45&platform=ios&signature=6d52830af89222da917a0161d3d32c70&system_version=12.1&timestamp=1546019663&token=249d880e4ba539c6edc04f9e35ff46a3&version=3.5.7&version_code=41'; /// 句子详情 /// [uuid] 句子id static String sentence(String uuid) { return '/v6/op/sentences/$uuid?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&platform=ios&signature=5351b762de0d27b2c2db3c4eebdaca41&system_version=12.1&timestamp=1546215975&token=249d880e4ba539c6edc04f9e35ff46a3&version=3.5.7&version_code=41'; } /// 句子热评 static String sentenceHot(String uuid) { return '/v6/op/sentences/$uuid/comments/hot?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&page=1&per_page=20&platform=ios&signature=78bffaeb4feeebdd5427dd810bc11e3d&system_version=12.1&timestamp=1546215975&token=249d880e4ba539c6edc04f9e35ff46a3&version=3.5.7&version_code=41'; } /// 最新评论 static String sentenceLatest(String uuid) { return '/v6/op/sentences/$uuid/comments/latest?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&page=1&per_page=20&platform=ios&signature=78bffaeb4feeebdd5427dd810bc11e3d&system_version=12.1&timestamp=1546215975&token=249d880e4ba539c6edc04f9e35ff46a3&version=3.5.7&version_code=41'; } /// 所有频道id + title static String channels() { return 'v6/op/channels/12?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&page=1&per_page=20&platform=ios&signature=9eb7dd623af816981a9947e017fb95e9&system_version=12.3&timestamp=1559000076&token=5c445d2b07a7e9ee6a84e9a4a1533891&version=3.8.0&version_code=51'; } /// 每个子频道的数据 /// 12 -> 订阅 static String channelWithId(String id) { return '/v6/op/channels/12?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&page=1&per_page=20&platform=ios&signature=44afc59250d46d93fdde07ba6579e889&system_version=12.1.2&timestamp=1551393195&token=bf803413c8e020a23f9c15f4c4237ee6&version=3.7.0&version_code=45'; } /// 发现页面 /// 底部Tags static String discoveryTags() { return '/v5/tags/list?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&platform=ios&signature=75f4b199a5ed71b7bb9c85679839ae7d&system_version=12.1.2&timestamp=1546822867&version=3.6.1&version_code=44'; } /// 发现页面 /// 话题数据 static String topicData() { return '/v5/topics?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&platform=ios&signature=75f4b199a5ed71b7bb9c85679839ae7d&system_version=12.1.2&timestamp=1546822867&version=3.6.1&version_code=44'; } /// 发现页面 /// 根据Tag id获取数据 /// [id] tag id static String dataWithTagId(String id) { return '/v5/tags/$id/ordered_sentences?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&page=1&per_page=20&platform=ios&signature=af6b8753c7eed7177746f0b326de350d&system_version=12.1.2&timestamp=1546822893&token=5fbeffff6f6d92c4902139d2619852b0&version=3.6.1&version_code=44'; } /// 发现页面 /// 推荐轮播 static String carousels() { return '/v5/recommends/carousels?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&platform=ios&signature=39acb567bf5b1792f58b58ff46ad6003&system_version=12.1.2&timestamp=1547011818&token=8783e97df8f4a954663a0674fb38ffe0&version=3.6.1&version_code=44'; } /// 发现页面 /// 今日哲思考 static String todayThink() { return '/v5/recommends/today?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&platform=ios&signature=39acb567bf5b1792f58b58ff46ad6003&system_version=12.1.2&timestamp=1547011818&token=8783e97df8f4a954663a0674fb38ffe0&version=3.6.1&version_code=44'; } /// 发现页面 /// 三段list数据 /// posts /// subjects /// videos static String recommand() { return '/v5/recommends?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&platform=ios&signature=39acb567bf5b1792f58b58ff46ad6003&system_version=12.1.2&timestamp=1547011818&token=8783e97df8f4a954663a0674fb38ffe0&version=3.6.1&version_code=44'; } /// ProfileDetail /// Author Info static String authorInfo(String id) { return '/v6/op/authors/$id?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&platform=ios&signature=a00f384c42d33a23334baef74690628b&system_version=12.1.2&timestamp=1547494083&token=8783e97df8f4a954663a0674fb38ffe0&version=3.6.1&version_code=44'; } /// ProfileDetail /// Author Sentences Latest static String authorInfoLatest(String id) { return '/v6/op/authors/$id/sentences?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&order_by=latest&page=1&per_page=20&platform=ios&signature=e53538fc8afbeee370c06f4ac9e88862&system_version=12.1.2&timestamp=1547494908&token=8783e97df8f4a954663a0674fb38ffe0&version=3.6.1&version_code=44'; } /// ProfileDetail /// Author Sentences Hot static String authorInfoHot(String id) { return '/v6/op/authors/$id/sentences?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&order_by=hot&page=1&per_page=20&platform=ios&signature=b93170717513bd9ea3aba395911fb740&system_version=12.1.2&timestamp=1547494915&token=8783e97df8f4a954663a0674fb38ffe0&version=3.6.1&version_code=44'; } /// ProfileDetail /// Topics info static String topicsInfo(String uuid) { return '/v5/topics/$uuid?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&platform=ios&signature=816ca877b7a4f8ebae64fc5fbd2cf81f&system_version=12.1.2&timestamp=1547497222&token=8783e97df8f4a954663a0674fb38ffe0&version=3.6.1&version_code=44'; } /// ProfileDetail /// Topics Latest static String topicsInfoLatest(String uuid) { return '/v5/topics/$uuid/sentences?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&page=1&per_page=20&platform=ios&signature=6c86664041fa6268b446f716cc0d84be&system_version=12.1.2&timestamp=1547497222&token=8783e97df8f4a954663a0674fb38ffe0&type=latest&version=3.6.1&version_code=44'; } /// ProfileDetail /// Topics Hot static String topicsInfoHot(String uuid) { return '/v5/topics/$uuid/sentences?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&page=1&per_page=20&platform=ios&signature=8131b95f324e83bde06ecd60d7511966&system_version=12.1.2&timestamp=1547497366&token=8783e97df8f4a954663a0674fb38ffe0&type=hot&version=3.6.1&version_code=44'; } /// ProfileDetail /// User static String userInfo(String uid) { return '/v5/users/$uid?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&platform=ios&signature=34e8a31d21c37d78557486df1e4aa07a&system_version=12.1.2&timestamp=1547669808&token=8783e97df8f4a954663a0674fb38ffe0&version=3.6.1&version_code=44'; } /// ProfileDetail /// User Sentences static String userInfoSentences(String uid) { return '/v6/op/users/$uid/sentences?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&page=1&per_page=20&platform=ios&signature=0d73839987a308ebfa7019f071968b05&system_version=12.1.2&timestamp=1547669808&token=8783e97df8f4a954663a0674fb38ffe0&version=3.6.1&version_code=44'; } /// ProfileDetail /// User Collections static String userInfoCollections(String uid) { return '/v6/op/users/$uid/collections?app_key=af66b896-665e-415c-a119-6ca5233a6963&channel=App%20Store&device_id=9f5e19d3dd08667400da31ae0e045e1b&device_type=iPhone9%2C1&page=1&per_page=20&platform=ios&signature=b4fdc33ea9ac41325261a7ccf2a4dbc1&system_version=12.1.2&timestamp=1547497622&token=8783e97df8f4a954663a0674fb38ffe0&version=3.6.1&version_code=44'; } }
0
mirrored_repositories/judou/lib
mirrored_repositories/judou/lib/network/network.dart
export 'package:rxdart/rxdart.dart'; export '../bloc_provider.dart'; export 'package:dio/dio.dart'; export './request.dart'; export './path.dart';
0
mirrored_repositories/judou/lib
mirrored_repositories/judou/lib/network/request.dart
import 'package:dio/dio.dart'; class Request { /// instance static final Request _request = Request._internal(); Request._internal(); static Request get instance => _request; /// Dio通用配置 /// baseUrl -> https://judouapp.com/api /// connectTimeout /// receiveTimeout /// final Dio dio = Dio( BaseOptions( baseUrl: 'https://judouapp.com/api', connectTimeout: 5000, receiveTimeout: 3000, responseType: ResponseType.json, ), ); }
0
mirrored_repositories/judou/lib
mirrored_repositories/judou/lib/widgets/button_subscript.dart
import 'package:flutter/material.dart'; import '../utils/color_util.dart'; class SubscriptButton extends StatefulWidget { SubscriptButton( {Key key, @required this.icon, this.color = ColorUtils.iconColor, @required this.subscript, this.onPressed}) : super(key: key); final Icon icon; final Color color; final String subscript; final VoidCallback onPressed; @override _SubscriptButtonState createState() => _SubscriptButtonState(); } class _SubscriptButtonState extends State<SubscriptButton> { @override Widget build(BuildContext context) { return Stack( alignment: AlignmentDirectional.topEnd, children: <Widget>[ SizedBox( child: Container( padding: EdgeInsets.only(top: 5, right: 5), child: IconButton( icon: widget.icon, onPressed: widget.onPressed, color: widget.color))), Positioned( top: 12, child: Text(widget.subscript, style: TextStyle( fontSize: 10, color: widget.color, fontFamily: 'PingFang'), textAlign: TextAlign.left)) ], ); } }
0
mirrored_repositories/judou/lib
mirrored_repositories/judou/lib/widgets/radius_image.dart
import 'package:flutter/material.dart'; class RadiusImage extends StatelessWidget { RadiusImage({ Key key, this.radius, @required this.imageUrl, @required this.width, @required this.height, }) : super(key: key); final double radius; final String imageUrl; final double width; final double height; @override Widget build(BuildContext context) { return ClipRRect( borderRadius: BorderRadius.all(Radius.circular(this.radius ?? 0)), child: imageUrl == null || imageUrl == '' ? Image( image: AssetImage('assets/avatar_placeholder.png'), width: this.width, height: this.height, ) : Image.network( this.imageUrl, width: this.width, height: this.height, fit: BoxFit.cover, gaplessPlayback: true, ), ); } }
0
mirrored_repositories/judou/lib
mirrored_repositories/judou/lib/widgets/SliverAppBarDelegate.dart
import 'package:flutter/material.dart'; import 'dart:math' as math; class SliverAppBarDelegate extends SliverPersistentHeaderDelegate { SliverAppBarDelegate({ @required this.minHeight, @required this.maxHeight, @required this.child, }); final double minHeight; final double maxHeight; final Widget child; @override double get minExtent => minHeight; @override double get maxExtent => math.max(minHeight, maxHeight); @override bool shouldRebuild(SliverAppBarDelegate oldDelegate) { return maxHeight != oldDelegate.maxHeight || minHeight != oldDelegate.minHeight || child != oldDelegate.child; } @override Widget build( BuildContext context, double shrinkOffset, bool overlapsContent) { return SizedBox.expand(child: child); } }
0
mirrored_repositories/judou/lib
mirrored_repositories/judou/lib/widgets/collection_cell.dart
import 'package:flutter/material.dart'; import './radius_image.dart'; import '../profile/models/collections_model.dart'; class CollectionCell extends StatelessWidget { CollectionCell({ Key key, this.model, }) : super(key: key); final CollectionModel model; @override Widget build(BuildContext context) { var width = MediaQuery.of(context).size.width / 2; return Container( color: Colors.white, child: Stack( children: <Widget>[ SizedBox( width: width, height: width, child: Container( padding: EdgeInsets.only(top: 0, bottom: 10, left: 20, right: 10), child: RadiusImage( imageUrl: model.cover, radius: 5, width: width - 30, height: width - 30, ), ), ), Center( child: Text( model.name, style: TextStyle(color: Colors.white), ), ) ], ), ); } }
0
mirrored_repositories/judou/lib
mirrored_repositories/judou/lib/widgets/loading.dart
import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'dart:io'; class Loading extends StatelessWidget { @override Widget build(BuildContext context) { return Center( child: Platform.isIOS ? CupertinoActivityIndicator( radius: 16, ) : CircularProgressIndicator(), ); } }
0
mirrored_repositories/judou/lib
mirrored_repositories/judou/lib/widgets/blank.dart
import 'package:flutter/material.dart'; import '../utils/color_util.dart'; class Blank extends StatelessWidget { Blank({Key key, this.height = 10, this.color = ColorUtils.blankColor}) : super(key: key); final double height; final Color color; @override Widget build(BuildContext context) { return SizedBox( width: MediaQuery.of(context).size.width, height: height, child: Container(color: color), ); } }
0
mirrored_repositories/judou/lib
mirrored_repositories/judou/lib/widgets/image_preview.dart
import 'package:flutter/material.dart'; class ImagePreview extends StatelessWidget { ImagePreview({Key key, this.imageUrl, this.tag}) : super(key: key); final String imageUrl; final String tag; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, body: Center( child: Hero( tag: this.tag, child: GestureDetector( child: Image.network(this.imageUrl), onTap: () => Navigator.pop(context)), transitionOnUserGestures: true), ), ); } }
0
mirrored_repositories/judou/lib
mirrored_repositories/judou/lib/widgets/user_info_tile.dart
import './radius_image.dart'; import '../utils/color_util.dart'; import 'package:flutter/material.dart'; class UserInfoTile extends StatelessWidget { UserInfoTile({ @required this.avatar, @required this.name, @required this.trailName, }); final String avatar; final String name; final String trailName; @override Widget build(BuildContext context) { return Row( children: <Widget>[ RadiusImage( imageUrl: avatar, width: 20, height: 20, radius: 10, ), Padding( padding: EdgeInsets.only(left: 5), child: Text( name, style: TextStyle(fontSize: 10), ), ), Padding( padding: EdgeInsets.only(left: 10), child: Text( trailName, style: TextStyle(fontSize: 10, color: ColorUtils.textGreyColor), ), ), ], ); } }
0
mirrored_repositories/judou/lib
mirrored_repositories/judou/lib/widgets/judou_cell.dart
import '../widgets/blank.dart'; import './user_info_tile.dart'; import '../utils/color_util.dart'; import '../widgets/radius_image.dart'; import '../widgets/image_preview.dart'; import 'package:flutter/material.dart'; import '../index/pages/detail_page.dart'; import '../index/models/judou_model.dart'; import '../profile/pages/profile_detail.dart'; import 'package:page_transition/page_transition.dart'; class JuDouCell extends StatefulWidget { JuDouCell({ Key key, this.divider, this.tag, this.model, this.isCell = true, }) : super(key: key); final Widget divider; // 每一个tag必须是唯一的 final String tag; final JuDouModel model; /// 如果是作为Cell时content文字只显示三行 final bool isCell; @override _JuDouCellState createState() => _JuDouCellState(); } class _JuDouCellState extends State<JuDouCell> with SingleTickerProviderStateMixin { JuDouModel model; AnimationController controller; @override void initState() { super.initState(); model = widget.model; controller = AnimationController(vsync: this, value: 1.0); } // 点击右侧下箭头 void _moreAction() { showModalBottomSheet( context: context, builder: (builder) => SafeArea( child: Container( color: Colors.white, height: 101, child: Column( children: <Widget>[ FlatButton(child: Text('复制'), onPressed: () => print('复制')), Blank(height: 5), FlatButton(child: Text('取消'), onPressed: () => print('取消')), ], ), ), ), ); } // 中间大图 Widget _midImage(BuildContext context) => Hero( tag: widget.tag, transitionOnUserGestures: true, child: Padding( padding: EdgeInsets.only(top: 10, bottom: 10), child: RadiusImage( imageUrl: model.pictures[0].url, width: MediaQuery.of(context).size.width, height: 200, radius: 8.0, ), ), ); // 大图预览 void _toImagePreview(BuildContext context) { Navigator.push( context, PageTransition( type: PageTransitionType.fade, child: ImagePreview( imageUrl: model.pictures[0].url, tag: widget.tag, ), ), ); } void _toDetailPage() { if (!widget.isCell) return; Navigator.push( context, MaterialPageRoute( builder: (context) => DetailPage(model: model), ), ); } @override Widget build(BuildContext context) { return GestureDetector( child: Column(children: <Widget>[ Container( padding: EdgeInsets.only(top: 15, bottom: 10, left: 15, right: 15), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ _AuthorInfo(model: model, moreAction: _moreAction), Text( model.content, style: TextStyle(color: ColorUtils.textPrimaryColor, fontSize: 14, height: 1.2), maxLines: widget.isCell ? 4 : 999, overflow: TextOverflow.ellipsis, softWrap: true, ), model.pictures.isNotEmpty ? GestureDetector( child: _midImage(context), onTap: () => _toImagePreview(context), ) : Container(height: 10), _ReferenceAuthorInfo(model: model), Divider(color: ColorUtils.dividerColor), _BottomButtonRow(model: model, commentAction: _toDetailPage) ], ), color: Colors.white, ), widget.divider, ]), onTap: _toDetailPage, ); } } /// 顶部作者信息 class _AuthorInfo extends StatelessWidget { _AuthorInfo({Key key, this.model, this.moreAction}) : super(key: key); final JuDouModel model; final VoidCallback moreAction; @override Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Container( child: GestureDetector( child: Row( children: <Widget>[ RadiusImage( radius: 3.0, imageUrl: model.author != null ? model.author.coverUrl : model.user.avatar ?? '', width: 30, height: 30), Padding( padding: EdgeInsets.only(left: 10), child: Text( model.author != null ? model.author.name : model.user.nickname, style: TextStyle(fontSize: 15, fontWeight: FontWeight.w300, color: ColorUtils.textUserNameColor), ), ), Padding( padding: EdgeInsets.only(left: 10), child: (model.author != null ? model.author.isVerified : false) ? Icon(Icons.stars, size: 16, color: Colors.blue) : Container()), ], ), onTap: () { Navigator.push( context, MaterialPageRoute( builder: (_) => ProfileDetailPage(type: 1, id: '${model.author.id ?? model.user.uid}')), ); }, ), ), IconButton(icon: Icon(Icons.keyboard_arrow_down), onPressed: moreAction), ], ); } } /// 收录者信息 class _ReferenceAuthorInfo extends StatelessWidget { _ReferenceAuthorInfo({Key key, this.model}) : super(key: key); final JuDouModel model; @override Widget build(BuildContext context) { return model.user != null ? UserInfoTile( avatar: model.user.avatar, name: model.user.nickname, trailName: '收录', ) : Container(); } } /// 最底部一排icon class _BottomButtonRow extends StatelessWidget { _BottomButtonRow({Key key, this.model, this.commentAction}) : super(key: key); final JuDouModel model; final VoidCallback commentAction; Widget btn(IconData iconData, VoidCallback onTap, [String rightTitle]) => GestureDetector( child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Icon(iconData, color: ColorUtils.textUserNameColor), Padding( padding: EdgeInsets.only(left: 2), child: Text( rightTitle ?? '', style: TextStyle(color: ColorUtils.textUserNameColor, fontSize: 10), ), ) ], ), onTap: onTap, ); @override Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ btn(Icons.favorite_border, () => print('11111'), '${model.likeCount}'), btn(Icons.insert_comment, commentAction, '${model.commentCount}'), btn(Icons.bookmark_border, null), btn(Icons.share, null) ], ); } }
0
mirrored_repositories/judou/lib
mirrored_repositories/judou/lib/widgets/label.dart
import 'package:flutter/material.dart'; import '../utils/color_util.dart'; class Label extends StatelessWidget { Label( {Key key, this.title, @required this.width, @required this.height, this.radius, this.onTap}) : super(key: key); final double width; final double height; final double radius; final String title; final VoidCallback onTap; @override Widget build(BuildContext context) { return GestureDetector( child: SizedBox( width: this.width, height: this.height, child: Container( decoration: BoxDecoration( border: Border.all(color: ColorUtils.textGreyColor), borderRadius: BorderRadius.all( Radius.circular(this.radius ?? 0), ), shape: BoxShape.rectangle, ), child: Center( child: Text( this.title, style: TextStyle(color: Colors.black45, fontSize: 12), ), ), ), ), onTap: this.onTap ?? () => {}, ); } }
0
mirrored_repositories/judou/lib
mirrored_repositories/judou/lib/widgets/end_cell.dart
import 'package:flutter/material.dart'; import '../utils/color_util.dart'; class EndCell extends StatelessWidget { EndCell({Key key, this.text}) : super(key: key); final String text; @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.only(top: 10, bottom: 50), child: Align( alignment: AlignmentDirectional.center, child: Text( text, style: TextStyle(color: ColorUtils.textGreyColor), ), ), ); } }
0
mirrored_repositories/judou/lib
mirrored_repositories/judou/lib/widgets/comment_cell.dart
import 'package:flutter/material.dart'; import '../widgets/radius_image.dart'; import '../index/models/comment_model.dart'; import '../utils/color_util.dart'; import '../utils/date_util.dart'; import '../profile/pages/profile_detail.dart'; class CommentCell extends StatelessWidget { CommentCell({Key key, @required this.divider, this.model}) : super(key: key); final Widget divider; final CommentModel model; @override Widget build(BuildContext context) { Widget commentContent() => Padding( padding: EdgeInsets.only(bottom: 10), child: Text( model.content, style: TextStyle( color: ColorUtils.textPrimaryColor, fontSize: 13, height: 1.2, ), ), ); return Container( padding: EdgeInsets.only(left: 15), color: Colors.white, child: Column( children: <Widget>[ _UserInfo(model: model), Padding( padding: EdgeInsets.only( left: 35, right: 15, bottom: model.replyToComment.isEmpty ? 0 : 8), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ commentContent(), model.replyToComment.isEmpty ? Container() : _ReplyContent( replyModel: CommentModel.fromJSON(model.replyToComment), ), ], ), ), Padding( padding: EdgeInsets.only(left: 35), child: divider, ), ], ), ); } } // 点赞及数字 class _UpCount extends StatelessWidget { _UpCount({this.isLiked, this.countStr}); final bool isLiked; final String countStr; @override Widget build(BuildContext context) { var color = isLiked ? Colors.black : ColorUtils.textGreyColor; return Row( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Text( countStr, style: TextStyle(fontSize: 10, color: color), textAlign: TextAlign.end, ), IconButton( alignment: Alignment.centerLeft, icon: Icon( Icons.thumb_up, color: color, ), onPressed: null, iconSize: 12, ), ], ); } } // user-info class _UserInfo extends StatelessWidget { _UserInfo({this.model}); final CommentModel model; @override Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ GestureDetector( onTap: () => Navigator.push( context, MaterialPageRoute( builder: (_) => ProfileDetailPage(type: 0, id: '${model.user.uid}')), ), child: Row( children: <Widget>[ RadiusImage( width: 30, height: 30, radius: 15, imageUrl: model.user.avatar, ), Container( padding: EdgeInsets.only(left: 5), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text( model.user.nickname, style: TextStyle(fontSize: 13), ), Text( DateUtils.fromNow(int.parse(model.createdAt)), style: TextStyle( fontSize: 10, color: ColorUtils.textGreyColor, ), softWrap: true, maxLines: 999, ) ], ), ), ], ), ), _UpCount(isLiked: model.isLiked, countStr: '${model.upCount}'), ], ); } } // 回复引用 class _ReplyContent extends StatelessWidget { _ReplyContent({this.replyModel}); final CommentModel replyModel; @override Widget build(BuildContext context) { return Container( width: 999, padding: EdgeInsets.all(8), color: ColorUtils.blankColor, child: RichText( text: TextSpan( children: <TextSpan>[ TextSpan( text: '${replyModel.user.nickname}:', style: TextStyle( color: ColorUtils.textGreyColor, fontSize: 12, height: 1.2, ), ), TextSpan( text: replyModel.content, style: TextStyle( fontSize: 12, height: 1.2, color: ColorUtils.textPrimaryColor), ) ], ), ), ); } }
0
mirrored_repositories/judou/lib
mirrored_repositories/judou/lib/widgets/jottings_cell.dart
/// 随笔cell import 'package:flutter/material.dart'; import '../utils/color_util.dart'; class JottingsCell extends StatelessWidget { @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.all(15), color: Colors.white, margin: EdgeInsets.only(bottom: 10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( '等我一年半', style: TextStyle(color: ColorUtils.textPrimaryColor, fontSize: 14), ), Padding( child: Text( '平日喧闹的告诉公路,在这圣诞之夜出奇地安静,隔着车窗外望,四野一片迷茫', style: TextStyle( color: Colors.grey[500], fontSize: 12, fontWeight: FontWeight.w300, ), ), padding: EdgeInsets.only(top: 5, bottom: 5), ), Row( crossAxisAlignment: CrossAxisAlignment.end, children: <Widget>[ Text( '天南', style: TextStyle(fontSize: 10, color: Colors.brown[200]), ), Padding( padding: EdgeInsets.only(left: 5, right: 5), child: Icon( Icons.remove_red_eye, size: 12, color: ColorUtils.textGreyColor, ), ), Text( '666', style: TextStyle( fontSize: 10, color: ColorUtils.textUserNameColor), ), ], ), Padding( padding: EdgeInsets.only(top: 10), child: Image.network( 'https:\/\/judou.oss-cn-beijing.aliyuncs.com\/images\/sentence\/2018\/12\/24\/2ucj7v8q0r.jpeg', fit: BoxFit.cover, height: 200, width: 999, ), ) ], ), ); } }
0
mirrored_repositories/judou/lib/profile
mirrored_repositories/judou/lib/profile/widgets/verify_header.dart
// 认证用户的Profile import 'dart:ui'; import '../../index/models/user_model.dart'; import '../../utils/ui_util.dart'; import '../../widgets/blank.dart'; import '../../utils/color_util.dart'; import 'package:flutter/material.dart'; import '../../widgets/radius_image.dart'; import '../../widgets/user_info_tile.dart'; class VerfiyHeader extends StatelessWidget { VerfiyHeader({this.data}); final Map<String, dynamic> data; @override Widget build(BuildContext context) { final sreenWidth = MediaQuery.of(context).size.width; UserModel user = UserModel.fromJson(data['user'] ?? Map()); return Stack( children: <Widget>[ SizedBox( width: sreenWidth, height: 180, child: Image.network( data['cover'], fit: BoxFit.cover, ), ), BackdropFilter( filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), child: Container( height: 180, width: sreenWidth, color: Colors.grey.withOpacity(0.1), ), ), Positioned( top: 160, child: Padding( padding: EdgeInsets.only(left: 15), child: Text( '2380人订阅', style: TextStyle(color: Colors.white70, fontSize: 12), ), ), ), Positioned( top: 120, left: (sreenWidth - 80) / 2, child: RadiusImage( imageUrl: data['cover'], width: 80, height: 80, radius: 3, ), ), Positioned( child: Container( padding: EdgeInsets.symmetric(vertical: 10, horizontal: 15), height: DeviceUtils.iPhoneXAbove(context) ? 140 : 110, width: MediaQuery.of(context).size.width, child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( data['name'], style: TextStyle(fontSize: 13), ), Icon(Icons.stars, size: 16, color: Colors.blue) ], ), Align( alignment: Alignment.centerLeft, child: Text( data['description'], style: TextStyle( fontSize: 12, color: ColorUtils.textGreyColor), maxLines: DeviceUtils.iPhoneXAbove(context) ? 3 : 2, overflow: TextOverflow.ellipsis, softWrap: true, ), ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ data['user'] != null ? UserInfoTile( avatar: user.avatar, name: user.nickname, trailName: '创建', ) : Container(), Container( decoration: BoxDecoration( border: Border.all(width: 0.5), borderRadius: BorderRadius.all(Radius.circular(3)), ), height: 24, width: 60, child: Center( child: Text( '订阅', style: TextStyle(fontSize: 13), ), ), ) ], ), ], ), ), top: 200, ), Positioned( bottom: 44, child: Blank(height: 10), ) ], ); } }
0
mirrored_repositories/judou/lib/profile
mirrored_repositories/judou/lib/profile/widgets/normal_header.dart
// 普通用户Profile import 'dart:ui'; import '../../utils/ui_util.dart'; import 'package:flutter/material.dart'; import '../../widgets/radius_image.dart'; class NormalHeader extends StatelessWidget { NormalHeader({this.data}); final Map<String, dynamic> data; @override Widget build(BuildContext context) { final sreenWidth = MediaQuery.of(context).size.width; TextStyle textStyle(double size) { return TextStyle( color: Colors.white, fontSize: size, fontWeight: FontWeight.w300); } return Stack( children: <Widget>[ SizedBox( width: sreenWidth, height: DeviceUtils.iPhoneXAbove(context) ? 286 : 264, child: Image.network( data['avatar'], fit: BoxFit.cover, ), ), BackdropFilter( filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), child: Container( height: DeviceUtils.iPhoneXAbove(context) ? 286 : 264, width: sreenWidth, color: Colors.black.withOpacity(0.4), child: Align( alignment: Alignment.center, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Padding( padding: EdgeInsets.only(top: 80), child: RadiusImage( imageUrl: data['avatar'], width: 70, height: 70, radius: 35, ), ), Padding( padding: EdgeInsets.symmetric(vertical: 8), child: Text(data['nickname'], style: textStyle(16)), ), Padding( padding: EdgeInsets.only(bottom: 10), child: Text( '关注 ${data['followings_count']} | 粉丝 ${data['followers_count']}', style: textStyle(12)), ), Container( decoration: BoxDecoration( border: Border.all(width: 0.5, color: Colors.white), borderRadius: BorderRadius.all(Radius.circular(12))), height: 24, width: 100, child: Center( child: Text( data['is_self'] ? '编辑' : '关注', style: textStyle(12), ), ), ) ], ), ), ), ), ], ); } }
0
mirrored_repositories/judou/lib/profile
mirrored_repositories/judou/lib/profile/widgets/subscribes_cell.dart
import 'package:flutter/material.dart'; import '../../widgets/radius_image.dart'; import '../../utils/color_util.dart'; class SubscribesCell extends StatelessWidget { @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.symmetric(horizontal: 15, vertical: 8), margin: EdgeInsets.only(bottom: 10), color: Colors.white, child: Row( children: <Widget>[ RadiusImage( imageUrl: 'http:\/\/judou.b0.upaiyun.com\/avatar\/2018\/04\/2E9998D6-7BC8-4D1A-B2D2-77B2D664910A.JPG', radius: 3.0, width: 60, height: 60, ), Padding( padding: EdgeInsets.only(left: 8), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Text( '薛之谦', style: TextStyle( fontSize: 14, color: ColorUtils.textPrimaryColor, ), ), Padding( padding: EdgeInsets.only(left: 3), child: Icon( Icons.stars, size: 16, color: Colors.blue, ), ) ], ), Container( width: MediaQuery.of(context).size.width - 98, child: Text( '华语流行乐男歌手,影视演员,音乐制作人,代表作品认真的雪、演员、丑八怪 || 华语流行乐男歌手,影视演员,音乐制作人,代表作品认真的雪、演员、丑八怪', style: TextStyle( fontSize: 12, color: ColorUtils.textGreyColor, ), softWrap: true, overflow: TextOverflow.ellipsis, maxLines: 2, ), ) ], ), ) ], ), ); } }
0
mirrored_repositories/judou/lib/profile
mirrored_repositories/judou/lib/profile/widgets/list_cell.dart
import 'package:flutter/material.dart'; import 'package:flutter/foundation.dart'; import '../../utils/color_util.dart'; class ListCell extends StatelessWidget { ListCell( {Key key, this.leading, this.title, this.trailing, this.onTap, this.isDivider = false}) : super(key: key); final bool isDivider; final IconData leading; final String title; final IconData trailing; final VoidCallback onTap; @override Widget build(BuildContext context) { return GestureDetector( child: Container( child: Column( children: <Widget>[ Container( padding: EdgeInsets.only(top: 10, bottom: 10), color: Colors.white, child: Row( children: <Widget>[ Row( children: <Widget>[ Container( child: Icon(this.leading, color: ColorUtils.iconColor), padding: EdgeInsets.only(left: 15, right: 15), ), Text( this.title, style: TextStyle(fontSize: 16), ), ], ), Container( child: Icon(this.trailing, color: ColorUtils.dividerColor, size: 16), padding: EdgeInsets.only(left: 15, right: 15), ) ], mainAxisAlignment: MainAxisAlignment.spaceBetween, ), ), Divider( color: this.isDivider ? ColorUtils.dividerColor : Colors.transparent, indent: 54, height: 1, ) ], ), color: Colors.white, ), onTap: this.onTap ?? () => {}, ); } }
0
mirrored_repositories/judou/lib/profile
mirrored_repositories/judou/lib/profile/pages/profile_detail.dart
import 'dart:ui'; import '../../widgets/blank.dart'; import '../../widgets/judou_cell.dart'; import '../models/collections_model.dart'; import '../../bloc_provider.dart'; import '../widgets/verify_header.dart'; import 'package:flutter/services.dart'; import '../../utils/color_util.dart'; import 'package:flutter/material.dart'; import '../widgets/normal_header.dart'; import '../Bloc/profile_detail_bloc.dart'; import '../../widgets/loading.dart'; import '../../widgets/collection_cell.dart'; import '../../index/models/judou_model.dart'; import '../../discovery/widget/topic_header.dart'; class ProfileDetailPage extends StatelessWidget { /// prfile header wiget type /// 0 Normal /// 1 Verify /// 2 Topics ProfileDetailPage({ @required this.type, @required this.id, }); final String id; final int type; @override Widget build(BuildContext context) { return BlocProvider( bloc: ProfileDetailBloc(type, id), child: ProfilDetail(), ); } } class ProfilDetail extends StatefulWidget { @override _ProfilDetailState createState() => _ProfilDetailState(); } class _ProfilDetailState extends State<ProfilDetail> { Color _titleColor = Colors.transparent; Color _iconColor = Colors.white; ScrollController _controller = ScrollController(); ProfileDetailBloc _bloc; Brightness _brightness = Brightness.dark; @override void initState() { super.initState(); _bloc = BlocProvider.of<ProfileDetailBloc>(context); _controller.addListener(() { bool isTop = _controller.offset >= 135; setState(() { _titleColor = isTop ? Colors.black : Colors.transparent; _iconColor = isTop ? Colors.black : Colors.white; _brightness = isTop ? Brightness.light : Brightness.dark; }); }); } Widget _header(Map<String, dynamic> map, int type) { List<Widget> list = [ NormalHeader(data: map), VerfiyHeader(data: map), TopicsHeader(data: map) ]; return list[type]; } /// verify,topics -> 350 /// normal -> 286 @override Widget build(BuildContext context) { return DefaultTabController( length: 2, child: StreamBuilder( stream: _bloc.stream, builder: (context, snapshot) { if (snapshot.connectionState != ConnectionState.active) { return Container( color: Colors.white, child: Loading(), ); } Map<String, dynamic> header = snapshot.data['header']; List<JuDouModel> sentences = snapshot.data['sentences']; List<CollectionModel> collections; List<JuDouModel> hot; String title; if (_bloc.type == 0) { title = header['nickname']; collections = snapshot.data['collections']; } else { title = header['name']; hot = snapshot.data['collections']; } return Scaffold( backgroundColor: Colors.white, body: NestedScrollView( controller: _controller, body: TabBarView( children: <Widget>[ ListView.builder( itemBuilder: (context, index) { return JuDouCell( divider: Blank(), tag: 'profile_detail_$index', model: sentences[index], isCell: true, ); }, itemCount: sentences.length, ), _bloc.type == 0 ? GridView.builder( itemBuilder: (context, index) { return CollectionCell(model: collections[index]); }, itemCount: collections.length, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2), ) : ListView.builder( itemBuilder: (context, index) { return JuDouCell( divider: Blank(), tag: 'profile_detail_hot$index', model: hot[index], isCell: true, ); }, itemCount: hot.length, ), ], ), headerSliverBuilder: (context, innerBoxIsScrolled) { return [ SliverAppBar( brightness: _brightness, backgroundColor: Colors.white, expandedHeight: _bloc.type == 1 ? 350 : 286, bottom: TabBar( indicatorColor: Colors.yellow, indicatorSize: TabBarIndicatorSize.label, unselectedLabelColor: ColorUtils.textGreyColor, tabs: <Widget>[ Tab( text: _bloc.type == 0 ? '句子 ${sentences.length}' : '最新'), Tab( text: _bloc.type == 0 ? '收藏夹 ${collections.length}' : '最热') ], ), iconTheme: IconThemeData(color: _iconColor), pinned: true, flexibleSpace: FlexibleSpaceBar( background: _header(header, _bloc.type), collapseMode: CollapseMode.pin, ), title: Text( title, style: TextStyle(color: _titleColor), ), leading: IconButton( icon: Icon(Icons.arrow_back_ios, color: _iconColor, size: 20), onPressed: () { Navigator.maybePop(context); }, ), ) ]; }, ), ); }, ), ); } }
0
mirrored_repositories/judou/lib/profile
mirrored_repositories/judou/lib/profile/pages/message_page.dart
import 'package:flutter/material.dart'; import '../../widgets/blank.dart'; import '../widgets/list_cell.dart'; class MessagePage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.grey[100], appBar: AppBar( title: Text('我的消息'), actions: <Widget>[ FlatButton(child: Text('清空'), onPressed: () => debugPrint('消息清空')) ], ), body: ListView(children: <Widget>[ Blank(height: 15), ListCell( leading: Icons.alarm, title: '通知', trailing: Icons.arrow_forward_ios, isDivider: true), ListCell( leading: Icons.person_add, title: '关注', trailing: Icons.arrow_forward_ios, isDivider: true), ListCell( leading: Icons.thumb_up, title: '点赞', trailing: Icons.arrow_forward_ios, isDivider: true), ListCell( leading: Icons.message, title: '评论', trailing: Icons.arrow_forward_ios, isDivider: true), ListCell( leading: Icons.bookmark_border, title: '收藏', trailing: Icons.arrow_forward_ios), ]), ); } }
0
mirrored_repositories/judou/lib/profile
mirrored_repositories/judou/lib/profile/pages/profile_page.dart
import 'package:flutter/material.dart'; import '../widgets/list_cell.dart'; import 'message_page.dart'; import '../../widgets/blank.dart'; import '../../utils/color_util.dart'; import 'subscribes_page.dart'; class ProfilePage extends StatefulWidget { ProfilePage({Key key}) : super(key: key); @override _ProfilePageState createState() => _ProfilePageState(); } class _ProfilePageState extends State<ProfilePage> { // 头像 + 昵称 Widget header() => Container( padding: EdgeInsets.only(top: 25, left: 15, right: 15, bottom: 25), child: Row( children: <Widget>[ Container( child: CircleAvatar(backgroundColor: Colors.orange, radius: 40), padding: EdgeInsets.only(left: 15, right: 15)), Column( children: <Widget>[ Text( 'CrazyCoderShi', style: TextStyle(fontSize: 20, fontFamily: 'PingFang'), ), GestureDetector( child: Text( '点击查看个人主页', style: TextStyle( fontSize: 14, color: ColorUtils.textGreyColor), ), ), ], crossAxisAlignment: CrossAxisAlignment.start, ), ], ), ); // 订阅-句子-喜欢 Widget subscribe() => Container( padding: EdgeInsets.only(bottom: 15, left: 15, right: 15), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ columnText('订阅', () => this.pushPage(Subscribes())), SizedBox( width: 1, height: 25, child: Container(color: ColorUtils.dividerColor)), columnText('句子', () => {}), SizedBox( width: 1, height: 25, child: Container(color: ColorUtils.dividerColor)), columnText('喜欢', () => {}), ])); Widget columnText(String title, VoidCallback onTap) => GestureDetector( child: Column( children: <Widget>[ Text('0', style: TextStyle(fontSize: 16)), Text( title, style: TextStyle(fontSize: 14, color: ColorUtils.textGreyColor), ), ], ), onTap: onTap, ); void pushPage(Widget page) { Navigator.push(context, MaterialPageRoute(builder: (context) => page)); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, body: SafeArea( child: ListView( children: <Widget>[ header(), subscribe(), Blank(), ListCell( title: '我的消息', leading: Icons.add_alert, trailing: Icons.arrow_forward_ios, isDivider: true, onTap: () => this.pushPage(MessagePage()), ), ListCell( title: '我的收藏夹', leading: Icons.bookmark, trailing: Icons.arrow_forward_ios, isDivider: true, onTap: () => debugPrint('点击'), ), ListCell( title: '我的评论', leading: Icons.insert_comment, trailing: Icons.arrow_forward_ios, onTap: () => debugPrint('点击'), ), Blank(), ListCell( title: '常见问题', leading: Icons.assistant_photo, trailing: Icons.arrow_forward_ios, isDivider: true, onTap: () => debugPrint('点击'), ), ListCell( title: '我要反馈', leading: Icons.feedback, trailing: Icons.arrow_forward_ios, isDivider: true, onTap: () => debugPrint('点击'), ), ListCell( title: '推荐句读', leading: Icons.thumb_up, trailing: Icons.arrow_forward_ios, onTap: () => debugPrint('点击'), ), Blank(), ListCell( title: '设置', leading: Icons.settings, trailing: Icons.arrow_forward_ios, onTap: () => debugPrint('点击'), ), Blank(), ], ), top: true, ), ); } }
0
mirrored_repositories/judou/lib/profile
mirrored_repositories/judou/lib/profile/pages/subscribes_page.dart
import 'package:flutter/material.dart'; import '../../utils/ui_util.dart'; import '../../widgets/end_cell.dart'; import '../widgets/subscribes_cell.dart'; class Subscribes extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBarUtils.appBar('我的订阅', context), body: ListView.builder( itemBuilder: (context, index) { if (index == 9) { return EndCell(); } return SubscribesCell(); }, itemCount: 10, ), ); } }
0
mirrored_repositories/judou/lib/profile
mirrored_repositories/judou/lib/profile/models/collections_model.dart
class CollectionModel { final int id; final String name; final bool isDefault; final bool isSelf; final String type; final String description; final String sentencesCount; final String cover; CollectionModel({ this.id, this.name, this.isDefault, this.isSelf, this.type, this.description, this.sentencesCount, this.cover, }); factory CollectionModel.fromJSON(Map<String, dynamic> json) { return CollectionModel( id: json['id'], name: json['name'], isDefault: json['is_default'], isSelf: json['is_self'], type: json['type'], description: json['description'], sentencesCount: json['sentences_count'], cover: json['cover']); } }
0
mirrored_repositories/judou/lib/profile
mirrored_repositories/judou/lib/profile/Bloc/profile_detail_bloc.dart
import 'dart:async'; import '../../bloc_provider.dart'; import '../../network/network.dart'; import '../models/collections_model.dart'; import '../../index/models/judou_model.dart'; class ProfileDetailBloc implements BlocBase { int type = 0; PublishSubject<Map<String, dynamic>> _dataSubject = PublishSubject(); /// prfile header wiget type /// 0 Normal /// 1 Verify /// 2 Topics ProfileDetailBloc(int type, String id) { this.type = type; _fetchData(type, id); } Stream<Map<String, dynamic>> get stream => _dataSubject.stream; void _fetchData(int type, String id) async { switch (type) { case 0: { _fetchUserInfo(id); } break; case 1: { _fetchAuthorInfo(id); } break; case 2: { _fetchTopicsInfo(id); } break; } } _fetchUserInfo(String uid) async { Map<String, dynamic> header = await Request.instance.dio .get(RequestPath.userInfo(uid)) .then((response) => response.data); List<JuDouModel> sentences = await Request.instance.dio .get(RequestPath.userInfoSentences(uid)) .then((response) => response.data['data'] as List) .then((response) => response.where((item) => !item['is_ad']).toList()) .then((response) => response.map((item) => JuDouModel.fromJson(item)).toList()); List<CollectionModel> collections = await Request.instance.dio .get(RequestPath.userInfoCollections(uid)) .then((response) => response.data['data'] as List) .then((response) => response.map((item) => CollectionModel.fromJSON(item)).toList()); if (!_dataSubject.isClosed) { _dataSubject.sink.add({ 'header': header, 'sentences': sentences, 'collections': collections, }); } } _fetchAuthorInfo(String uid) async { Map<String, dynamic> user = await Request.instance.dio .get(RequestPath.authorInfo(uid)) .then((response) => response.data); List<JuDouModel> sentences = await Request.instance.dio .get(RequestPath.authorInfoLatest(uid)) .then((response) => response.data['data'] as List) .then((response) => response.where((item) => !item['is_ad']).toList()) .then((response) => response.map((item) => JuDouModel.fromJson(item)).toList()); List<JuDouModel> hot = await Request.instance.dio .get(RequestPath.authorInfoHot(uid)) .then((response) => response.data['data'] as List) .then((response) => response.where((item) => !item['is_ad']).toList()) .then((response) => response.map((item) => JuDouModel.fromJson(item)).toList()); if (!_dataSubject.isClosed) { _dataSubject.sink.add({ 'header': user, 'sentences': sentences, 'collections': hot, }); } } _fetchTopicsInfo(String uid) async { Map<String, dynamic> user = await Request.instance.dio .get(RequestPath.topicsInfo(uid)) .then((response) => response.data); List<JuDouModel> sentences = await Request.instance.dio .get(RequestPath.topicsInfoLatest(uid)) .then((response) => response.data['data'] as List) .then((response) => response.where((item) => !item['is_ad']).toList()) .then((response) => response.map((item) => JuDouModel.fromJson(item)).toList()); List<JuDouModel> hot = await Request.instance.dio .get(RequestPath.topicsInfoHot(uid)) .then((response) => response.data['data'] as List) .then((response) => response.where((item) => !item['is_ad']).toList()) .then((response) => response.map((item) => JuDouModel.fromJson(item)).toList()); if (!_dataSubject.isClosed) { _dataSubject.sink.add({ 'header': user, 'sentences': sentences, 'collections': hot, }); } } @override dispose() { if (!_dataSubject.isClosed) { _dataSubject.close(); } } }
0
mirrored_repositories/judou/lib/discovery
mirrored_repositories/judou/lib/discovery/pages/discovery_page.dart
import './include_page.dart'; import '../../utils/color_util.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import '../widget/subscribe_widget.dart'; import '../widget/recommand_widget.dart'; import '../widget/discovery_widget.dart'; import 'package:page_transition/page_transition.dart'; class DiscoveryPage extends StatefulWidget { @override _DiscoveryPageState createState() => _DiscoveryPageState(); } class _DiscoveryPageState extends State<DiscoveryPage> with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { TabController _topController; List<Tab> tabs = [Tab(text: '订阅'), Tab(text: '发现'), Tab(text: '推荐')]; @override void initState() { super.initState(); _topController = TabController(vsync: this, length: 3); _topController.index = 1; } @override bool get wantKeepAlive => true; @override void dispose() { _topController.dispose(); super.dispose(); } void _toIncludePage() { Navigator.of(context).push(PageTransition( type: PageTransitionType.downToUp, child: IncludePage(), )); } @override Widget build(BuildContext context) { super.build(context); return Scaffold( appBar: AppBar( centerTitle: true, title: TabBar( controller: _topController, tabs: tabs, indicatorColor: Colors.yellow, indicatorSize: TabBarIndicatorSize.label, unselectedLabelColor: ColorUtils.textGreyColor, labelStyle: TextStyle(fontSize: 16), labelPadding: EdgeInsets.symmetric(horizontal: 4), ), actions: <Widget>[ IconButton( icon: Icon(Icons.search), onPressed: () => print('搜索'), ), ], ), body: TabBarView( controller: _topController, children: <Widget>[ DiscoverySubscribe(), Discovery(), DiscoveryRecommand() ], ), floatingActionButton: Container( width: 40, height: 40, decoration: BoxDecoration( shape: BoxShape.rectangle, color: ColorUtils.textPrimaryColor, borderRadius: BorderRadius.circular(20), ), child: IconButton( icon: Icon(Icons.add), color: Colors.white, onPressed: _toIncludePage, ), ), ); } }
0
mirrored_repositories/judou/lib/discovery
mirrored_repositories/judou/lib/discovery/pages/include_page.dart
import 'package:flutter/material.dart'; class IncludePage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('收录'), leading: IconButton( icon: Icon(Icons.close), onPressed: () => Navigator.pop(context), ), ), body: Center( child: Text('收录句子'), ), ); } }
0
mirrored_repositories/judou/lib/discovery
mirrored_repositories/judou/lib/discovery/models/carousel_model.dart
class CarouselModel { final int id; final String title; final String summary; final String cover; final String schemeUrl; final String actionType; final int weight; final String createdAt; CarouselModel({ this.id, this.title, this.summary, this.cover, this.schemeUrl, this.actionType, this.weight, this.createdAt, }); factory CarouselModel.fromJSON(Map<String, dynamic> json) { return CarouselModel( id: json['id'], title: json['title'], summary: json['summary'], cover: json['cover'], schemeUrl: json['scheme_url'], actionType: json['action_type'], weight: json['weight'], createdAt: json['created_at'], ); } }
0
mirrored_repositories/judou/lib/discovery
mirrored_repositories/judou/lib/discovery/models/subject_model.dart
// "id": 124, // "uuid": "3e18be3f-3994-4e51-a3ee-f26955fc40c0", // "title": "哪一句话,让你突然就放弃Ta了?", // "summary": "你有没有喜欢过一个人,很久很久,以为自己会一直坚持下去,结果却在多年后的某一天,因为Ta或者别人的一句话,你就突然释怀了,选择了放弃。谁都懂坚持的甜蜜,但不是谁能理解放手的心酸。", // "attendees_count": 488, // "comments_count": 318, // "published_at": "2019-01-07T00:00:00.000+08:00", // "share_url": "http://m.judouapp.com/subjects/124", // "cover": "https://judou.oss-cn-beijing.aliyuncs.com/images/subject/2019/1/2/inx9nz81.jpeg", // "hits": 8 class SubjectModel { final int id; final String title; final String uuid; final int attendeesCount; final int commentsCount; final String summary; final String cover; final int hits; final String shareUrl; final String publishedAt; SubjectModel({ this.id, this.title, this.uuid, this.attendeesCount, this.commentsCount, this.summary, this.cover, this.hits, this.shareUrl, this.publishedAt, }); factory SubjectModel.fromJSON(Map<String, dynamic> json) { return SubjectModel( id: json['id'], title: json['title'], uuid: json['uuid'], attendeesCount: json['attendees_count'], commentsCount: json['comments_count'], summary: json['summary'], cover: json['cover'], hits: json['hits'], shareUrl: json['share_url'], publishedAt: json['published_at'], ); } }
0
mirrored_repositories/judou/lib/discovery
mirrored_repositories/judou/lib/discovery/models/post_model.dart
// "id": 547, // "summary": "我也许感到有一点寂寞,回想我刚才瞥见的这种幸福家庭生活,心里不无艳羡之感。", // "banner": "https://judou.oss-cn-beijing.aliyuncs.com/images/post/2019/1/7/ablrxblg5.jpeg", // "author": "毛姆", // "is_show_banner": true, // "published_at": "2019-01-09T00:00:00.000+08:00", // "title": "幸福", // "url": "https://judouapp.com/p/547", // "hits": 258, // "comment_count": 3, // "like_count": 6, // "is_liked": false, // "is_disabled_comment": false class PostModel { final int id; final String title; final int commentCount; final int hits; final String author; final String summary; final String banner; final String url; final int likeCount; final bool isLiked; final String publishedAt; PostModel({ this.id, this.title, this.author, this.commentCount, this.likeCount, this.summary, this.banner, this.url, this.hits, this.isLiked, this.publishedAt, }); factory PostModel.fromJSON(Map<String, dynamic> json) { return PostModel( id: json['id'], title: json['title'], author: json['author'], commentCount: json['comment_count'], likeCount: json['like_count'], summary: json['summary'], banner: json['banner'], url: json['url'], hits: json['hits'], isLiked: json['is_liked'], publishedAt: json['published_at'], ); } }
0
mirrored_repositories/judou/lib/discovery
mirrored_repositories/judou/lib/discovery/models/video_model.dart
// "id": 58, // "title": "分享才是快乐的意义", // "source": "", // "source_link": "", // "is_published": true, // "comments_count": 1, // "likes_count": 0, // "video_length": 339, // "summary": "短片中的主人公每天重复着同样的生活,也包括天天买彩票都中头奖。当他明白和他人分享才能获得快乐之前,他已经对于天天中头奖这件事感到厌倦了。你心里的 OS 是不是:他不要放着我来!", // "cover": "https://judou.oss-cn-beijing.aliyuncs.com/images/video/2019/1/3/1p33xa522u.jpeg", // "orig_source": "http://video.judouapp.com/sv/33e01ad-16812081b1e/33e01ad-16812081b1e.mp4?auth_key=1547040618-0-0-8a5d82ba60d7a30de4873862930a5814", // "user": null, // "share_url": "https://judouapp.com", // "like_count": 9, // "is_liked": false class VideoModel { final int id; final String title; final String source; final String sourceLink; final bool isPublished; final int commentsCount; final int likesCount; final int videoLength; final String summary; final String cover; final String origSource; final String shareUrl; final int likeCount; final bool isLiked; VideoModel({ this.id, this.title, this.source, this.sourceLink, this.isPublished, this.commentsCount, this.likeCount, this.videoLength, this.summary, this.cover, this.origSource, this.shareUrl, this.likesCount, this.isLiked, }); factory VideoModel.fromJSON(Map<String, dynamic> json) { return VideoModel( id: json['id'], title: json['title'], source: json['source'], sourceLink: json['source_link'], isPublished: json['is_published'], commentsCount: json['comments_count'], likeCount: json['like_count'], videoLength: json['video_length'], summary: json['summary'], cover: json['cover'], origSource: json['orig_source'], shareUrl: json['share_url'], likesCount: json['likes_count'], isLiked: json['is_liked'], ); } }
0
mirrored_repositories/judou/lib/discovery
mirrored_repositories/judou/lib/discovery/models/topic_model.dart
class TopicModel { final String schemeUrl; final String name; final String uuid; final String cover; final String description; TopicModel({ this.schemeUrl, this.name, this.uuid, this.cover, this.description, }); factory TopicModel.fromJSON(Map<String, dynamic> json) { return TopicModel( schemeUrl: json['scheme_url'] as String, name: json['name'] as String, uuid: json['uuid'] as String, cover: json['cover'] as String, description: json['description'] as String, ); } }
0
mirrored_repositories/judou/lib/discovery
mirrored_repositories/judou/lib/discovery/models/jotting_model.dart
class JuttingModel { final String summary; final int id; final String author; final int hits; final String publishedAt; final String uuid; final String title; final String url; final String banner; final bool isShowBanner; JuttingModel( {this.summary, this.id, this.author, this.hits, this.publishedAt, this.uuid, this.title, this.url, this.banner, this.isShowBanner}); factory JuttingModel.fromJSON(Map<String, dynamic> json) { return JuttingModel( summary: json['summary'] as String, id: json['id'] as int, author: json['author'] as String, hits: json['hits'] as int, publishedAt: json['published_at'] as String, uuid: json['uuid'] as String, title: json['title'] as String, url: json['url'] as String, banner: json['banner'] as String, isShowBanner: json['is_show_banner'] as bool, ); } }
0
mirrored_repositories/judou/lib/discovery
mirrored_repositories/judou/lib/discovery/models/tabs_model.dart
class TabModel { final int id; final String name; TabModel({this.id, this.name}); factory TabModel.fromJSON(Map<String, dynamic> json) { return TabModel(id: json['id'] as int, name: json['name'] as String); } }
0
mirrored_repositories/judou/lib/discovery
mirrored_repositories/judou/lib/discovery/widget/topic_header.dart
// 话题列表页header import 'dart:ui'; import '../../utils/ui_util.dart'; import '../../widgets/blank.dart'; import 'package:flutter/material.dart'; class TopicsHeader extends StatelessWidget { TopicsHeader({this.data}); final Map<String, dynamic> data; @override Widget build(BuildContext context) { final sreenWidth = MediaQuery.of(context).size.width; TextStyle textStyle(double size) { return TextStyle( color: Colors.black, fontSize: size, fontWeight: FontWeight.w300, letterSpacing: 1); } return Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Container( width: sreenWidth, height: DeviceUtils.iPhoneXAbove(context) ? 190 : 170, child: Image.network( data['cover'], fit: BoxFit.cover, ), ), Container( padding: EdgeInsets.all(15), height: 90, child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( data['name'], style: textStyle(16), textAlign: TextAlign.left, ), Text( data['description'], style: textStyle(13), textAlign: TextAlign.left, maxLines: 2, softWrap: true, overflow: TextOverflow.ellipsis, ) ], ), ), Blank() ], ); } }
0
mirrored_repositories/judou/lib/discovery
mirrored_repositories/judou/lib/discovery/widget/recommand_cell.dart
import '../../widgets/blank.dart'; import '../../utils/color_util.dart'; import 'package:flutter/material.dart'; import '../../widgets/radius_image.dart'; final TextStyle _textStyle = TextStyle(fontSize: 12, color: ColorUtils.textGreyColor); class RecommandCell extends StatelessWidget { RecommandCell({ this.isVideo, this.imageUrl, this.title, this.subTitle, this.content, }); final bool isVideo; final String imageUrl; final String title; final String subTitle; final String content; @override Widget build(BuildContext context) { return Column( children: <Widget>[ Row( children: <Widget>[ Stack( children: <Widget>[ RadiusImage( imageUrl: imageUrl, width: 100, height: 70, radius: 0, ), isVideo ? Positioned( left: 38, top: 23, child: Icon( Icons.play_circle_filled, color: Colors.white54, )) : Container() ], ), Container( width: MediaQuery.of(context).size.width - 145, padding: EdgeInsets.only(left: 15), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Padding( child: Text( title, style: TextStyle(fontSize: 14), maxLines: 1, softWrap: true, overflow: TextOverflow.ellipsis, ), padding: EdgeInsets.only(bottom: 3), ), Padding( padding: EdgeInsets.only(bottom: 3), child: Text( '$subTitle 著', style: _textStyle, maxLines: 2, softWrap: true, overflow: TextOverflow.ellipsis, ), ), Text( content, style: _textStyle, maxLines: 2, softWrap: true, overflow: TextOverflow.ellipsis, ), ], ), ), ], ), Blank(color: Colors.white, height: 15), ], ); } }
0
mirrored_repositories/judou/lib/discovery
mirrored_repositories/judou/lib/discovery/widget/recommand_widget.dart
import './discovery_card.dart'; import './recommand_cell.dart'; import '../../bloc_provider.dart'; import '../../widgets/blank.dart'; import '../models/post_model.dart'; import '../models/video_model.dart'; import '../../widgets/loading.dart'; import '../BLoc/recommand_bloc.dart'; import '../../utils/color_util.dart'; import '../models/subject_model.dart'; import '../models/carousel_model.dart'; import 'package:flutter/material.dart'; import '../../index/models/judou_model.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; final TextStyle _textStyle = TextStyle(fontSize: 12, color: ColorUtils.textGreyColor); class DiscoveryRecommand extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( bloc: RecommandBloc(), child: RecommandWidget(), ); } } class RecommandWidget extends StatefulWidget { @override _RecommandWidgetState createState() => _RecommandWidgetState(); } class _RecommandWidgetState extends State<RecommandWidget> with AutomaticKeepAliveClientMixin { RecommandBloc bloc; @override void initState() { super.initState(); bloc = BlocProvider.of<RecommandBloc>(context); } @override void dispose() { bloc.dispose(); super.dispose(); } @override bool get wantKeepAlive => true; @override Widget build(BuildContext context) { super.build(context); return StreamBuilder( stream: bloc.stream, builder: (context, snapshot) { if (snapshot.connectionState != ConnectionState.active) { return Loading(); } List<CarouselModel> carousels = snapshot.data['carousels'] as List; return Container( color: Colors.white, child: ListView( children: <Widget>[ SizedBox( width: MediaQuery.of(context).size.width, height: 180, child: Swiper( itemBuilder: (context, index) { return Image.network( carousels[index].cover, fit: BoxFit.cover, ); }, itemCount: carousels.length, autoplay: true, outer: false, controller: SwiperController(), ), ), Blank(height: 10), _RecommandThink(models: snapshot.data['today']), Blank(height: 10), _SectionTitle(title: '文章', moreAction: () => print('更多')), _ArticleList(posts: snapshot.data['posts']), Blank(height: 10), _SectionTitle(title: '话题', moreAction: () => print('更多')), _SubjectList(subjects: snapshot.data['subjects']), Blank(height: 10), _SectionTitle(title: '视频', moreAction: () => print('更多')), _VideoList(videos: snapshot.data['videos']), Blank(height: 10), ], ), ); }, ); } } class _RecommandThink extends StatelessWidget { /// [onTap] 点击回调 _RecommandThink({this.onTap, this.models}); final VoidCallback onTap; final List<JuDouModel> models; @override Widget build(BuildContext context) { return Container( height: 180, padding: EdgeInsets.all(10), child: GestureDetector( onTap: onTap, child: Container( height: 180, padding: EdgeInsets.symmetric(vertical: 10, horizontal: 15), decoration: BoxDecoration( border: Border.all(color: ColorUtils.dividerColor, width: 0.5), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text( '今日哲思', style: TextStyle(fontSize: 25.0, fontFamily: 'LiSung'), ), IconButton( icon: Icon(Icons.share), color: ColorUtils.iconColor, onPressed: () => print('分享今日哲思'), ), ], ), Text( '${models[0].content}', style: TextStyle(color: ColorUtils.textPrimaryColor), ), Align( alignment: Alignment.bottomRight, child: Text( '${models[0].subHeading}', style: TextStyle(color: ColorUtils.textPrimaryColor), ), ) ], ), ), ), ); } } class _ArticleList extends StatelessWidget { _ArticleList({this.posts}); final List<PostModel> posts; @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.symmetric(horizontal: 15), child: Column( children: posts .map((item) => RecommandCell( isVideo: false, title: item.title, subTitle: item.author, content: item.summary, imageUrl: item.banner, )) .toList(), ), ); } } class _SubjectList extends StatelessWidget { _SubjectList({this.subjects}); final List<SubjectModel> subjects; @override Widget build(BuildContext context) { return Container( height: 90, padding: EdgeInsets.only(bottom: 10), child: ListView.builder( scrollDirection: Axis.horizontal, itemCount: subjects.length, physics: AlwaysScrollableScrollPhysics(), itemBuilder: ((context, index) { SubjectModel model = subjects[index]; return DiscoveryCard( isLeading: index == 0, isTrailing: index == subjects.length - 1, title: model.title, imageUrl: model.cover, height: 90, width: 150, ); }), ), ); } } class _VideoList extends StatelessWidget { _VideoList({this.videos}); final List<VideoModel> videos; @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.symmetric(horizontal: 15), child: Column( children: videos .map((item) => RecommandCell( isVideo: true, title: item.title, subTitle: item.summary, content: '时长: ${item.videoLength}', imageUrl: item.cover, )) .toList(), ), ); } } class _SectionTitle extends StatelessWidget { _SectionTitle({ this.title, this.moreAction, }); final String title; final VoidCallback moreAction; @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.symmetric(horizontal: 15), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text( title, style: TextStyle(fontSize: 18), ), FlatButton( child: Text('更多', style: _textStyle), onPressed: moreAction, ) ], ), ); } }
0
mirrored_repositories/judou/lib/discovery
mirrored_repositories/judou/lib/discovery/widget/discovery_widget.dart
import './discovery_card.dart'; import '../../widgets/blank.dart'; import '../../bloc_provider.dart'; import '../../widgets/loading.dart'; import '../models/topic_model.dart'; import '../BLoc/discovery_bloc.dart'; import '../../utils/color_util.dart'; import 'package:flutter/material.dart'; import '../../widgets/judou_cell.dart'; import '../../index/models/tag_model.dart'; import '../../index/models/judou_model.dart'; class Discovery extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( bloc: DiscoveryBloc(), child: DiscoveryWidget(), ); } } class DiscoveryWidget extends StatefulWidget { @override _DiscoveryWidgetState createState() => _DiscoveryWidgetState(); } class _DiscoveryWidgetState extends State<DiscoveryWidget> with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { ScrollController _scrollController; TabController _controller; DiscoveryBloc _bloc; @override void initState() { super.initState(); _bloc = BlocProvider.of<DiscoveryBloc>(context); _scrollController = ScrollController(); _scrollController.addListener(_scrollListener); _controller = TabController(vsync: this, length: 9); _controller.addListener(() { if (_controller.indexIsChanging) { _bloc.fetchTagListDataWithId('${_bloc.tags[_controller.index].id}'); } }); } @override bool get wantKeepAlive => true; @override void dispose() { _controller.dispose(); _bloc.dispose(); super.dispose(); } _scrollListener() { // print(_scrollController.position.extentInside); } List<Tab> _tagWidgets(List<TagModel> tags) { return tags .map((item) => Tab( text: item.name, )) .toList(); } List<Widget> _tabBarViews(List<TagModel> tags, List<JuDouModel> tagListData) { return _tagWidgets(tags).map( (item) { return ListView.builder( itemBuilder: (context, index) => JuDouCell( model: tagListData[index], divider: Blank(height: 10), tag: 'discovery$index', isCell: true, ), itemCount: tagListData.length, physics: AlwaysScrollableScrollPhysics(), controller: _scrollController, ); }, ).toList(); } @override Widget build(BuildContext context) { super.build(context); return StreamBuilder( stream: _bloc.stream, builder: (context, snapshot) { if (snapshot.connectionState != ConnectionState.active) { return Loading(); } else { return Container( color: Colors.white, child: Column( children: <Widget>[ _DiscoverTopicsWidget( topics: snapshot.data['topics'], ), Blank(height: 5), Container( height: 35, child: TabBar( isScrollable: true, controller: _controller, tabs: _tagWidgets(snapshot.data['tags']), indicatorSize: TabBarIndicatorSize.label, indicatorColor: Colors.white, unselectedLabelColor: ColorUtils.textGreyColor, labelColor: ColorUtils.textPrimaryColor, labelStyle: TextStyle(fontSize: 14), ), ), Blank(height: 1), Expanded( child: TabBarView( controller: _controller, children: _tabBarViews( snapshot.data['tags'], snapshot.data['tagListData'], ), ), ) ], ), ); } }, ); } } class _DiscoverTopicsWidget extends StatelessWidget { _DiscoverTopicsWidget({this.topics}); final List<TopicModel> topics; @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.only(top: 15, bottom: 15), height: 100, color: Colors.white, child: ListView.builder( scrollDirection: Axis.horizontal, itemCount: topics.length, physics: AlwaysScrollableScrollPhysics(), itemBuilder: ((context, index) { TopicModel model = topics[index]; return DiscoveryCard( isLeading: index == 0, isTrailing: index == topics.length - 1, title: model.name, imageUrl: model.cover, height: 70, width: 100, id: model.uuid, ); }), ), ); } }
0
mirrored_repositories/judou/lib/discovery
mirrored_repositories/judou/lib/discovery/widget/discovery_card.dart
import 'package:flutter/material.dart'; import '../../widgets/radius_image.dart'; import '../../profile/pages/profile_detail.dart'; class DiscoveryCard extends StatelessWidget { DiscoveryCard({ Key key, this.isLeading, this.isTrailing, this.title, this.imageUrl, this.height, this.width, this.id, }) : super(key: key); final bool isLeading; final bool isTrailing; final String title; final String imageUrl; final double height; final double width; final String id; @override Widget build(BuildContext context) { return Card( margin: EdgeInsets.only(left: isLeading ? 15 : 4, right: isTrailing ? 15 : 4), child: GestureDetector( child: Stack( children: <Widget>[ SizedBox( child: Container( foregroundDecoration: BoxDecoration( gradient: LinearGradient( colors: [ Colors.black, Colors.black26, Colors.black12, Colors.transparent ], begin: Alignment.bottomCenter, end: Alignment.topCenter, ), borderRadius: BorderRadius.all( Radius.circular(3), ), ), width: width, child: RadiusImage( imageUrl: imageUrl, radius: 3, width: width, height: height, ), ), ), Positioned( bottom: 8, left: 8, right: 8, child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Container( width: 84, child: Text( title, style: TextStyle(color: Colors.white, fontSize: 12), textAlign: TextAlign.center, maxLines: 2, ), ) ], ), ), ], ), onTap: () { Navigator.push( context, MaterialPageRoute( builder: (_) => ProfileDetailPage(type: 2, id: id)), ); }, ), ); } }
0
mirrored_repositories/judou/lib/discovery
mirrored_repositories/judou/lib/discovery/widget/subscribe_widget.dart
import '../../bloc_provider.dart'; import '../../widgets/blank.dart'; import '../../widgets/loading.dart'; import '../BLoc/subscribe_bloc.dart'; import 'package:flutter/material.dart'; import '../../widgets/judou_cell.dart'; import '../../index/models/judou_model.dart'; class DiscoverySubscribe extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( bloc: SubscribeBloc(), child: SubscribeWidget(), ); } } class SubscribeWidget extends StatefulWidget { @override _SubscribeWidgetState createState() => _SubscribeWidgetState(); } class _SubscribeWidgetState extends State<SubscribeWidget> with AutomaticKeepAliveClientMixin { SubscribeBloc bloc; @override void initState() { super.initState(); bloc = BlocProvider.of<SubscribeBloc>(context); } @override bool get wantKeepAlive => true; @override void dispose() { bloc.dispose(); super.dispose(); } @override Widget build(BuildContext context) { super.build(context); return StreamBuilder( stream: bloc.stream, builder: (context, AsyncSnapshot<List<JuDouModel>> snapshot) { List<JuDouModel> dataList = snapshot.data; if (snapshot.connectionState != ConnectionState.active) { return Center( child: Loading(), ); } return ListView.builder( itemBuilder: (context, index) => JuDouCell( model: dataList[index], tag: 'DiscoveryPageSubscribe$index', divider: Blank(), isCell: true, ), itemCount: dataList.length, physics: AlwaysScrollableScrollPhysics(), ); }, ); } }
0
mirrored_repositories/judou/lib/discovery
mirrored_repositories/judou/lib/discovery/BLoc/subscribe_bloc.dart
import 'dart:async'; import '../../network/network.dart'; import '../../index/pages/detail_page.dart'; import 'package:flutter/material.dart'; import '../../index/models/judou_model.dart'; class SubscribeBloc implements BlocBase { final _fetchSubject = PublishSubject<List<JuDouModel>>(); SubscribeBloc() { this._fetchData(); } Stream<List<JuDouModel>> get stream => _fetchSubject.stream; void _fetchData() async { List<JuDouModel> dataList = await Request.instance.dio .get(RequestPath.channelWithId('12')) .then((response) => response.data['data'] as List) .then((response) => response.where((item) => !item['is_ad']).toList()) .then((response) => response.map((item) => JuDouModel.fromJson(item)).toList()); if (!_fetchSubject.isClosed) { _fetchSubject.sink.add(dataList); } } /// to detail page void toDetailPage(BuildContext context, JuDouModel model) { Navigator.push( context, MaterialPageRoute(builder: (context) => DetailPage(model: model)), ); } @override dispose() { if (!_fetchSubject.isClosed) _fetchSubject.close(); } }
0