repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/flutter-examples/using_listwheelscrollview
mirrored_repositories/flutter-examples/using_listwheelscrollview/lib/listwheel.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'roundcontainer.dart'; class Listwheel extends StatefulWidget { @override _ListwheelState createState() => _ListwheelState(); } class _ListwheelState extends State<Listwheel> { double size = 28; int radius = 8; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white70, body: Container( child: ListWheelScrollView( children: [ NewWidget( size: size, l: Icon( Icons.brush, color: Colors.white54, size: size, ), s: 'Brush'), NewWidget( size: size, l: Icon( Icons.style, color: Colors.white54, size: size, ), s: 'Style'), NewWidget( size: size, l: Icon( Icons.build, color: Colors.white54, size: size, ), s: 'Build'), NewWidget( size: size, l: Icon( Icons.add, color: Colors.white54, size: size, ), s: 'Add'), NewWidget( size: size, l: Icon( Icons.delete, color: Colors.white54, size: size, ), s: 'Delete'), NewWidget( size: size, l: Icon( Icons.details, color: Colors.white54, size: size, ), s: 'Details'), NewWidget( size: size, l: Icon( Icons.email, color: Colors.white54, size: size, ), s: 'Email'), ], squeeze: 1.0, itemExtent: 180, diameterRatio: 1.9, offAxisFraction: -0.5, ), ), ); } }
0
mirrored_repositories/flutter-examples/using_listwheelscrollview
mirrored_repositories/flutter-examples/using_listwheelscrollview/lib/main.dart
import 'package:flutter/material.dart'; import 'listwheel.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData.dark().copyWith( scaffoldBackgroundColor: Color(0XFF0A0E21), ), home: Listwheel(), ); } }
0
mirrored_repositories/flutter-examples/using_listwheelscrollview
mirrored_repositories/flutter-examples/using_listwheelscrollview/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:usinglistwheelscrollview/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/flutter-examples/analytics_integration
mirrored_repositories/flutter-examples/analytics_integration/lib/single_item_tile.dart
import 'package:firebase_analytics/firebase_analytics.dart'; import 'package:flutter/material.dart'; class SingleItemTile extends StatefulWidget { final String price; final String itemName; final double quantity; final FirebaseAnalytics analytics; SingleItemTile({ this.itemName, this.price, this.quantity, this.analytics, }); @override _SingleItemTileState createState() => _SingleItemTileState(); } class _SingleItemTileState extends State<SingleItemTile> { /// [addedToCart] this variable is used to to justify that product is added in /// cart or not bool addedToCart; @override void initState() { addedToCart = false; super.initState(); } @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), border: Border.all( color: Colors.green, ), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Image.asset( 'asset/carrot.jpg', height: 200, width: 400, ), Container( color: Colors.green, height: .5, width: double.infinity, ), Padding( padding: const EdgeInsets.all(16.0) + EdgeInsets.only(left: 8), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( widget.price, style: TextStyle( color: Colors.red[600], fontWeight: FontWeight.bold, fontSize: 18, ), ), Text( widget.itemName, style: TextStyle( color: Colors.black, fontSize: 16, ), ), Text( widget.quantity.toString() + ' kg', style: TextStyle( color: Colors.grey, fontSize: 12, ), ), ], ), InkWell( onTap: () { setState(() { addedToCart = !addedToCart; }); _sendCartEvent(widget.price, widget.itemName, widget.quantity, addedToCart); }, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), border: Border.all( color: Colors.green, ), ), child: Padding( padding: const EdgeInsets.all(12.0), child: Text( addedToCart ? 'Remove from Cart' : 'Add to Cart +', style: TextStyle( color: Colors.red[600], fontWeight: FontWeight.bold, fontSize: 16, ), ), ), ), ), ], ), ), ], ), ); } /// to make custom event in Analytics you can create your own Map /// below in [name] field give your event name identifier /// and in [parameters] filed create your map Future<void> _sendCartEvent( String price, String itemName, double quantity, bool addedToCart) async { await widget.analytics.logEvent( name: 'item', parameters: <String, dynamic>{ 'price': price, 'itemName': itemName, 'quantity': quantity, 'bool': addedToCart, }, ); } }
0
mirrored_repositories/flutter-examples/analytics_integration
mirrored_repositories/flutter-examples/analytics_integration/lib/main.dart
import 'package:analytics_integration/single_item_tile.dart'; import 'package:firebase_analytics/firebase_analytics.dart'; import 'package:firebase_analytics/observer.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); /// initialize your firebase project await Firebase.initializeApp(); runApp(FlutterAnalyticsApp()); } class FlutterAnalyticsApp extends StatelessWidget { /// create instance of FirebaseAnalytics as [analytics] static FirebaseAnalytics analytics = FirebaseAnalytics(); /// create observer for FirebaseAnalytics as [observer] /// this observer sends events to Firebase Analytics when the /// currently active route changes. static FirebaseAnalyticsObserver observer = FirebaseAnalyticsObserver(analytics: analytics); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Analytics', debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.blue, visualDensity: VisualDensity.adaptivePlatformDensity, ), /// this is used to observe navigation changes in the app /// and sending data back to Firebase Analytics navigatorObservers: <NavigatorObserver>[observer], home: FlutterAnalyticsHome( title: 'Flutter Analytics', analytics: analytics, observer: observer, ), ); } } class FlutterAnalyticsHome extends StatefulWidget { final String title; final FirebaseAnalytics analytics; final FirebaseAnalyticsObserver observer; FlutterAnalyticsHome({ Key key, this.title, this.analytics, this.observer, }) : super(key: key); @override _FlutterAnalyticsHomeState createState() => _FlutterAnalyticsHomeState(); } class _FlutterAnalyticsHomeState extends State<FlutterAnalyticsHome> { FirebaseAnalytics _analytics; @override void initState() { /// initializing data to local variable [_analytics] for Firebase Analytics /// that we made before for local use _analytics = widget.analytics; //// below three events are related to user which we are //// sending to Firebase Analytics _setUserIdInAnalytics(); _setUserPropertyInAnalytics(); _currentScreen(); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: AppBar( title: Center( child: Text(widget.title), ), ), body: Padding( padding: const EdgeInsets.all(16.0), child: ListView( shrinkWrap: true, children: <Widget>[ SizedBox( height: 16, ), SingleItemTile( itemName: 'Carrot', analytics: _analytics, quantity: 1, price: '100Rs', ), SizedBox( height: 16, ), SingleItemTile( itemName: 'Baby Carrot', analytics: _analytics, quantity: .5, price: '50Rs', ), SizedBox( height: 16, ), ], ), ), ); } //// to create a unique user identifier for Analytics //// send user id(if you app has) Future<void> _setUserIdInAnalytics() async { await _analytics.setUserId('alksj39hnfn49skvnghqwp40sm'); } //// sending user related field to Analytics /// below [name] is the name of the user property to set /// [value] is the values of that property Future<void> _setUserPropertyInAnalytics() async { await _analytics.setUserProperty( name: 'email', value: '[email protected]', ); } /// Setting the current Screen of the app in [screenName] /// and sending back to Analytics Future<void> _currentScreen() async { await _analytics.setCurrentScreen( screenName: 'FlutterAnalyticsHome', screenClassOverride: 'FlutterAnalyticsHome', ); } }
0
mirrored_repositories/flutter-examples/analytics_integration
mirrored_repositories/flutter-examples/analytics_integration/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:analytics_integration/main.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(FlutterAnalyticsApp()); // 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/flutter-examples/firebase_crash_reporting
mirrored_repositories/flutter-examples/firebase_crash_reporting/lib/main.dart
import 'dart:async'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:flutter/material.dart'; main() { WidgetsFlutterBinding.ensureInitialized(); runZonedGuarded(() { runApp(App()); }, (error, stackTrace) { // Pass all uncaught errors from the framework to Crashlytics. FirebaseCrashlytics.instance.recordError(error, stackTrace); }); } class App extends StatelessWidget { //initialise firebase and crashlytics Future<void> _initializeFirebase() async { await Firebase.initializeApp(); await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true); } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: Text("Crash App"), ), body: FutureBuilder( future: _initializeFirebase(), builder: (context, snapshot) { if (snapshot.hasError) { return Center( child: Text("Unable to initialise Firebase"), ); } //firebase and crashlytics initialise complete if (snapshot.connectionState == ConnectionState.done) { return CrashApp(); } return Center( child: Column( children: [ CircularProgressIndicator(), Text("Initialising Firebase") ], ), ); }, ), ), ); } } class CrashApp extends StatelessWidget { @override Widget build(BuildContext context) { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ ElevatedButton( onPressed: () { //custom Crashlytics log message FirebaseCrashlytics.instance.log("It's a bug"); }, child: Text("Custom Log")), const SizedBox(height: 10), ElevatedButton( child: Text('Crash the app'), onPressed: () { FirebaseCrashlytics.instance.crash(); }, ), ], ), ); } }
0
mirrored_repositories/Hotel-Lapallise-App
mirrored_repositories/Hotel-Lapallise-App/lib/main.dart
import 'package:flutter/material.dart'; const Color mainThemeColor = Color(0xFF272D8D); final List<Attraction> attractionsList = [ Attraction( imgPath: 'https://cf.bstatic.com/xdata/images/hotel/max1024x768/275162028.jpg?k=38b638c8ec9ec86624f9a598482e95fa634d49aa3f99da1838cf5adde1a14521&o=&hp=1', name: 'Grand Bavaro Princess', desc: 'All-Inclusive Resort', location: 'Punta Cana, DR', rating: 3, price: 80.0), Attraction( imgPath: 'https://cf.bstatic.com/xdata/images/hotel/max1024x768/232161008.jpg?k=27808fe44ab95f6468e5433639bf117032c8271cebf5988bdcaa0a202b9a6d79&o=&hp=1', name: 'Hyatt Ziva Cap Cana', desc: 'All-Inclusive Resort', price: 90.0, rating: 4, location: 'Punta Cana, DR'), Attraction( imgPath: 'https://cf.bstatic.com/xdata/images/hotel/max1024x768/256931299.jpg?k=57b5fb9732cd89f308def5386e221c46e52f48579345325714a310addf819274&o=&hp=1', name: 'Impressive Punta Cana', desc: 'All-Inclusive Resort', price: 100.0, rating: 5, location: 'Punta Cana, DR'), Attraction( imgPath: 'https://cf.bstatic.com/xdata/images/hotel/max1024x768/283750757.jpg?k=4f3437bf1e1b077463c9900e4dd015633db1d96da38f034f4b70a4ba3ef76d82&o=&hp=1', name: 'Villas Mar Azul Dreams', desc: 'All-Inclusive Resort', price: 100.0, rating: 4, location: 'Tallaboa, PR'), ]; // bottom bar list final List<BottomBarItem> barItemsList = [ BottomBarItem(label: 'Home', isSelected: true, icon: Icons.home), BottomBarItem(label: 'Account', isSelected: false, icon: Icons.person), BottomBarItem( label: 'Bookings', isSelected: false, icon: Icons.pending_actions), BottomBarItem(label: 'Payments', isSelected: false, icon: Icons.payments), BottomBarItem(label: 'More', isSelected: false, icon: Icons.more_horiz), ]; void main() { runApp(MaterialApp(debugShowCheckedModeBanner: false, home: SplashPage())); } // The landing page class LandingPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( drawer: Drawer( child: Container( padding: EdgeInsets.all(20), alignment: Alignment.bottomLeft, child: Icon( Icons.pool, color: mainThemeColor, size: 80, ), ), ), body: Stack( children: [ Container( decoration: BoxDecoration( image: DecorationImage( image: NetworkImage( 'https://dynamic-media-cdn.tripadvisor.com/media/photo-o/0e/02/8b/39/hotel-swimming-pool-when.jpg?w=1200&h=-1&s=1'), fit: BoxFit.cover), ), ), Container( color: mainThemeColor.withOpacity(0.7), ), AppBar( backgroundColor: Colors.transparent, elevation: 0, iconTheme: IconThemeData(color: Colors.white), ), Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Text( 'La Palisse Hotel', textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 40), ), SizedBox( height: 60, ), Icon( Icons.pool, color: Colors.white, size: 80, ), SizedBox( height: 10, ), Text("Choose location to".toUpperCase(), textAlign: TextAlign.center, style: TextStyle( color: Colors.white.withOpacity(0.5), )), SizedBox( height: 5, ), Text( "Find a Hotel", textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontSize: 30, fontWeight: FontWeight.bold), ), SizedBox( height: 20, ), LandingSearchBar() ], ) ], )); } } // Landing Search Bar class LandingSearchBar extends StatelessWidget { const LandingSearchBar({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.only(left: 30, right: 30), padding: EdgeInsets.only(top: 5, bottom: 5, left: 20, right: 5), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(50), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( 'Search Room', style: TextStyle(color: Colors.grey), ), GestureDetector( onTap: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) => ListPage())); }, child: Container( width: 30, height: 30, child: Icon( Icons.search, color: Colors.white, size: 15, ), decoration: BoxDecoration( color: mainThemeColor, borderRadius: BorderRadius.circular(25)), ), ) ], ), ); } } class SplashPage extends StatelessWidget { const SplashPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { // delay and navigate to List page Future.delayed(const Duration(seconds: 3), () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) => LandingPage())); }); return Stack( children: [ Container( color: mainThemeColor, ), Align( alignment: Alignment.center, child: Icon( Icons.pool, color: Colors.white, size: 80, ), ), Align( alignment: Alignment.bottomCenter, child: LinearProgressIndicator( valueColor: AlwaysStoppedAnimation<Color>(Colors.white.withOpacity(0.4)), ), ) ], ); } } // Another landing page after splash class ListPage extends StatelessWidget { const ListPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.transparent, iconTheme: IconThemeData(color: Colors.white), elevation: 0, title: Center( child: Icon( Icons.pool, color: Colors.white, ), ), actions: [ Container( margin: EdgeInsets.only(right: 15), child: Icon( Icons.notifications, color: Colors.white, ), ) ], ), backgroundColor: mainThemeColor, body: ClipRRect( borderRadius: const BorderRadius.only( topLeft: Radius.circular(50), topRight: Radius.circular(50), ), child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(50), topRight: Radius.circular(50), ), ), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Expanded( child: ListView.builder( itemCount: attractionsList.length, itemBuilder: (context, index) { Attraction attr = attractionsList[index]; return AttractionCard( attraction: attr, ); }), ), BottomBarWidget() ], ), ), ), ); } } class AttractionCard extends StatelessWidget { Attraction? attraction; AttractionCard({this.attraction}); @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.all(20), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(40), boxShadow: [ BoxShadow( blurRadius: 20, offset: Offset.zero, color: Colors.black.withOpacity(0.1), ), ]), child: ClipRRect( borderRadius: BorderRadius.circular(40), child: Container( height: 300, child: Stack( children: [ Column( children: [ Container( height: 150, decoration: BoxDecoration( image: DecorationImage( image: NetworkImage(attraction!.imgPath!), fit: BoxFit.cover), ), ), Container( height: 150, padding: EdgeInsets.all(20), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( attraction!.name!, style: TextStyle( color: Colors.black, fontSize: 16, fontWeight: FontWeight.bold), ), SizedBox( width: 5, ), Row( children: [ Icon( Icons.pin_drop, color: Colors.grey.withOpacity(0.7), size: 13, ), SizedBox( width: 5, ), Text( attraction!.location!, style: TextStyle( fontSize: 12, fontWeight: FontWeight.bold, color: Colors.grey.withOpacity(0.7)), ) ], ), SizedBox( width: 5, ), RatingWidget( rating: attraction!.rating!, ) ], ), Column( crossAxisAlignment: CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end, children: [ Text( '\$${attraction!.price!.toStringAsFixed(2)}', style: TextStyle( color: Colors.black, fontSize: 16, fontWeight: FontWeight.bold, ), ), SizedBox( height: 5, ), Text( 'Per Night', style: TextStyle( color: Colors.grey.withOpacity(0.7), fontSize: 12, fontWeight: FontWeight.bold, ), ), ], ), ], ), ), ], ), Align( alignment: Alignment.centerRight, child: Container( child: Icon( Icons.favorite, color: Colors.white, size: 16, ), margin: EdgeInsets.only(right: 10), width: 40, height: 40, decoration: BoxDecoration( color: mainThemeColor, borderRadius: BorderRadius.circular(40), boxShadow: [ BoxShadow( blurRadius: 10, color: mainThemeColor.withOpacity(0.5), offset: Offset.zero) ]), ), ) ], ), ), ), ); } } // Bottom Widget bar class BottomBarWidget extends StatefulWidget { @override _BottomBarWidgetState createState() => _BottomBarWidgetState(); } class _BottomBarWidgetState extends State<BottomBarWidget> { List<BottomBarItem> barItems = barItemsList; @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.only( top: 20, left: 20, right: 20, bottom: 15, ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: List.generate(barItems.length, (index) { var barItem = barItems[index]; return GestureDetector( onTap: () { setState(() { barItems.forEach((element) { element.isSelected = barItem == element; }); }); }, child: Column( children: [ Icon(barItem.icon, color: barItem.isSelected! ? mainThemeColor : Colors.grey), Text( barItem.label!, style: TextStyle( color: (barItem.isSelected! ? mainThemeColor : Colors.grey), fontSize: 11), ) ], ), ); }), ), ); } } class RatingWidget extends StatelessWidget { int? rating; RatingWidget({this.rating}); @override Widget build(BuildContext context) { return Row( children: [ Row( children: List.generate(5, (index) { return Icon( index < this.rating! ? Icons.star : Icons.star_border, color: Colors.yellow, ); }), ), SizedBox( width: 5, ), Text( '${this.rating!}/5 Reviews', style: TextStyle( fontSize: 12, color: Colors.grey.withOpacity(0.7), ), ) ], ); } } // bottom bar model class BottomBarItem { String? label; bool? isSelected; IconData? icon; BottomBarItem({this.label, this.isSelected, this.icon}); } class Attraction { String? imgPath; String? name; String? desc; double? price; String? location; int? rating; Attraction( {this.imgPath, this.name, this.desc, this.price, this.location, this.rating}); }
0
mirrored_repositories/docit_v1.0.0
mirrored_repositories/docit_v1.0.0/lib/myHomePage.dart
import 'package:dynamic_theme/dynamic_theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'screens/aboutTab.dart'; import 'screens/homeTab.dart'; import 'screens/settingTab.dart'; class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key); final String title; @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { bool isSwitched = false; void changeBrightness() { DynamicTheme.of(context).setBrightness( Theme.of(context).brightness == Brightness.dark ? Brightness.light : Brightness.dark); } @override Widget build(BuildContext context) { return Stack(children: <Widget>[ Scaffold( backgroundColor: Colors.grey, body: Container( height: MediaQuery.of(context).size.height / 2, width: MediaQuery.of(context).size.width, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: <Color>[Color(0xffad5389), Color(0xff3c1053)])), child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Padding( padding: const EdgeInsets.only(top: 50), child: Text( widget.title, style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, letterSpacing: 5, fontSize: 20), ), ), ], ), ), ), Padding( padding: const EdgeInsets.fromLTRB(10, 110, 10, 10), child: Scaffold( backgroundColor: Colors.transparent, appBar: AppBar( shape: RoundedRectangleBorder( borderRadius: BorderRadius.vertical( top: Radius.circular(10), )), backgroundColor: Theme.of(context).scaffoldBackgroundColor, flexibleSpace: Center( child: TabBar( unselectedLabelColor: Colors.grey, indicatorSize: TabBarIndicatorSize.label, indicator: BoxDecoration( borderRadius: BorderRadius.circular(50), gradient: LinearGradient( colors: [Colors.redAccent, Colors.orangeAccent]), ), tabs: <Widget>[ Tab( child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(50), ), child: Align( alignment: Alignment.center, child: Text("Home"), ), ), ), Tab( child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(50), ), child: Align( alignment: Alignment.center, child: Text("Favourite"), ), ), ), Tab( child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(50), ), child: Align( alignment: Alignment.center, child: Text("Setting"), ), ), ) ], ), ), ), body: Container( decoration: BoxDecoration( borderRadius: BorderRadius.vertical(bottom: Radius.circular(10)), color: Theme.of(context).scaffoldBackgroundColor, ), child: TabBarView( children: <Widget>[HomeTab(), AboutTab(), SettingTab()], ), ), ), ), ]); } } class LightThemeAppbar extends StatelessWidget { const LightThemeAppbar({ Key key, }) : super(key: key); @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: <Color>[Color(0xffad5389), Color(0xff3c1053)])), ); } }
0
mirrored_repositories/docit_v1.0.0
mirrored_repositories/docit_v1.0.0/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:dynamic_theme/dynamic_theme.dart'; import 'package:custom_splash/custom_splash.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; // dart files import import 'myHomePage.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); Function duringSplash = () { print('Dummy Print Statement ....'); int a = 123 + 23; if (a > 100) return 1; else return 2; }; Map<int, Widget> op = {1: MyApp()}; await DotEnv().load('.env'); runApp( MaterialApp( home: Scaffold( backgroundColor: Colors.blue, body: Center( child: CustomSplash( logoSize: 200, backGroundColor: new Color(0xff1874D2), animationEffect: 'fade-in', imagePath: 'assets/images/giphy.gif', home: MyApp(), customFunction: duringSplash, duration: 50, type: CustomSplashType.StaticDuration, outputAndHome: op, ), ), ), ), ); } class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { @override void initState() { super.initState(); } @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, ]); return new DynamicTheme( defaultBrightness: Brightness.light, data: (brightness) => new ThemeData( fontFamily: 'OpenSans', primarySwatch: Colors.deepPurple, tabBarTheme: TabBarTheme( labelColor: Colors.white, unselectedLabelColor: Colors.white38, ), brightness: brightness, accentColor: Colors.white, ), themedWidgetBuilder: (context, theme) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Demo', theme: theme, home: DefaultTabController( length: 3, child: MyHomePage(title: 'DocIT'), ), ); }); } }
0
mirrored_repositories/docit_v1.0.0
mirrored_repositories/docit_v1.0.0/lib/permission.dart
import 'package:permission_handler/permission_handler.dart'; final PermissionHandler _permissionHandler = PermissionHandler(); askpermission() async { await PermissionHandler().requestPermissions([PermissionGroup.storage]); } Future<bool> checkstatus() async { var permissionStatus = await _permissionHandler.checkPermissionStatus(PermissionGroup.storage); if (permissionStatus == PermissionStatus.granted) { return true; } else { return false; } }
0
mirrored_repositories/docit_v1.0.0/lib
mirrored_repositories/docit_v1.0.0/lib/screens/aboutTab.dart
import 'package:docit_v1_0_0/screens/uploadScreen.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; import 'package:shared_preferences/shared_preferences.dart'; class AboutTab extends StatefulWidget { @override _AboutTabState createState() => _AboutTabState(); } class _AboutTabState extends State<AboutTab> { Future<List<String>> listOfFavConversion; @override void initState() { super.initState(); listOfFavConversion = _getList(); } Future<List<String>> _getList() async { SharedPreferences prefs = await SharedPreferences.getInstance(); List<String> resultList = prefs.getStringList("FavList"); if (resultList.isEmpty) { return null; } return resultList; } _removeTile(int index) async { SharedPreferences prefs = await SharedPreferences.getInstance(); List<String> temp = prefs.getStringList("FavList"); temp.removeAt(index); prefs.clear(); await prefs.setStringList("FavList", temp); setState(() { listOfFavConversion = _getList(); }); } @override Widget build(BuildContext context) { return FutureBuilder<List<String>>( future: listOfFavConversion, builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasData && snapshot.data != []) { return Padding( padding: const EdgeInsets.fromLTRB(10, 5, 10, 5), child: ListView.builder( itemCount: snapshot.data.length, itemBuilder: (BuildContext ctxt, int index) { return AnimationConfiguration.staggeredList( position: index, duration: const Duration(milliseconds: 370), child: SlideAnimation( verticalOffset: 50.0, child: FadeInAnimation( child: Theme( data: ThemeData.dark(), child: Card( margin: EdgeInsets.all(10), color: Color(0xff574b90), child: ListTile( contentPadding: EdgeInsets.all(10), leading: IconButton( icon: Icon(Icons.delete), onPressed: () { _removeTile(index); }, ), title: Text(snapshot.data[index]), subtitle: Text('Convert from ${snapshot.data[index]}'), trailing: IconButton( icon: Icon(Icons.arrow_forward_ios), onPressed: () async { List<String> tempList = snapshot.data[index].split(" "); Navigator.push( context, MaterialPageRoute( builder: (context) => UploadScreen( tempList[2], tempList[0]), )).then((value) { setState(() { listOfFavConversion = _getList(); }); }); }, ), ), ), ), ), ), ); }), ); } else if (snapshot.data == null) { return Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Padding( padding: const EdgeInsets.all(10.0), child: Icon( Icons.sentiment_dissatisfied, size: 40, color: Colors.grey, ), ), Text( "List is empty", style: TextStyle(color: Colors.grey, fontSize: 20), ), ], ); } return Center( child: CircularProgressIndicator( backgroundColor: Colors.blueAccent, strokeWidth: 2, ), ); }, ); } }
0
mirrored_repositories/docit_v1.0.0/lib
mirrored_repositories/docit_v1.0.0/lib/screens/downloadPage.dart
import 'package:dio/dio.dart'; import 'package:docit_v1_0_0/screens/ApiEvents/uploadAndDownload.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:path/path.dart' as p; class DownloadPage extends StatefulWidget { final String inputType; final String outputType; final List<String> paths; DownloadPage(this.inputType, this.outputType, this.paths); @override _DownloadPageState createState() => _DownloadPageState(); } class _DownloadPageState extends State<DownloadPage> { Future<List<String>> downloadPaths; Dio dio = new Dio(); @override void initState() { super.initState(); downloadPaths = createUploadJob( widget.inputType, widget.outputType, widget.paths, context); } @override Widget build(BuildContext context) { return Stack( children: <Widget>[ Scaffold( backgroundColor: Colors.grey, body: Container( height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: <Color>[Color(0xffad5389), Color(0xff3c1053)])), child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Padding( padding: const EdgeInsets.only(top: 50), child: Text( "Download", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, letterSpacing: 5, fontSize: 20), ), ), ], ), ), ), Padding( padding: const EdgeInsets.fromLTRB(10, 100, 10, 10), child: Scaffold( backgroundColor: Colors.transparent, body: Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(10)), color: Theme.of(context).scaffoldBackgroundColor, ), child: FutureBuilder<List<String>>( future: downloadPaths, builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasData) { return ListView.builder( itemCount: snapshot.data.length, itemBuilder: (BuildContext context, int index) { return Card( elevation: 20, margin: EdgeInsets.fromLTRB(20, 5, 20, 5), color: Color(0xff5959ab), child: ListTile( leading: Icon( Icons.insert_drive_file, size: 40, color: Colors.white, ), title: Padding( padding: const EdgeInsets.all(8.0), child: Text( p .basename(widget.paths[index]) .split(".")[0] + '.' + widget.outputType, style: TextStyle(color: Colors.white), ), ), subtitle: Align( alignment: Alignment.centerLeft, child: FlatButton.icon( onPressed: () async { String url = snapshot.data[index]; if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } }, icon: Icon( Icons.file_download, color: Colors.white, ), label: Text( "Download", style: TextStyle( color: Colors.white, ), )), ), ), ); }); } else if (snapshot.hasError) { return Center( child: Padding( padding: const EdgeInsets.only(left: 50.0), child: Text( snapshot.error, softWrap: true, ), ), ); } return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ CircularProgressIndicator( backgroundColor: Colors.blueAccent, strokeWidth: 2, ), Padding( padding: const EdgeInsets.only(top: 15), child: Text("Converting Please wait..."), ) ], ), ); }, ), ), ), ), ], ); } }
0
mirrored_repositories/docit_v1.0.0/lib
mirrored_repositories/docit_v1.0.0/lib/screens/settingTab.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:dynamic_theme/dynamic_theme.dart'; import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; class SettingTab extends StatefulWidget { @override _SettingTabState createState() => _SettingTabState(); } class _SettingTabState extends State<SettingTab> { String appName = 'DocIT'; String version = '1.0.0'; @override void initState() { super.initState(); } void lightTheme() { DynamicTheme.of(context).setBrightness(Brightness.light); } void darkTheme() { DynamicTheme.of(context).setBrightness(Brightness.dark); } @override Widget build(BuildContext context) { return AnimationLimiter( child: ListView( children: <Widget>[ AnimationConfiguration.staggeredList( position: 0, duration: const Duration(milliseconds: 640), child: SlideAnimation( verticalOffset: 50.0, child: FadeInAnimation( child: SimpleDialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20.0)), title: const Text('Select Theme'), children: <Widget>[ RadioListTile<Brightness>( activeColor: Colors.deepPurpleAccent, value: Brightness.light, groupValue: Theme.of(context).brightness, onChanged: (Brightness value) { DynamicTheme.of(context).setBrightness(value); }, title: const Text('Light mode 🌞'), ), RadioListTile<Brightness>( activeColor: Colors.deepPurpleAccent, value: Brightness.dark, groupValue: Theme.of(context).brightness, onChanged: (Brightness value) { DynamicTheme.of(context).setBrightness(value); }, title: const Text('Dark Mode 🌙'), ) ], ), ), ), ), AnimationConfiguration.staggeredList( position: 1, duration: const Duration(milliseconds: 640), child: SlideAnimation( verticalOffset: 50.0, child: FadeInAnimation( child: SimpleDialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20.0)), title: const Text('About Us'), contentPadding: EdgeInsets.all(20), children: [ Center( child: Text( "Developed By", style: TextStyle(fontSize: 15.0), ), ), Center( child: Text( "MAYANK", style: TextStyle( fontSize: 17.0, fontWeight: FontWeight.w900), ), ), Center( child: ButtonBar( alignment: MainAxisAlignment.center, children: <Widget>[ FlatButton.icon( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20.0)), color: const Color(0xFF3366FF), icon: Icon(Icons.info), label: Text("About App"), onPressed: () { _showDialog(); }, ), ], ), ) ], ), ), ), ) ], ), ); } void _showDialog() { // flutter defined function showDialog( context: context, builder: (BuildContext context) { // return object of type Dialog return AlertDialog( title: new Text("About App"), content: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisSize: MainAxisSize.min, children: <Widget>[ Padding( padding: const EdgeInsets.only(bottom: 10), child: Image.asset( 'assets/images/icons/logo.png', height: 80, width: 80, fit: BoxFit.fitWidth, ), ), Padding( padding: const EdgeInsets.all(8.0), child: Text("App Name : " + appName), ), Padding( padding: const EdgeInsets.all(8.0), child: Text("Version : " + version), ), ], ), actions: <Widget>[ // usually buttons at the bottom of the dialog new FlatButton( child: new Text("Close"), onPressed: () { Navigator.of(context).pop(); }, ), ], ); }, ); } }
0
mirrored_repositories/docit_v1.0.0/lib
mirrored_repositories/docit_v1.0.0/lib/screens/conversionIOSelection.dart
import 'package:docit_v1_0_0/screens/ApiEvents/getTypeOfFormats.dart'; import 'package:docit_v1_0_0/screens/uploadScreen.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:progress_dialog/progress_dialog.dart'; String selectedInput; String selectedOutput; class ConversionIoSelction extends StatefulWidget { final String category; ConversionIoSelction(this.category); @override _ConversionIoSelctionState createState() => _ConversionIoSelctionState(); } class _ConversionIoSelctionState extends State<ConversionIoSelction> { ProgressDialog pr; Future<Map<String, List>> checkData; refresh() { setState(() {}); } @override initState() { super.initState(); checkData = getExtensions(); } Future<Map<String, List>> getExtensions() { return getInputOutputFormatOnGroup(widget.category); } @override Widget build(BuildContext context) { pr = new ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: true, showLogs: false); return WillPopScope( onWillPop: () { selectedInput = null; selectedOutput = null; Navigator.pop(context); return null; }, child: Stack( children: <Widget>[ Scaffold( backgroundColor: Colors.grey, body: Container( height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: <Color>[Color(0xffad5389), Color(0xff3c1053)])), child: Column( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Padding( padding: const EdgeInsets.only(top: 50), child: Column( children: <Widget>[ Text( widget.category.toUpperCase(), style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, letterSpacing: 5, fontSize: 20), ), ], ), ), ], ), Padding( padding: const EdgeInsets.only(top: 20.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ Text( selectedInput == null ? "From" : selectedInput.toUpperCase(), style: TextStyle( color: selectedInput == null ? Colors.grey : Colors.white, fontWeight: FontWeight.bold, fontSize: 40), ), Icon( Icons.arrow_forward_ios, color: Colors.white, ), Text( selectedOutput == null ? "To" : selectedOutput.toUpperCase(), style: TextStyle( color: selectedOutput == null ? Colors.grey : Colors.white, fontWeight: FontWeight.bold, fontSize: 40), ) ], ), ), ], ), ), ), Padding( padding: const EdgeInsets.fromLTRB(10, 180, 10, 0), child: Scaffold( backgroundColor: Colors.transparent, body: SingleChildScrollView( child: Container( decoration: BoxDecoration( color: Theme.of(context).scaffoldBackgroundColor, borderRadius: new BorderRadius.circular(20)), child: FutureBuilder<Map<String, List>>( future: checkData, builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasData && snapshot.data != null) { return Column( children: <Widget>[ Container( decoration: BoxDecoration( color: Colors.blue[900], borderRadius: new BorderRadius.vertical( top: Radius.circular(10))), height: 60, child: Center( child: Text( "Select Type", style: TextStyle(color: Colors.white), )), ), SingleChildScrollView( child: Column(children: <Widget>[ ExpansionTileInput(snapshot.data, refresh), ExpansionTileOutput(snapshot.data, refresh), selectedInput != null && selectedOutput != null && selectedOutput != selectedInput ? Padding( padding: const EdgeInsets.all(20.0), child: FlatButton.icon( shape: RoundedRectangleBorder( borderRadius: BorderRadius.all( Radius.circular(50)), ), color: const Color(0xFF3366FF), icon: Icon( Icons.loop, color: Colors.white, ), label: Text('Convert', style: TextStyle( color: Colors.white)), onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) => UploadScreen( selectedOutput, selectedInput), )); }, ), ) : Padding( padding: const EdgeInsets.all(20.0), child: Text( "Please Select input and output Type to proceed", style: TextStyle(color: Colors.grey), ), ) ]), ), ], ); } else if (snapshot.hasError) { return Container( height: MediaQuery.of(context).size.height - 400, child: Scaffold( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Icon( Icons.signal_wifi_off, color: Colors.grey, size: 30, ), Padding( padding: const EdgeInsets.all(15.0), child: Text( '${snapshot.error}', textAlign: TextAlign.center, style: TextStyle( color: Colors.grey, fontSize: 20), ), ), Padding( padding: const EdgeInsets.all(20.0), child: FlatButton.icon( shape: RoundedRectangleBorder( borderRadius: BorderRadius.all( Radius.circular(50)), ), color: const Color(0xFF3366FF), icon: Icon( Icons.refresh, color: Colors.white, ), label: Text('Refresh', style: TextStyle(color: Colors.white)), onPressed: () { setState(() { pr.show(); checkData = getExtensions(); Future.delayed(Duration(seconds: 3)) .then((value) { pr.hide(); }); }); }, ), ) ], ), ), ), ); } return Container( height: MediaQuery.of(context).size.height - 400, child: Center( child: CircularProgressIndicator( backgroundColor: Colors.blueAccent, strokeWidth: 2, ), ), ); }, ), ), )), ) ], ), ); } } class ExpansionTileInput extends StatefulWidget { final Function() notifyParent; final Map<String, List<String>> io; const ExpansionTileInput(this.io, this.notifyParent); @override _ExpansionTileInputState createState() => _ExpansionTileInputState(); } class _ExpansionTileInputState extends State<ExpansionTileInput> { @override Widget build(BuildContext context) { List<String> input = widget.io.keys.toList(); return Container( decoration: new BoxDecoration( borderRadius: BorderRadius.circular(10.0), ), margin: EdgeInsets.all(10), child: Theme( data: Theme.of(context).brightness == Brightness.light ? ThemeData.light() : ThemeData.dark(), child: ExpansionTile( key: GlobalKey(), subtitle: Text( "Select the input type by clicking ⌄ icon", style: TextStyle(color: Colors.grey), ), title: Text("Input Type"), children: <Widget>[ GridView.count( shrinkWrap: true, physics: ClampingScrollPhysics(), crossAxisCount: 3, padding: const EdgeInsets.all(20.0), mainAxisSpacing: 15, crossAxisSpacing: 15, childAspectRatio: MediaQuery.of(context).size.width / (MediaQuery.of(context).size.height / 4), children: List.generate(input.length, (index) { return FlatButton( onPressed: () { setState(() { selectedInput = input[index]; selectedOutput = null; }); widget.notifyParent(); }, shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(50)), ), padding: EdgeInsets.all(10), child: Center( child: Text( input[index], )), ); }), ) ]), ), ); } } class ExpansionTileOutput extends StatefulWidget { final Function() notifyParent; final Map<String, List<String>> io; ExpansionTileOutput(this.io, this.notifyParent); @override _ExpansionTileOutputState createState() => _ExpansionTileOutputState(); } class _ExpansionTileOutputState extends State<ExpansionTileOutput> { @override Widget build(BuildContext context) { Map<String, List<String>> ioList = widget.io; return Container( decoration: new BoxDecoration( borderRadius: BorderRadius.circular(10.0), ), margin: EdgeInsets.all(10), child: Theme( data: Theme.of(context).brightness == Brightness.light ? ThemeData.light() : ThemeData.dark(), child: ExpansionTile( key: GlobalKey(), subtitle: Text( "Select the output type by clicking ⌄ icon", style: TextStyle(color: Colors.grey), ), title: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text("Output Type"), ], ), children: <Widget>[ selectedInput == null ? Center( child: Padding( padding: const EdgeInsets.all(15.0), child: Text( "Plz select input type", style: TextStyle(color: Colors.grey), ), )) : GridView.count( shrinkWrap: true, physics: ClampingScrollPhysics(), crossAxisCount: 3, padding: const EdgeInsets.all(20.0), mainAxisSpacing: 15, crossAxisSpacing: 15, childAspectRatio: MediaQuery.of(context).size.width / (MediaQuery.of(context).size.height / 4), children: List.generate( selectedInput == null ? 0 : ioList[selectedInput].length, (index) { return FlatButton( onPressed: () { setState(() { selectedOutput = ioList[selectedInput][index]; }); widget.notifyParent(); }, shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(50)), ), padding: EdgeInsets.all(10), child: Center( child: Text( ioList[selectedInput][index], )), ); }), ) ]), ), ); } }
0
mirrored_repositories/docit_v1.0.0/lib
mirrored_repositories/docit_v1.0.0/lib/screens/uploadScreen.dart
import 'dart:io'; import 'package:docit_v1_0_0/screens/downloadPage.dart'; import 'package:filesize/filesize.dart'; import 'package:path/path.dart' as p; import 'package:file_picker/file_picker.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:progress_dialog/progress_dialog.dart'; import 'package:shared_preferences/shared_preferences.dart'; class UploadScreen extends StatefulWidget { final String inputType; final String outputType; UploadScreen(this.outputType, this.inputType); @override _UploadScreenState createState() => _UploadScreenState(); } class _UploadScreenState extends State<UploadScreen> { ProgressDialog pr; List<String> _filenames = []; List<String> _filesize = []; List<String> docPaths = []; bool isPressed = false; Future<bool> _saveList() async { List<String> list = []; list.add(widget.inputType + " to " + widget.outputType); SharedPreferences prefs = await SharedPreferences.getInstance(); List<String> temp = prefs.getStringList("FavList"); if (temp != null) { if (!temp.contains(list[0])) { list.addAll(temp); return await prefs.setStringList("FavList", list); } } return await prefs.setStringList("FavList", list); } Future<bool> _removeFromList() async { SharedPreferences prefs = await SharedPreferences.getInstance(); List<String> temp = prefs.getStringList("FavList"); temp.remove(widget.inputType + " to " + widget.outputType); prefs.clear(); return await prefs.setStringList("FavList", temp); } void _getList() async { SharedPreferences prefs = await SharedPreferences.getInstance(); List<String> resultList = prefs.getStringList("FavList"); if (resultList != null) { if (resultList.contains(widget.inputType + " to " + widget.outputType)) { setState(() { isPressed = true; }); } } } void filepick() async { pr = new ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: true, showLogs: false); pr.style( message: "Loading Files", progressWidget: Padding( padding: const EdgeInsets.all(8.0), child: CircularProgressIndicator( strokeWidth: 1, ), )); int flag = 0; String sizeOfFile; try { pr.show(); Map<String, String> temp = await FilePicker.getMultiFilePath(); setState(() { for (var fileNamesPresent in temp.keys) { String ext = p.extension(temp[fileNamesPresent]); if (ext == "." + widget.inputType && docPaths.length < 5) { docPaths.add(temp[fileNamesPresent]); _filenames.add(fileNamesPresent); int size = File(temp[fileNamesPresent]).lengthSync(); sizeOfFile = filesize(size); _filesize.add(sizeOfFile); } else { flag = 1; } } }); if (flag == 1) { _wrongExtensionAlert(context).then((value) { Future.delayed(Duration(seconds: 1)).then((value) { pr.hide(); }); }); } else { Future.delayed(Duration(seconds: 1)).then((value) { pr.hide(); }); } } catch (e) { Future.delayed(Duration(seconds: 0)).then((value) { pr.hide(); }); } if (!mounted) { return; } } Future<void> _noFileAlert(BuildContext context) { return showDialog<void>( context: context, builder: (BuildContext context) { return AlertDialog( title: Text('Error'), content: Text('No Files as been added'), actions: <Widget>[ FlatButton( child: Text('Ok'), onPressed: () { Navigator.of(context).pop(); }, ), ], ); }, ); } Future<void> _wrongExtensionAlert(BuildContext context) { return showDialog<void>( context: context, builder: (BuildContext context) { return AlertDialog( title: Text('Error'), content: Text( '● Maximum 5 files can be selected at once.\n● Some files is of wrong extension please add file with .${widget.inputType} extension only.'), actions: <Widget>[ FlatButton( child: Text('Ok'), onPressed: () { Navigator.of(context).pop(); }, ), ], ); }, ); } Future<void> _showToastRemoveFav(BuildContext context) { return showDialog<void>( context: context, builder: (BuildContext context) { return CupertinoAlertDialog( title: Text('Removed'), content: Padding( padding: const EdgeInsets.all(8.0), child: Text('Successfully removed from favourite'), ), actions: <Widget>[ FlatButton( child: Text( 'Ok', style: TextStyle(color: Colors.white), ), onPressed: () { Navigator.of(context).pop(); }, ), ], ); }, ); } Future<void> _showToastAddFav(BuildContext context) { return showDialog<void>( context: context, builder: (BuildContext context) { return CupertinoAlertDialog( title: Text('Added'), content: Padding( padding: const EdgeInsets.all(8.0), child: Text('Successfully added to favourite'), ), actions: <Widget>[ FlatButton( child: Text('Ok', style: TextStyle(color: Colors.white)), onPressed: () { Navigator.of(context).pop(); }, ), ], ); }, ); } void removeFiles(int index) { return setState(() { _filenames.removeAt(index); _filesize.removeAt(index); docPaths.removeAt(index); }); } @override void initState() { super.initState(); _getList(); } @override Widget build(BuildContext context) { return WillPopScope( onWillPop: () async { Navigator.pop(context); return null; }, child: Stack(children: <Widget>[ Scaffold( body: Builder( builder: (context) => Container( height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: <Color>[Color(0xffad5389), Color(0xff3c1053)])), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Padding( padding: const EdgeInsets.only(top: 50), child: Text( widget.inputType + " ➟ " + widget.outputType, style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 20), ), ), Padding( padding: const EdgeInsets.only(top: 38), child: SizedBox.fromSize( size: Size(56, 56), // button width and height child: ClipOval( child: Material( color: Colors.transparent, // button color child: InkWell( splashColor: Colors.pinkAccent, // splash color onTap: () async { if (isPressed == false) { if (await _saveList()) { setState(() { isPressed = !isPressed; }); this._showToastAddFav(context); } } else if (isPressed == true) { if (await _removeFromList()) { setState(() { isPressed = !isPressed; }); this._showToastRemoveFav(context); } } if (!isPressed) { _removeFromList(); } }, // button pressed child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Icon( isPressed ? Icons.favorite : Icons.favorite_border, color: isPressed ? Colors.redAccent : Colors.white, ), // text ], ), ), ), ), )) ], ), ), ), ), Padding( padding: const EdgeInsets.fromLTRB(10, 100, 10, 0), child: Scaffold( backgroundColor: Colors.transparent, floatingActionButton: Row( mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ Padding( padding: const EdgeInsets.all(8.0), child: FloatingActionButton.extended( heroTag: "btn-1", icon: Icon(Icons.cached), onPressed: () { if (docPaths.isNotEmpty) { Navigator.push( context, MaterialPageRoute( builder: (context) => DownloadPage( widget.inputType, widget.outputType, docPaths), )); } else { _noFileAlert(context); } }, label: Text('Convert'), ), ), Padding( padding: const EdgeInsets.all(8.0), child: FloatingActionButton.extended( heroTag: "btn-2", icon: Icon(Icons.add), onPressed: () { filepick(); }, label: Text('Add File'), ), ) ], ), body: _filenames.length == 0 ? DisplayWhenEmpty(widget.inputType) : ListView.builder( padding: EdgeInsets.only(bottom: 120), itemCount: _filenames.length, itemBuilder: (BuildContext context, int index) { return Card( color: new Color(0xff2a5298), margin: EdgeInsets.all(10.0), child: Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ ListTile( leading: Icon( Icons.insert_drive_file, color: Colors.white, size: 45, ), trailing: IconButton( icon: Icon( Icons.cancel, color: Colors.white, ), onPressed: () { removeFiles(index); }, ), title: Padding( padding: const EdgeInsets.all(8.0), child: Text( 'File Name : ${_filenames[index]}', style: TextStyle(color: Colors.white), ), ), subtitle: Padding( padding: const EdgeInsets.all(8.0), child: Text( 'Size : ${_filesize[index]}', style: TextStyle(color: Colors.white), ), ), ), ], ), ); }, ), ), ), ]), ); } } class DisplayWhenEmpty extends StatelessWidget { final String inputType; const DisplayWhenEmpty( this.inputType, { Key key, }) : super(key: key); @override Widget build(BuildContext context) { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Icon( Icons.add_circle_outline, color: Colors.grey, size: 50, ), Padding( padding: const EdgeInsets.all(15.0), child: Text( 'Click on "Add File" to add file with extension .$inputType', textAlign: TextAlign.center, style: TextStyle(color: Colors.grey), ), ), ], ), ); } }
0
mirrored_repositories/docit_v1.0.0/lib
mirrored_repositories/docit_v1.0.0/lib/screens/homeTab.dart
import 'package:docit_v1_0_0/screens/conversionIOSelection.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; class HomeTab extends StatefulWidget { @override _HomeTabState createState() => _HomeTabState(); } class _HomeTabState extends State<HomeTab> { List<String> typesOfConvertor = [ "Document Converter", "Image Converter", "Presentation Converter", "Spreadsheet Converter", "Audio Converter", "Video Converter", "Ebook Converter", "Font Converter", "Archive Converter", "CAD Converter", "Vector Converter" ]; @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.fromLTRB(20, 10, 20, 10), child: AnimationLimiter( child: ListView.builder( scrollDirection: Axis.vertical, shrinkWrap: true, itemCount: 11, itemBuilder: (BuildContext context, int index) { return AnimationConfiguration.staggeredGrid( position: index, duration: const Duration(milliseconds: 370), columnCount: 1, child: ScaleAnimation( child: FadeInAnimation( child: Card( elevation: 5, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(50)), color: Color(0xFF2e5090), child: ListTile( onTap: () { List<String> metadata = typesOfConvertor[index].split(" "); Navigator.push( context, MaterialPageRoute( builder: (context) => ConversionIoSelction( metadata[0].toLowerCase()), )); }, contentPadding: EdgeInsets.symmetric( horizontal: 20.0, vertical: 10.0), leading: Container( padding: EdgeInsets.only(right: 12.0), decoration: new BoxDecoration( border: new Border( right: new BorderSide( width: 1.0, color: Colors.white24))), child: Icon(Icons.autorenew, color: Colors.white), ), title: Text( typesOfConvertor[index], style: TextStyle(color: Colors.white), ), trailing: Icon( Icons.navigate_next, color: Colors.white, )), ), ), ), ); }, ), ), ); } }
0
mirrored_repositories/docit_v1.0.0/lib/screens
mirrored_repositories/docit_v1.0.0/lib/screens/ApiEvents/uploadAndDownload.dart
import 'dart:convert'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:path/path.dart' as p; import 'package:dio/dio.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:progress_dialog/progress_dialog.dart'; String url = "https://api.cloudconvert.com/v2/jobs"; String token = DotEnv().env['API_TOKEN']; Map<String, String> headers = { 'Authorization': 'Bearer $token', 'Content-type': 'application/json' }; var dio = Dio(); ProgressDialog pr; Future<List<String>> createUploadJob(String inputType, String outputType, List<String> paths, BuildContext context) async { Map<String, dynamic> tempBodyImportTag = {}; List<String> importList = []; for (var i = 1; i <= paths.length; i++) { tempBodyImportTag.addAll({ "import-$i": {"operation": "import/upload"}, }); importList.add("import-$i"); } tempBodyImportTag.addAll({ "task-1": { "operation": "convert", "input_format": inputType, "output_format": outputType, "input": importList }, "export-1": { "operation": "export/url", "input": ["task-1"], } }); var body = jsonEncode({"tasks": tempBodyImportTag}); try { Response<Map> response = await dio.post(url, options: Options( headers: headers, ), data: body); Map<String, dynamic> res = response.data; return await uploadFilePost(res, paths); } catch (e) { print(e); if (e is DioError) { return Future.error( 'Oops Something went wrong ! Plz check Internet connection.'); } else { return Future.error( 'Seems our API broke please reinstall this app or try later!'); } } } Future<List<String>> uploadFilePost( Map<String, dynamic> res, List<String> paths) async { List<String> downloadLinks = []; List<Map<String, dynamic>> parameters = []; List<String> postUrl = []; for (var i = 0; i < paths.length; i++) { parameters.add(res["data"]["tasks"][i]["result"]["form"]["parameters"]); postUrl.add(res["data"]["tasks"][i]["result"]["form"]["url"]); FormData formData = new FormData.fromMap({ "expires": parameters[i]["expires"], "max_file_count": 1, "max_file_size": 10000000000, "redirect": parameters[i]["redirect"], "signature": parameters[i]["signature"], "file": await MultipartFile.fromFile(paths[i], filename: p.basename(paths[i])), }); try { Response postRessponse = await dio.post(postUrl[i], options: Options(headers: headers), data: formData); if (postRessponse.statusCode == 201) { continue; } else { break; } } catch (e) { return Future.error( 'Oops Something went wrong ! Plz check Internet connection.'); } } try { while (true) { Response<Map> downloadResponse = await dio.getUri( Uri.parse(res["data"]["links"]["self"]), options: Options(headers: headers)); print(downloadResponse.data["data"]["status"]); if (downloadResponse.data["data"]["status"] == "waiting" || downloadResponse.data["data"]["status"] == "processing") { continue; } else if (downloadResponse.data["data"]["status"] == "finished") { for (var i = 0; i < paths.length; i++) { downloadLinks.add(downloadResponse.data["data"]["tasks"][i]["result"] ["files"][0]["url"]); } break; } } return downloadLinks; } catch (e) { return e; } }
0
mirrored_repositories/docit_v1.0.0/lib/screens
mirrored_repositories/docit_v1.0.0/lib/screens/ApiEvents/getTypeOfFormats.dart
import 'dart:convert'; import 'dart:io'; import 'package:http/http.dart' as http; String url = "https://api.cloudconvert.com/v2/convert/formats"; Future<Map<String, List<String>>> getInputOutputFormatOnGroup( String groupName) async { Set<String> inputFormat = {}; List<List<String>> outputFormat = []; try { http.Response response = await http .get(Uri.encodeFull(url), headers: {"Accept": "application/json"}); Map<String, dynamic> data = json.decode(response.body); for (var i = 0; i < data["data"].length; i++) { if (data["data"][i]["meta"]["group"] == groupName) { // print(data["data"][i]["output_format"]); inputFormat.add(data["data"][i]["output_format"]); } } for (var i = 0; i < inputFormat.length; i++) { List<String> temp = []; for (var j = 0; j < data["data"].length; j++) { if (data["data"][j]["input_format"] == inputFormat.elementAt(i)) { temp.add(data["data"][j]["output_format"]); } } outputFormat.add(temp); } Map<String, List<String>> inputOutputFormat = new Map.fromIterables(inputFormat, outputFormat); return inputOutputFormat; } on SocketException { return Future.error("Network Error please connect to internet", StackTrace.fromString("Network Failure")); } catch (e) { return Future.error( 'Something went wrong please reinstall or restart the app'); } }
0
mirrored_repositories/docit_v1.0.0
mirrored_repositories/docit_v1.0.0/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:docit_v1_0_0/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/searchbar_in_appbar
mirrored_repositories/searchbar_in_appbar/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData(primarySwatch: Colors.cyan), home: HomePage(), ); } } class HomePage extends StatefulWidget { @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { //TODO Variables Icon customIcon = Icon(Icons.search); Widget customSearchBar = Text('App Bar'); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( elevation: 20.0, title: customSearchBar, leading: IconButton( onPressed: () {}, icon: Icon(Icons.menu), ), actions: [ IconButton( onPressed: () { setState(() { if (this.customIcon.icon == Icons.search) { this.customIcon = Icon(Icons.cancel); this.customSearchBar = TextField( textInputAction: TextInputAction.go, decoration: InputDecoration( border: InputBorder.none, hintText: 'Search', ), style: TextStyle( fontSize: 20.0, // color: Colors.white, ), ); } else { this.customIcon = Icon(Icons.search); this.customSearchBar = Text('App Bar'); } }); }, icon: customIcon, ), IconButton( onPressed: () {}, icon: Icon(Icons.more_vert), ), ], // when add something like any widget at the appbar's bottom // bottom: PreferredSize( // preferredSize: Size(50.0, 50.0), // child: Container(), // ), ), ); } }
0
mirrored_repositories/searchbar_in_appbar
mirrored_repositories/searchbar_in_appbar/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:searchbar_in_appbar/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/eAttendance/eattendance_student
mirrored_repositories/eAttendance/eattendance_student/lib/main.dart
import '../../repository/auth/auth_repository.dart'; import '../../controllers/permissions_controller.dart'; import '../../screens/home/home_screen.dart'; import '../../screens/splash/splash_screen.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:get/get.dart'; import 'package:provider/provider.dart'; Future<void> main() async { WidgetsFlutterBinding.ensureInitialized(); Get.put(AuthenticationRepository()); SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); Get.put(GrantPermissions()); runApp( ChangeNotifierProvider( create: (context) => ButtonState(), child: const MyApp(), ), ); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return GetMaterialApp( title: 'eAttendance Student', debugShowCheckedModeBanner: false, theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.green), inputDecorationTheme: InputDecorationTheme( enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(5), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(5), ), ), appBarTheme: const AppBarTheme( backgroundColor: Colors.green, ), filledButtonTheme: const FilledButtonThemeData( style: ButtonStyle( elevation: MaterialStatePropertyAll(5), ), ), useMaterial3: true, ), home: const SplashScreen(), ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/controllers/forgot_password_controller.dart
import 'package:flutter/widgets.dart'; import 'package:get/get.dart'; class ForgotPasswordController extends GetxController { static ForgotPasswordController get instance => Get.find(); final email = TextEditingController(); // void resetPassword(email) { // AuthenticationRepository.instance.resetPassword(email); // } }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/controllers/button_disable.dart
import 'package:flutter/material.dart'; class Buttondisable extends StatefulWidget { const Buttondisable({super.key}); @override State<Buttondisable> createState() => _ButtondisableState(); } class _ButtondisableState extends State<Buttondisable> { bool isButtonDisable= false; void disableButton(){ setState(() { isButtonDisable = true; }); } @override Widget build(BuildContext context) { return Scaffold( body: Center(child: Column( // mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ ElevatedButton(onPressed: isButtonDisable ? null: () { disableButton(); }, child: Text("fill the attendace")) ], )), ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/controllers/registration_controller.dart
import 'package:flutter/material.dart'; import 'package:get/get.dart'; class RegistrationController extends GetxController { static RegistrationController get instance => Get.find(); final name = TextEditingController(); final email = TextEditingController(); final password = TextEditingController(); // final userRepo = Get.put(UserRepository()); // Future<User?> registerUser(String email, String password) async { // return await AuthenticationRepository.instance // .createUserWithNameEmailAndPassword(email, password); // } // Future<void> createUser(UserModel user) async { // User? userCredential = await registerUser(user.email, user.password); // user.id = userCredential!.uid; // userRepo.createUser(user); // } }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/controllers/permissions_controller.dart
import 'package:get/get.dart'; import 'package:permission_handler/permission_handler.dart'; class GrantPermissions extends GetxController { static GrantPermissions get instance => Get.find(); Future<bool> isCameraGranted() async { bool isGranted = await Permission.camera.request().isGranted; if (!isGranted) { await Permission.camera.request(); } return isGranted; } Future<bool> isMediaGranted() async { bool isGranted = await Permission.mediaLibrary.request().isGranted; if (!isGranted) { await Permission.mediaLibrary.request(); } return isGranted; } }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/controllers/login_controller.dart
import '../../repository/auth/auth_repository.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; class LoginController extends GetxController { static LoginController get instance => Get.find(); final email = TextEditingController(); final password = TextEditingController(); void loginUser(String email, String password) { AuthenticationRepository.instance .loginUserWithNameEmailAndPassword(email, password); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/repository
mirrored_repositories/eAttendance/eattendance_student/lib/repository/attendance/attendance_list_repository.dart
import 'dart:convert'; import 'package:eattendance_student/models/attendance_model.dart'; import 'package:eattendance_student/models/token_manager.dart'; import 'package:eattendance_student/repository/auth/auth_repository.dart'; import 'package:eattendance_student/utility/constants.dart'; import 'package:get/get.dart'; import 'package:http/http.dart' as http; class AttendanceListRepository { static AttendanceListRepository get instance => Get.find(); final AuthenticationRepository authRepo = Get.find(); Future<AttendanceListData?> getAttendanceList() async { try { final response = await http.get( Uri.parse( "$apiUrl/attendance/data/${authRepo.student.value!.studentId}"), headers: createAuthorizationHeaders(await TokenManager.getToken())); if (response.statusCode == 200) { final Map<String, dynamic> jsonData = jsonDecode(response.body); return AttendanceListData.fromMap(jsonData); } else { return null; } } catch (_) { return null; } } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/repository
mirrored_repositories/eAttendance/eattendance_student/lib/repository/auth/auth_repository.dart
import 'package:eattendance_student/models/token_manager.dart'; import '../../exceptions/auth_exceptions.dart'; import '../../models/auth_request.dart'; import '../../models/batch_model.dart'; import '../../models/course_model.dart'; import '../../utility/constants.dart'; import '../../models/student_model.dart'; import '../../screens/authentication/login.dart'; import '../../utility/utils.dart'; import 'package:http/http.dart' as http; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../../screens/screen_navigator.dart'; class AuthenticationRepository extends GetxController { static AuthenticationRepository get instance => Get.find(); // final _auth = FirebaseAuth.instance; // late final Rx<User?> firebaseUser; late Rx<Student?> student = Rx<Student?>(null); late SharedPreferences prefs; @override void onReady() async { prefs = await SharedPreferences.getInstance(); bool isLoggedIn = prefs.getBool("isLoggedIn") ?? false; if (isLoggedIn) { student.value = Student.fromJson(prefs.getString("student") ?? Student( studentId: 0, enrollment: 'enrollment', username: 'username', email: 'email', division: 'division', course: Course(courseId: 0, courseName: 'courseName'), batch: Batch(id: 0, batchName: 'batchName'), token: 'token', ).toJson()); } // firebaseUser = Rx<User?>(_auth.currentUser); //firebaseUser.bindStream(_auth.userChanges()); // ever(firebaseUser, _setInitialScreen); // ever(student, _setInitialScreen); _setInitialScreen(student); } _setInitialScreen(Rx<Student?> user) { user.value == null ? Get.offAll(() => const LoginScreen()) : Get.offAll(() => const ScreenNavigator()); } // Future<User?> createUserWithNameEmailAndPassword( // String email, String password) async { // try { // await _auth.createUserWithEmailAndPassword( // email: email, password: password); // if (firebaseUser.value != null) { // Get.offAll(() => const ScreenNavigator()); // } // return firebaseUser.value; // } on FirebaseAuthException catch (e) { // final ex = SignUpWithEmailAndPasswordFailure.code(e.code); // showSnackkBar( // message: ex.message, // title: 'Try Again', // icon: const Icon(Icons.error), // ); // // print('FIREBASE AUTH EXCEPTION - ${ex.message}'); // throw ex; // } catch (_) { // final ex = SignUpWithEmailAndPasswordFailure(); // showSnackkBar( // message: ex.message, // title: 'Try Again', // icon: const Icon(Icons.error), // ); // // print('EXCEPTION - ${ex.message}'); // throw ex; // } // } Future<void> loginUserWithNameEmailAndPassword( String email, String password) async { try { final response = await http.post(Uri.parse("$apiUrl/auth/login"), body: AuthRequest(username: email, password: password).toJson(), headers: {'Content-Type': 'application/json'}); if (response.statusCode == 200) { student = Rx<Student?>(Student.fromJson(response.body)); await prefs.setBool("isLoggedIn", true); await prefs.setString("student", student.value!.toJson()); await TokenManager.saveToken(student.value!.token); } if (response.statusCode == 404) { throw SignUpWithEmailAndPasswordFailure.code("404"); } // await _auth.signInWithEmailAndPassword(email: email, password: password); // Get.put(faculty); student.value != null ? Get.offAll(() => const ScreenNavigator()) : Get.offAll(() => const LoginScreen()); } catch (_) { final ex = SignUpWithEmailAndPasswordFailure(); showSnackkBar( message: ex.message, title: 'Try Again', icon: const Icon(Icons.error), ); // print('EXCEPTION - ${ex.message}'); } } // Future<void> resetPassword(email) async { // await _auth.sendPasswordResetEmail(email: email); // Get.offAll(() => const LoginScreen()); // showSnackkBar( // message: 'Password Reset Mail Send SuccessFully', // title: 'Check Your Mail', // icon: const Icon(Icons.done), // ); // } Future<void> logOut() async { prefs.clear(); Get.offAll(() => const LoginScreen()); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/repository
mirrored_repositories/eAttendance/eattendance_student/lib/repository/session/session_repository.dart
import 'dart:convert'; import '../auth/auth_repository.dart'; import '../../models/attendance_data.dart'; import '../../models/token_manager.dart'; import '../../models/mapping_model.dart'; import '../../utility/constants.dart'; import 'package:get/get.dart'; import 'package:http/http.dart' as http; class SessionRepository { static SessionRepository get instance => Get.find(); final AuthenticationRepository authRepo = Get.find(); Future<Mapping?> isSessionOpen() async { try { final response = await http.get( Uri.parse( "$apiUrl/session/isSession/${authRepo.student.value!.studentId}"), headers: createAuthorizationHeaders(await TokenManager.getToken())); // log(response.body); if (response.statusCode == 200) { final json = jsonDecode(response.body); return Mapping.fromJson(json); } else { return null; } } catch (_) { return null; } } Future<bool> fillAttendance(Mapping map, AttendanceData data) async { // remain to pass the AttendnceData in the Request final response = await http.post( Uri.parse( "$apiUrl/session/fillAttendance/${map.mapId}/${authRepo.student.value!.studentId}"), headers: createAuthorizationHeaders(await TokenManager.getToken(), contentType: true), body: data.toJson()); if (response.statusCode == 200) { return bool.parse(response.body); } else { throw Exception("Unable To Fill Attendance"); } } }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/models/subject_model.dart
import 'dart:convert'; class Subject { int subjectId; String subjectName; Subject({ required this.subjectId, required this.subjectName, }); Map<String, dynamic> toMap() { return <String, dynamic>{ 'subjectId': subjectId, 'subjectName': subjectName, }; } factory Subject.fromMap(Map<String, dynamic> map) { return Subject( subjectId: map['subjectId'] as int, subjectName: map['subjectName'] as String, ); } String toJson() => json.encode({ 'subjectId': subjectId, 'subjectName': subjectName, }); factory Subject.fromJson(Map<String, dynamic> map) => Subject( subjectId: map['subjectId'] as int, subjectName: map['subjectName'] as String, ); }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/models/student_model.dart
// ignore_for_file: public_member_api_docs, sort_constructors_first import 'dart:convert'; import '../../models/batch_model.dart'; import '../../models/course_model.dart'; class Student { int studentId; String enrollment; String username; String email; String division; Course course; Batch batch; String token; Student({ required this.studentId, required this.enrollment, required this.username, required this.email, required this.division, required this.course, required this.batch, required this.token, }); Map<String, dynamic> toMap() { return <String, dynamic>{ 'studentId': studentId, 'enrollment': enrollment, 'username': username, 'email': email, 'division': division, 'course': course.toMap(), 'batch': batch.toMap(), 'token': token, }; } factory Student.fromMap(Map<String, dynamic> map) { return Student( studentId: map['studentId'] as int, enrollment: map['enrollment'] as String, username: map['username'] as String, email: map['email'] as String, division: map['division'] as String, course: Course.fromMap(map['course'] as Map<String, dynamic>), batch: Batch.fromMap(map['batch'] as Map<String, dynamic>), token: map['token'] as String, ); } String toJson() => json.encode(toMap()); factory Student.fromJson(String source) => Student.fromMap(json.decode(source) as Map<String, dynamic>); Student copyWith({ int? studentId, String? enrollment, String? username, String? email, String? division, Course? course, Batch? batch, String? token, }) { return Student( studentId: studentId ?? this.studentId, enrollment: enrollment ?? this.enrollment, username: username ?? this.username, email: email ?? this.email, division: division ?? this.division, course: course ?? this.course, batch: batch ?? this.batch, token: token ?? this.token, ); } @override String toString() { return 'Student(studentId: $studentId, enrollment: $enrollment, username: $username, email: $email, division: $division, course: $course, batch: $batch, token: $token)'; } @override bool operator ==(covariant Student other) { if (identical(this, other)) return true; return other.studentId == studentId && other.enrollment == enrollment && other.username == username && other.email == email && other.division == division && other.course == course && other.batch == batch && other.token == token; } @override int get hashCode { return studentId.hashCode ^ enrollment.hashCode ^ username.hashCode ^ email.hashCode ^ division.hashCode ^ course.hashCode ^ batch.hashCode ^ token.hashCode; } }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/models/attendance_data.dart
// ignore_for_file: public_member_api_docs, sort_constructors_first import 'dart:convert'; class AttendanceData { String course; String subject; String sem; String dividion; String duration; String faculty; String createdAt; AttendanceData({ required this.course, required this.subject, required this.sem, required this.dividion, required this.duration, required this.faculty, required this.createdAt, }); AttendanceData copyWith({ String? course, String? subject, String? sem, String? dividion, String? duration, String? faculty, String? createdAt, }) { return AttendanceData( course: course ?? this.course, subject: subject ?? this.subject, sem: sem ?? this.sem, dividion: dividion ?? this.dividion, duration: duration ?? this.duration, faculty: faculty ?? this.faculty, createdAt: createdAt ?? this.createdAt, ); } Map<String, dynamic> toMap() { return <String, dynamic>{ 'course': course, 'subject': subject, 'sem': sem, 'dividion': dividion, 'duration': duration, 'faculty': faculty, 'createdAt': createdAt, }; } factory AttendanceData.fromMap(Map<String, dynamic> map) { return AttendanceData( course: map['course'] as String, subject: map['subject'] as String, sem: map['sem'] as String, dividion: map['dividion'] as String, duration: map['duration'] as String, faculty: map['faculty'] as String, createdAt: map['createdAt'] as String, ); } String toJson() => json.encode(toMap()); factory AttendanceData.fromJson(String source) => AttendanceData.fromMap(json.decode(source) as Map<String, dynamic>); @override String toString() { return 'AttendanceData(course: $course, subject: $subject, sem: $sem, dividion: $dividion, duration: $duration, faculty: $faculty, createdAt: $createdAt)'; } @override bool operator ==(covariant AttendanceData other) { if (identical(this, other)) return true; return other.course == course && other.subject == subject && other.sem == sem && other.dividion == dividion && other.duration == duration && other.faculty == faculty && other.createdAt == createdAt; } @override int get hashCode { return course.hashCode ^ subject.hashCode ^ sem.hashCode ^ dividion.hashCode ^ duration.hashCode ^ faculty.hashCode ^ createdAt.hashCode; } }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/models/attendance_model.dart
// ignore_for_file: public_member_api_docs, sort_constructors_first import 'dart:convert'; import 'package:collection/collection.dart'; import 'package:eattendance_student/models/subject_model.dart'; class AttendanceListData { List<Subject> subjects; List<double> subjectAttendance; double total; AttendanceListData({ required this.subjects, required this.subjectAttendance, required this.total, }); AttendanceListData copyWith({ List<Subject>? subjects, List<double>? subjectAttendance, double? total, }) { return AttendanceListData( subjects: subjects ?? this.subjects, subjectAttendance: subjectAttendance ?? this.subjectAttendance, total: total ?? this.total, ); } Map<String, dynamic> toMap() { return <String, dynamic>{ 'subjects': subjects.map((x) => x.toMap()).toList(), 'subjectAttendance': subjectAttendance, 'total': total, }; } factory AttendanceListData.fromMap(Map<String, dynamic> map) { final List<Subject> subjects = (map['subjects'] as List<dynamic>?) ?.map((x) => Subject.fromMap(x as Map<String, dynamic>)) .toList() ?? []; final List<double> subjectAttendance = (map['subjectAttendance'] as List<dynamic>?) ?.map<double>((value) => value.toDouble()) .toList() ?? []; final double total = (map['total'] as int).toDouble(); // Convert 'total' from int to double return AttendanceListData( subjects: subjects, subjectAttendance: subjectAttendance, total: total, ); } String toJson() => json.encode(toMap()); factory AttendanceListData.fromJson(String source) => AttendanceListData.fromMap(json.decode(source) as Map<String, dynamic>); @override String toString() => 'AttendanceListData(subjects: $subjects, subjectAttendance: $subjectAttendance, total: $total)'; @override bool operator ==(covariant AttendanceListData other) { if (identical(this, other)) return true; final listEquals = const DeepCollectionEquality().equals; return listEquals(other.subjects, subjects) && listEquals(other.subjectAttendance, subjectAttendance) && other.total == total; } @override int get hashCode => subjects.hashCode ^ subjectAttendance.hashCode ^ total.hashCode; }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/models/batch_model.dart
import 'dart:convert'; class Batch { int id; String batchName; Batch({ required this.id, required this.batchName, }); Map<String, dynamic> toMap() { return <String, dynamic>{ 'id': id, 'batchName': batchName, }; } factory Batch.fromMap(Map<String, dynamic> map) { return Batch( id: map['id'] as int, batchName: map['batchName'] as String, ); } String toJson() => json.encode(toMap()); factory Batch.fromJson(String source) => Batch.fromMap(json.decode(source) as Map<String, dynamic>); }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/models/faculty_model.dart
import 'dart:convert'; class Faculty { int userId; String enrollment; String email; String userName; String password; Faculty({ required this.userId, required this.enrollment, required this.email, required this.userName, required this.password, }); Map<String, dynamic> toMap() { return <String, dynamic>{ 'userId': userId, 'enrollment': enrollment, 'email': email, 'userName': userName, 'password': password, }; } factory Faculty.fromMap(Map<String, dynamic> map) { return Faculty( userId: map['userId'] as int, enrollment: map['enrollment'] as String, email: map['email'] as String, userName: map['userName'] as String, password: map['password'] as String, ); } String toJson() => json.encode(toMap()); factory Faculty.fromJson(Map<String, dynamic> json) { return Faculty( userId: json['userId'] as int, enrollment: json['enrollment'] as String, email: json['email'] as String, userName: json['userName'] as String, password: json['password'] as String, ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/models/token_manager.dart
import 'package:shared_preferences/shared_preferences.dart'; class TokenManager { static const String _tokenKey = 'auth_token'; static Future<String?> getToken() async { SharedPreferences prefs = await SharedPreferences.getInstance(); return prefs.getString(_tokenKey); } static Future<void> saveToken(String token) async { SharedPreferences prefs = await SharedPreferences.getInstance(); await prefs.setString(_tokenKey, token); } static Future<void> removeToken() async { SharedPreferences prefs = await SharedPreferences.getInstance(); await prefs.remove(_tokenKey); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/models/mapping_model.dart
// ignore_for_file: public_member_api_docs, sort_constructors_first import 'dart:convert'; import 'course_model.dart'; import 'faculty_model.dart'; import 'semester_model.dart'; import 'subject_model.dart'; class Mapping { int mapId; Course course; Subject subject; Semester semester; Faculty faculty; Mapping({ required this.mapId, required this.course, required this.subject, required this.semester, required this.faculty, }); factory Mapping.fromJson(Map<String, dynamic> json) { return Mapping( mapId: json['mapId'] as int, course: Course.fromJson( json['course'] as Map<String, dynamic>), // Parse the nested object subject: Subject.fromJson( json['subject'] as Map<String, dynamic>), // Parse the nested object semester: Semester.fromJson( json['semester'] as Map<String, dynamic>), // Parse the nested object faculty: Faculty.fromJson( json['faculty'] as Map<String, dynamic>), // Parse the nested object ); } Map<String, dynamic> toMap() { return <String, dynamic>{ 'mapId': mapId, 'course': course.toMap(), 'subject': subject.toMap(), 'semester': semester.toMap(), 'faculty': faculty.toMap(), }; } factory Mapping.fromMap(Map<String, dynamic> map) { return Mapping( mapId: map['mapId'] as int, course: Course.fromMap(map['course'] as Map<String, dynamic>), subject: Subject.fromMap(map['subject'] as Map<String, dynamic>), semester: Semester.fromMap(map['semester'] as Map<String, dynamic>), faculty: Faculty.fromMap(map['faculty'] as Map<String, dynamic>), ); } String toJson() => json.encode(toMap()); }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/models/course_model.dart
// ignore_for_file: public_member_api_docs, sort_constructors_first import 'dart:convert'; class Course { final int courseId; final String courseName; Course({ required this.courseId, required this.courseName, }); factory Course.fromJson(Map<String, dynamic> json) { return Course( courseId: json['courseId'], courseName: json['courseName'], ); } Map<String, dynamic> toMap() { return <String, dynamic>{ 'courseId': courseId, 'courseName': courseName, }; } factory Course.fromMap(Map<String, dynamic> map) { return Course( courseId: map['courseId'] as int, courseName: map['courseName'] as String, ); } String toJson() => json.encode(toMap()); } extension JsonConversion on Course { Map<String, dynamic> toJson() { return { 'courseId': courseId, 'courseName': courseName, }; } }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/models/semester_model.dart
import 'dart:convert'; // ignore_for_file: public_member_api_docs, sort_constructors_first class Semester { int semesterId; String semesterName; Semester({ required this.semesterId, required this.semesterName, }); Map<String, dynamic> toMap() { return <String, dynamic>{ 'semesterId': semesterId, 'semesterName': semesterName, }; } factory Semester.fromMap(Map<String, dynamic> map) { return Semester( semesterId: map['semesterId'] as int, semesterName: map['semesterName'] as String, ); } String toJson() => json.encode(toMap()); factory Semester.fromJson(Map<String, dynamic> json) { return Semester( semesterId: json['semesterId'], semesterName: json['semesterName'], ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/models/auth_request.dart
import 'dart:convert'; class AuthRequest { String username; String password; AuthRequest({ required this.username, required this.password, }); AuthRequest copyWith({ String? username, String? password, }) { return AuthRequest( username: username ?? this.username, password: password ?? this.password, ); } Map<String, dynamic> toMap() { return <String, dynamic>{ 'username': username, 'password': password, }; } factory AuthRequest.fromMap(Map<String, dynamic> map) { return AuthRequest( username: map['username'] as String, password: map['password'] as String, ); } String toJson() => json.encode(toMap()); factory AuthRequest.fromJson(String source) => AuthRequest.fromMap(json.decode(source) as Map<String, dynamic>); @override String toString() => 'AuthRequest(username: $username, password: $password)'; @override bool operator ==(covariant AuthRequest other) { if (identical(this, other)) return true; return other.username == username && other.password == password; } @override int get hashCode => username.hashCode ^ password.hashCode; }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/models/user_model.dart
class UserModel { late String? id; final String name; final String email; final String password; UserModel({ this.id, required this.name, required this.email, required this.password, }); toJson() { return { "Name": name, "email": email, "password": password, }; } Map<String, dynamic> toFirestore() { return { "name": name, "email": email, "country": password, if (id != null) "id": id, }; } }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/utility/constants.dart
const String appName = "eAttendance"; const String appLogo = "assets/images/logo.png"; Map<String, String> createAuthorizationHeaders(String? token, {bool contentType = false}) { if (contentType) { return { 'Authorization': 'Bearer $token', "Content-Type": "application/json" }; } return {"Authorization": 'Bearer $token'}; } const endpoint = "/api/v1"; // HOST URL const hosturl = "https://eattendance-zfk0.onrender.com"; const String apiUrl = "$hosturl$endpoint";
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/utility/utils.dart
import 'package:flutter/material.dart'; import 'package:get/get.dart'; void showSnackkBar({message, title = '', icon = const Icon(Icons.done)}) { Get.snackbar( message, title, snackPosition: SnackPosition.BOTTOM, icon: icon, ); }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/exceptions/auth_exceptions.dart
class SignUpWithEmailAndPasswordFailure { final String message; SignUpWithEmailAndPasswordFailure( [this.message = "An Unknown Error Occurred"]); factory SignUpWithEmailAndPasswordFailure.code(String code) { switch (code) { case 'weak-password': return SignUpWithEmailAndPasswordFailure( 'Please Enter A Stronger Password'); case 'invalid-email': return SignUpWithEmailAndPasswordFailure( 'Email is Not valid or badly formated'); case 'email-already-in-use': return SignUpWithEmailAndPasswordFailure( 'An account already exists for this email'); case 'operation-not-allowed': return SignUpWithEmailAndPasswordFailure( 'operation not allowed please contact support team'); case 'user-disabled': return SignUpWithEmailAndPasswordFailure( 'the user has been disabled please contact support for help'); case 'INVALID_LOGIN_CREDENTIALS': return SignUpWithEmailAndPasswordFailure( 'Email or Password dosen\'t match'); default: return SignUpWithEmailAndPasswordFailure(); } } }
0
mirrored_repositories/eAttendance/eattendance_student/lib
mirrored_repositories/eAttendance/eattendance_student/lib/screens/screen_navigator.dart
import 'home/generate_qr_code.dart'; import '../screens/view_attendance/attendance_list.dart'; import '../screens/profile/user_profile_screen.dart'; import 'package:flutter/material.dart'; import 'components/drawer_navigation.dart'; import 'components/custom_appbar.dart'; class ScreenNavigator extends StatefulWidget { const ScreenNavigator({super.key}); @override State<ScreenNavigator> createState() => _ScreenNavigatorState(); } class _ScreenNavigatorState extends State<ScreenNavigator> { int _currentIndex = 0; @override Widget build(BuildContext context) { final List<Widget> currentScreen = [ const HomePage(), const AttendanceList(), const UserProfileScreen(), ]; return Scaffold( drawer: const DrawerNavigation(), appBar: CustomAppBar().customAppBar(), body: SafeArea( maintainBottomViewPadding: true, child: Container( color: Colors.greenAccent.withOpacity(0.1), child: currentScreen[_currentIndex], ), ), bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.fixed, items: const [ // when session is active then this is active other wise this will be desable BottomNavigationBarItem( tooltip: 'Mark Attendance', icon: Icon(Icons.home), label: 'Mark Attendance', ), BottomNavigationBarItem( icon: Icon(Icons.library_books), label: 'see Attendance', tooltip: 'see Attendance', ), BottomNavigationBarItem( icon: Icon(Icons.person), label: 'Profile', tooltip: 'Profile', ) ], currentIndex: _currentIndex, onTap: (index) { setState(() { _currentIndex = index; }); }, ), // floatingActionButton: const FlotingBottomNavigation(), // floatingActionButtonLocation: FloatingActionButtonLocation.miniEndFloat, ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/screens
mirrored_repositories/eAttendance/eattendance_student/lib/screens/contact_us/contact_us.dart
import '../../utility/constants.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; class ContactUs extends StatelessWidget { const ContactUs({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.white, title: const Text( "Contact Us", style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold), ), ), body: Center( child: Padding( padding: const EdgeInsets.all(20.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ const Image( height: 200, width: 300, image: AssetImage(appLogo), ), const SizedBox(height: 30), buildContactInfo("Our toll-free number:", "800-007-0000"), const SizedBox(height: 20), buildContactInfo("Website:", "https://digvijay.rf.gd"), const SizedBox(height: 50), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ buildSocialIcon( icon: Icons.phone, iconColor: Colors.green, onTap: () { launchUrl(Uri.parse("tel: +91 80000700000")); }), const SizedBox(width: 20), buildSocialIcon( icon: Icons.web, iconColor: Colors.blue, onTap: () { launchUrl( Uri.parse("https://digvijay.rf.gd"), mode: LaunchMode.inAppWebView, ); }), ], ), ], ), ), ), ); } Widget buildContactInfo(String label, String value) { return Column( children: [ Text( label, style: const TextStyle( color: Colors.black, fontSize: 20, fontWeight: FontWeight.w600, ), ), const SizedBox(height: 5), Text( value, style: const TextStyle( color: Colors.black, fontSize: 18, ), ), ], ); } Widget buildSocialIcon({icon, iconColor, onTap}) { return GestureDetector( onTap: onTap, child: Container( height: 70, width: 70, decoration: BoxDecoration( color: iconColor, shape: BoxShape.circle, ), child: Center( child: Icon( icon, color: Colors.white, size: 40, ), ), ), ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/screens
mirrored_repositories/eAttendance/eattendance_student/lib/screens/contact_us/about_us.dart
import '../../utility/constants.dart'; import 'package:flutter/material.dart'; class AboutUs extends StatelessWidget { const AboutUs({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.white, title: const Text( "About Us", style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold), ), ), body: const Center( child: Padding( padding: EdgeInsets.all(20.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Image( height: 200, width: 300, image: AssetImage(appLogo), ), SizedBox(height: 30), Text( "Welcome to eAttendance!", style: TextStyle( color: Colors.black, fontSize: 24, fontWeight: FontWeight.bold, ), ), SizedBox(height: 20), Text( "Our Mission", style: TextStyle( color: Colors.black, fontSize: 20, fontWeight: FontWeight.bold, ), ), SizedBox(height: 10), Text( "To reduce time taken by manual proccess of taking attendance.", style: TextStyle( color: Colors.black, fontSize: 18, ), textAlign: TextAlign.center, ), SizedBox(height: 20), Text( "Developed By", style: TextStyle( color: Colors.black, fontSize: 20, fontWeight: FontWeight.bold, ), ), SizedBox(height: 10), Text( "Growth Guards", style: TextStyle( color: Colors.black, fontSize: 18, ), textAlign: TextAlign.center, ), ], ), ), ), ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/screens
mirrored_repositories/eAttendance/eattendance_student/lib/screens/components/drawer_navigation.dart
import '../../utility/constants.dart'; import 'package:flutter/material.dart'; import '../../repository/auth/auth_repository.dart'; import '../contact_us/about_us.dart'; import '../contact_us/contact_us.dart'; class DrawerNavigation extends StatelessWidget { const DrawerNavigation({super.key}); @override Widget build(BuildContext context) { return Drawer( child: Column( children: [ const DrawerHeader( child: Center( child: Image(height: 150, width: 300, image: AssetImage(appLogo)), ), ), ListTile( leading: const Icon(Icons.group), title: const Text( 'About Us', style: TextStyle(fontSize: 20), ), onTap: () { Navigator.of(context).push( MaterialPageRoute(builder: (context) => const AboutUs())); }, ), ListTile( leading: const Icon(Icons.support), title: const Text( 'Contact Us', style: TextStyle(fontSize: 20), ), onTap: () { Navigator.of(context).push( MaterialPageRoute(builder: (context) => const ContactUs())); }, ), const Spacer(), // Pushes the "LogOut" button to the bottom SizedBox( width: double.infinity, // Full width child: TextButton.icon( label: const Text('LogOut'), onPressed: () { AuthenticationRepository.instance.logOut(); }, icon: const Icon(Icons.logout), ), ), const SizedBox(height: 20) ], ), ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/screens
mirrored_repositories/eAttendance/eattendance_student/lib/screens/components/custom_appbar.dart
import 'package:flutter/material.dart'; class CustomAppBar { PreferredSizeWidget customAppBar({title = 'eAttendance'}) { return AppBar( title: Text( title, style: const TextStyle( color: Colors.black, fontSize: 20, ), ), centerTitle: true, backgroundColor: Colors.transparent, forceMaterialTransparency: true, ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/screens
mirrored_repositories/eAttendance/eattendance_student/lib/screens/profile/user_profile_screen.dart
import '../../repository/auth/auth_repository.dart'; import '../../utility/constants.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; class UserProfileScreen extends StatefulWidget { const UserProfileScreen({super.key}); @override State<UserProfileScreen> createState() => _UserProfileScreenState(); } class _UserProfileScreenState extends State<UserProfileScreen> { final AuthenticationRepository authRepo = Get.find(); @override Widget build(BuildContext context) { return Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ const CircleAvatar( backgroundColor: Colors.black12, radius: 60, backgroundImage: AssetImage(appLogo), ), const SizedBox(height: 10), Text( authRepo.student.value!.username, style: const TextStyle( fontSize: 24, fontWeight: FontWeight.bold, letterSpacing: 2.5, ), ), const SizedBox( height: 20, width: 200, child: Divider(color: Colors.black12), ), InfoCard( text: authRepo.student.value!.enrollment, icon: Icons.email, onPressed: () async {}, ), InfoCard( text: authRepo.student.value!.email, icon: Icons.email, onPressed: () async {}, ), InfoCard( text: authRepo.student.value!.batch.batchName, icon: Icons.email, onPressed: () async {}, ), InfoCard( text: authRepo.student.value!.course.courseName, icon: Icons.email, onPressed: () async {}, ), InfoCard( text: authRepo.student.value!.division, icon: Icons.email, onPressed: () async {}, ), ], ); } } class InfoCard extends StatelessWidget { final String text; final IconData icon; final Function onPressed; const InfoCard({ super.key, required this.text, required this.icon, required this.onPressed, }); @override Widget build(BuildContext context) { return GestureDetector( child: Card( margin: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 20.0), child: ListTile( leading: Icon( icon, ), title: Text( text, style: const TextStyle( fontSize: 20, ), ), ), ), ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/screens
mirrored_repositories/eAttendance/eattendance_student/lib/screens/view_attendance/attendance_list.dart
import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../repository/attendance/attendance_list_repository.dart'; import '../../models/attendance_model.dart'; class AttendanceList extends StatefulWidget { const AttendanceList({super.key}); @override State<AttendanceList> createState() => _AttendanceListState(); } class _AttendanceListState extends State<AttendanceList> with SingleTickerProviderStateMixin { late AnimationController _animationController; double totalPercentage = 0.0; AttendanceListRepository attendanceListRepo = Get.put(AttendanceListRepository()); AttendanceListData? data = AttendanceListData( subjects: List.empty(), subjectAttendance: List.empty(), total: 0); @override void initState() { super.initState(); _animationController = AnimationController( vsync: this, duration: const Duration(seconds: 1), ); _animationController.forward(); totalPercentage = 0.0; _initializeData(); } void _initializeData() async { data = await attendanceListRepo.getAttendanceList(); double totalAttendance = 0.0; for (double attendance in data!.subjectAttendance) { totalAttendance += attendance; } setState(() { totalPercentage = totalAttendance; }); } @override Widget build(BuildContext context) { return Scaffold( body: listView(), ); } Widget listView() { return Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Column( children: [ for (int i = 0; i < data!.subjects.length; i++) listViewItem( data!.subjectAttendance[i], data!.subjects[i].subjectName), ], ), Container( alignment: Alignment.center, padding: const EdgeInsets.all(10), color: totalPercentageColor(), child: Text( 'Total Attendance: ${totalPercentage.toStringAsFixed(2)}', style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 20.0, ), ), ), ], ); } Widget listViewItem(double subjectPercentage, String subjectName) { Color progressColor = Colors.green; if (subjectPercentage <= 33) { progressColor = Colors.red; } else if (subjectPercentage > 33 && subjectPercentage < 70) { progressColor = Colors.yellow; } return Container( decoration: const BoxDecoration( border: Border.symmetric(horizontal: BorderSide(color: Colors.black26)), ), padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 15), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( child: Container( margin: const EdgeInsets.only(left: 10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(left: 8.0, top: 5.0), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( subjectName, style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 20.0, ), ), ], ), ) ], ), ), ), Padding( padding: const EdgeInsets.only(right: 8.0), child: AnimatedBuilder( animation: _animationController, builder: (context, child) { return CustomPaint( // size: const Size(100, 100), painter: CirclePainter( progress: subjectPercentage * _animationController.value, progressColor: progressColor, ), child: Padding( padding: const EdgeInsets.all(5), child: Center( child: Text( '${(subjectPercentage * _animationController.value).toStringAsFixed(0)}', style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 15.0, color: Colors.black, ), ), ), ), ); }, ), ), ], ), ); } Color totalPercentageColor() { if (totalPercentage <= 33) { return Colors.red; } else if (totalPercentage > 33 && totalPercentage < 70) { return Colors.yellow; } else { return Colors.green; } } @override void dispose() { _animationController.dispose(); super.dispose(); } } class CirclePainter extends CustomPainter { final double progress; final Color progressColor; CirclePainter({required this.progress, required this.progressColor}); @override void paint(Canvas canvas, Size size) { Paint paint = Paint() ..color = Colors.grey[300]! ..strokeCap = StrokeCap.round ..style = PaintingStyle.stroke ..strokeWidth = 2.0; canvas.drawCircle(size.center(Offset.zero), size.width / 2, paint); Paint progressPaint = Paint() ..color = progressColor ..strokeCap = StrokeCap.round ..style = PaintingStyle.stroke ..strokeWidth = 3.0; double sweepAngle = 360 * progress / 100; canvas.drawArc( Rect.fromCircle(center: size.center(Offset.zero), radius: size.width / 2), -90 * (3.1415926535897932 / 180), sweepAngle * (3.1415926535897932 / 180), false, progressPaint, ); } @override bool shouldRepaint(covariant CustomPainter oldDelegate) { return true; } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/screens
mirrored_repositories/eAttendance/eattendance_student/lib/screens/home/generate_Qr_code.dart
import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:simple_barcode_scanner/simple_barcode_scanner.dart'; import '../../models/attendance_data.dart'; import '../../models/mapping_model.dart'; import '../../repository/session/session_repository.dart'; import '../../utility/utils.dart'; class HomePage extends StatefulWidget { const HomePage({super.key}); @override State<HomePage> createState() => _HomePageState(); } class _HomePageState extends State<HomePage> with WidgetsBindingObserver { final SessionRepository sessionRepo = Get.put(SessionRepository()); late bool _showBuffer; String result = ''; Map<String, String> queryParameters = {}; late OverlayEntry _overlayEntry; String? duration; String? createdAt; String overlayMessage = "Please wait while we mark your attendance."; bool overlayShown = false; bool isAppActive = true; // Flag to track if the app is active bool isAttendance = false; // Flag to track if attendance is filled @override void didChangeAppLifecycleState(AppLifecycleState state) { switch (state) { case AppLifecycleState.resumed: setState(() { isAppActive = true; // App is now active }); break; case AppLifecycleState.paused: setState(() { isAppActive = false; // App is now inactive }); break; default: break; } } @override void initState() { super.initState(); WidgetsBinding.instance.addObserver(this); _showBuffer = false; _overlayEntry = createOverlayEntry(); } @override void dispose() { WidgetsBinding.instance.removeObserver(this); super.dispose(); } OverlayEntry createOverlayEntry() { return OverlayEntry( builder: (context) => Scaffold( body: Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height, color: Colors.white, child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const CircularProgressIndicator(), Text( overlayMessage, style: const TextStyle(fontSize: 14), ), ], ), ), ), ), ); } void removeOverlay() { setState(() { _overlayEntry.remove(); overlayShown = false; if (isAttendance) { showSnackkBar( icon: const Icon(Icons.done), message: 'Attendance Filled Successfully', ); } else if (!isAttendance) { showSnackkBar( icon: const Icon(Icons.not_interested), message: 'Could not mark attendance because you have switched the application Or Out Of Time', ); } else { showSnackkBar( icon: const Icon(Icons.not_interested), message: 'Oops! You Are Out Of Time', ); } }); } @override Widget build(BuildContext context) { return Scaffold( body: Stack( children: [ Center( child: Column( mainAxisSize: MainAxisSize.min, children: [ ElevatedButton( onPressed: () async { var res = await Navigator.push( context, MaterialPageRoute( builder: (context) => const SimpleBarcodeScannerPage(), ), ); setState(() { if (res is String) { result = res; Uri uri = Uri.parse(result); queryParameters = uri.queryParameters; duration = queryParameters['duration']; createdAt = queryParameters['createdAt']; } }); if (!overlayShown && duration != null && duration!.isNotEmpty) { showOverlay(res); } else { showSnackkBar( icon: const Icon(Icons.not_interested), message: 'Invalid QR Code', ); } }, child: const Text('Open Scanner'), ), ], ), ), _showBuffer ? _overlayEntry as Widget : const SizedBox(), ], ), ); } void showOverlay(String res) async { DateTime currentDate = DateTime.now(); DateTime createdAtTime = DateTime( currentDate.year, currentDate.month, currentDate.day, int.parse(createdAt!.split(":")[0]), int.parse(createdAt!.split(":")[1]), int.parse(createdAt!.split(":")[2]), ); int durationInMinutes = int.tryParse(duration ?? '0') ?? 0; DateTime endTime = createdAtTime.add(Duration(minutes: durationInMinutes)); Overlay.of(context).insert(_overlayEntry); Duration difference = currentDate.difference(endTime).abs(); int remainingSeconds = difference.inSeconds; Future.delayed(Duration(seconds: remainingSeconds), () { removeOverlay(); }); Mapping? map = await sessionRepo.isSessionOpen(); log(map.toString()); if (map != null && isAppActive) { showSnackkBar( icon: const Icon(Icons.done), message: 'Session is Active Filling Attendance', ); if (remainingSeconds > 30) { Future.delayed(Duration(seconds: remainingSeconds - 40), () async { isAttendance = await sessionRepo.fillAttendance(map, getAttendanceData(res)); }); } else { isAttendance = await sessionRepo.fillAttendance(map, getAttendanceData(res)); } } else if (!isAppActive) { showSnackkBar( icon: const Icon(Icons.not_interested), message: 'Could not mark attendance because you have switched the application', ); overlayMessage = 'Please wait till session expires.'; } else { showSnackkBar( icon: const Icon(Icons.not_interested), message: 'Oops! You Are Out Of Time', ); } log(queryParameters.toString()); overlayShown = true; } AttendanceData getAttendanceData(String res) { Uri uri = Uri.parse(res); return AttendanceData( course: uri.queryParameters['course']!, subject: uri.queryParameters['subject']!, sem: uri.queryParameters['sem']!, dividion: uri.queryParameters['division']!, faculty: uri.queryParameters['fid']!, duration: uri.queryParameters['duration']!, createdAt: uri.queryParameters['createdAt']!, ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/screens
mirrored_repositories/eAttendance/eattendance_student/lib/screens/home/home_screen.dart
import 'dart:developer'; import 'package:simple_barcode_scanner/simple_barcode_scanner.dart'; import '../../models/attendance_data.dart'; import '../../models/mapping_model.dart'; import '../../repository/session/session_repository.dart'; import '../../utility/utils.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:provider/provider.dart'; class Home extends StatefulWidget { const Home({super.key}); @override State<Home> createState() => _HomeState(); } class ButtonState extends ChangeNotifier { bool _isButtonEnabled = true; bool get isButtonEnabled => _isButtonEnabled; void disableButton() { _isButtonEnabled = false; notifyListeners(); } } class _HomeState extends State<Home> { bool isButtonDisable = false; SessionRepository sessinRepo = Get.put(SessionRepository()); bool isAttendance = false; @override void initState() { super.initState(); } void disableButton() { setState(() { isButtonDisable = true; }); } @override Widget build(BuildContext context) { final buttonState = Provider.of<ButtonState>(context); return Scaffold( body: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ // const SingleChildScrollView( // child: Padding( // padding: EdgeInsets.all(16.0), // // child: TextField( // // decoration: InputDecoration(labelText: "Enter the OTP"), // // ), // ), // ), Padding( padding: const EdgeInsets.only(left: 115, bottom: 20), child: ElevatedButton( onPressed: buttonState.isButtonEnabled ? () async { var res = await Navigator.push( context, MaterialPageRoute( builder: (context) => const SimpleBarcodeScannerPage(), ), ); Uri uri = Uri.parse(res); Map<String, String> queryParameters = uri.queryParameters; log(queryParameters.toString()); AttendanceData data = AttendanceData( course: queryParameters['course']!.toString(), subject: queryParameters['subject']!.toString(), sem: queryParameters['sem']!.toString(), dividion: queryParameters['division']!.toString(), faculty: queryParameters['fid']!.toString(), duration: queryParameters['duration']!.toString(), createdAt: queryParameters['createdAt']!.toString()); log(data.toString()); // Your action when the button is pressed Mapping? map = await sessinRepo.isSessionOpen(); if (map != null) { showSnackkBar( icon: const Icon(Icons.done), message: 'Session is Active Filling Attendance'); // isAttendance = await sessinRepo.fillAttendance(map); if (isAttendance) { showSnackkBar( icon: const Icon(Icons.done), message: 'Attendance Filled SuccessFully'); } buttonState.disableButton(); } else { showSnackkBar( icon: const Icon(Icons.not_interested), message: 'Session Is Not Active Please Try again When Session is Active', ); } } : null, child: const Text('Mark Attendance'), ), ), //create the second OTP module ], ), ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/screens
mirrored_repositories/eAttendance/eattendance_student/lib/screens/home/circularprocessindicator.dart
import 'package:flutter/material.dart'; class ProcessIndicator extends StatelessWidget { const ProcessIndicator({super.key}); @override Widget build(BuildContext context) { return const Scaffold( body: Center( child: Column( children: [CircularProgressIndicator(), Text('Please wait...')], ), ), ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/screens
mirrored_repositories/eAttendance/eattendance_student/lib/screens/splash/splash_screen.dart
import 'dart:async'; import '../../utility/constants.dart'; import 'package:flutter/material.dart'; class SplashScreen extends StatelessWidget { const SplashScreen({super.key}); @override Widget build(BuildContext context) { Timer(const Duration(seconds: 3), () {}); return Scaffold( body: Container( width: double.infinity, height: double.infinity, decoration: const BoxDecoration(color: Colors.white), child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Column( children: [ Image.asset( appLogo, height: 300.0, width: 300.0, ), const SizedBox( height: 40, ), const Text( appName, textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 18.0, ), ), ], ), const CircularProgressIndicator( color: Colors.green, ), ], ), ), ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/screens
mirrored_repositories/eAttendance/eattendance_student/lib/screens/authentication/register.dart
import '../../screens/authentication/forms/registration_forms.dart'; import 'package:flutter/material.dart'; class RegisterScreen extends StatefulWidget { const RegisterScreen({super.key}); @override State<RegisterScreen> createState() => _RegisterScreenState(); } class _RegisterScreenState extends State<RegisterScreen> with SingleTickerProviderStateMixin { late AnimationController _animationController; late Animation<double> _animation; @override void initState() { super.initState(); _animationController = AnimationController( vsync: this, duration: const Duration( milliseconds: 500, )); _animation = CurvedAnimation( parent: _animationController, curve: Curves.easeIn, ); _animation.addListener(() { setState(() {}); }); _animationController.forward(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.transparent, ), body: SingleChildScrollView( child: Center( child: RegistrationForm( animationController: _animationController, animation: _animation), ), ), ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/screens
mirrored_repositories/eAttendance/eattendance_student/lib/screens/authentication/forgot_password.dart
import '../../screens/authentication/forms/forgotpassword_form.dart'; import 'package:flutter/material.dart'; class ForgotPasswordScreen extends StatefulWidget { const ForgotPasswordScreen({super.key}); @override State<ForgotPasswordScreen> createState() => _ForgotPasswordScreenState(); } class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> with SingleTickerProviderStateMixin { late AnimationController _animationController; late Animation<double> _animation; @override void initState() { super.initState(); _animationController = AnimationController( vsync: this, duration: const Duration( milliseconds: 500, )); _animation = CurvedAnimation( parent: _animationController, curve: Curves.easeIn, ); _animation.addListener(() { setState(() {}); }); _animationController.forward(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.transparent, ), body: SingleChildScrollView( child: Center( child: ForgotPasswordForm( animationController: _animationController, animation: _animation), ), ), ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/screens
mirrored_repositories/eAttendance/eattendance_student/lib/screens/authentication/login.dart
import '../../screens/authentication/forms/login_form.dart'; import 'package:flutter/material.dart'; class LoginScreen extends StatefulWidget { const LoginScreen({super.key}); @override State<LoginScreen> createState() => _LoginScreenState(); } class _LoginScreenState extends State<LoginScreen> with SingleTickerProviderStateMixin { late AnimationController _animationController; late Animation<double> _animation; @override void initState() { super.initState(); _animationController = AnimationController( vsync: this, duration: const Duration( milliseconds: 500, )); _animation = CurvedAnimation( parent: _animationController, curve: Curves.easeIn, ); _animation.addListener(() { setState(() {}); }); _animationController.forward(); } @override Widget build(BuildContext context) { return Scaffold( body: SingleChildScrollView( child: Padding( padding: EdgeInsets.only(top: MediaQuery.sizeOf(context).height / 6), child: Center( child: LoginForm( animationController: _animationController, animation: _animation), ), ), ), ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/screens/authentication
mirrored_repositories/eAttendance/eattendance_student/lib/screens/authentication/forms/forgotpassword_form.dart
import '../../../controllers/forgot_password_controller.dart'; import '../../../utility/constants.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; class ForgotPasswordForm extends StatelessWidget { final AnimationController animationController; final Animation<double> animation; const ForgotPasswordForm({ super.key, required this.animationController, required this.animation, }); @override Widget build(BuildContext context) { final controller = Get.put(ForgotPasswordController()); final formKey = GlobalKey<FormState>(); return Form( key: formKey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( appLogo, height: animationController.value * 125, width: animationController.value * 125, ), const SizedBox(height: 20), const Text( appName, style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold), ), const SizedBox( height: 25, ), Padding( padding: const EdgeInsets.all(16.0), child: TextFormField( controller: controller.email, keyboardType: TextInputType.emailAddress, decoration: const InputDecoration( labelText: 'Enter Your Email', ), ), ), FilledButton.icon( icon: const Icon(Icons.email), label: const Text('Reset Your Password'), onPressed: () async { if (formKey.currentState!.validate()) { // ForgotPasswordController.instance // .resetPassword(controller.email.text.trim()); } }, ), ], ), ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/screens/authentication
mirrored_repositories/eAttendance/eattendance_student/lib/screens/authentication/forms/registration_forms.dart
import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../../utility/constants.dart'; import '../../../controllers/registration_controller.dart'; class RegistrationForm extends StatefulWidget { final AnimationController animationController; final Animation<double> animation; const RegistrationForm({ super.key, required this.animationController, required this.animation, }); @override State<RegistrationForm> createState() => _RegistrationFormState(); } class _RegistrationFormState extends State<RegistrationForm> { @override Widget build(BuildContext context) { final controller = Get.put(RegistrationController()); final formKey = GlobalKey<FormState>(); return Form( key: formKey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( appLogo, height: widget.animationController.value * 100, width: widget.animationController.value * 100, ), const SizedBox(height: 20), const Text( appName, style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold), ), const SizedBox( height: 25, ), Padding( padding: const EdgeInsets.all(16.0), child: TextFormField( controller: controller.name, keyboardType: TextInputType.name, decoration: const InputDecoration( labelText: 'Name', ), ), ), Padding( padding: const EdgeInsets.all(16.0), child: TextFormField( controller: controller.email, keyboardType: TextInputType.emailAddress, decoration: const InputDecoration( labelText: 'Email', ), ), ), Padding( padding: const EdgeInsets.all(16.0), child: TextFormField( controller: controller.password, obscureText: true, decoration: const InputDecoration( labelText: 'Password', ), ), ), Padding( padding: const EdgeInsets.all(8.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ OutlinedButton( child: const Text('LogIn'), onPressed: () async { Navigator.pop(context); }, ), FilledButton( child: const Text('Sign Up'), onPressed: () async { if (formKey.currentState!.validate()) { // final user = UserModel( // name: controller.name.text.trim(), // email: controller.email.text.trim(), // password: controller.password.text.trim(), // ); // RegistrationController.instance.createUser(user); } }, ), ], ), ), ], ), ); } }
0
mirrored_repositories/eAttendance/eattendance_student/lib/screens/authentication
mirrored_repositories/eAttendance/eattendance_student/lib/screens/authentication/forms/login_form.dart
import '../../../utility/constants.dart'; import '../../../controllers/login_controller.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../forgot_password.dart'; class LoginForm extends StatelessWidget { final AnimationController animationController; final Animation<double> animation; const LoginForm({ super.key, required this.animationController, required this.animation, }); @override Widget build(BuildContext context) { final controller = Get.put(LoginController()); final formKey = GlobalKey<FormState>(); return Form( key: formKey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( appLogo, height: animationController.value * 125, width: animationController.value * 125, ), const SizedBox(height: 20), const Text( appName, style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold), ), const SizedBox( height: 25, ), Padding( padding: const EdgeInsets.all(16.0), child: TextFormField( controller: controller.email, keyboardType: TextInputType.emailAddress, decoration: const InputDecoration( labelText: 'Enter Email number', ), ), ), Padding( padding: const EdgeInsets.all(16.0), child: TextFormField( controller: controller.password, obscureText: true, decoration: const InputDecoration( labelText: 'Password', ), ), ), Padding( padding: const EdgeInsets.all(8.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ FilledButton( child: const Text('LogIn'), onPressed: () async { if (formKey.currentState!.validate()) { LoginController.instance.loginUser( controller.email.text.trim(), controller.password.text.trim()); } }, ), ], ), ), TextButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) => const ForgotPasswordScreen())); }, child: const Text( 'Forgot password?', style: TextStyle(color: Colors.black54), ), ), ], ), ); } }
0
mirrored_repositories/eAttendance/eattendance_student
mirrored_repositories/eAttendance/eattendance_student/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:eattendance_student/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/eAttendance/eattendance_faculty
mirrored_repositories/eAttendance/eattendance_faculty/lib/main.dart
import '../../repositories/auth/auth_repository.dart'; import '../../controllers/permissions_controller.dart'; import '../../screens/splash/splash_screen.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:get/get.dart'; Future<void> main() async { WidgetsFlutterBinding.ensureInitialized(); Get.put(AuthenticationRepository()); SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky, overlays: []); Get.put(GrantPermissions()); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return GetMaterialApp( title: 'eAttendance Faculty', debugShowCheckedModeBanner: false, theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.green), inputDecorationTheme: InputDecorationTheme( enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(5), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(5), ), ), appBarTheme: const AppBarTheme( backgroundColor: Colors.green, ), filledButtonTheme: const FilledButtonThemeData( style: ButtonStyle( elevation: MaterialStatePropertyAll(5), ), ), useMaterial3: true, ), home: const SplashScreen(), ); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib
mirrored_repositories/eAttendance/eattendance_faculty/lib/controllers/forgot_password_controller.dart
import '../../repositories/auth/auth_repository.dart'; import 'package:flutter/widgets.dart'; import 'package:get/get.dart'; class ForgotPasswordController extends GetxController { static ForgotPasswordController get instance => Get.find(); final email = TextEditingController(); void resetPassword(email) { AuthenticationRepository.instance.resetPassword(email); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib
mirrored_repositories/eAttendance/eattendance_faculty/lib/controllers/registration_controller.dart
import 'package:flutter/material.dart'; import 'package:get/get.dart'; class RegistrationController extends GetxController { static RegistrationController get instance => Get.find(); final name = TextEditingController(); final email = TextEditingController(); final password = TextEditingController(); // final userRepo = Get.put(UserRepository()); // Future<User?> registerUser(String email, String password) async { // return await AuthenticationRepository.instance // .createUserWithNameEmailAndPassword(email, password); // } // Future<void> createUser(UserModel user) async { // User? userCredential = await registerUser(user.email, user.password); // user.id = userCredential!.uid; // userRepo.createUser(user); // } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib
mirrored_repositories/eAttendance/eattendance_faculty/lib/controllers/permissions_controller.dart
import 'package:get/get.dart'; import 'package:permission_handler/permission_handler.dart'; class GrantPermissions extends GetxController { static GrantPermissions get instance => Get.find(); Future<bool> isCameraGranted() async { bool isGranted = await Permission.camera.request().isGranted; if (!isGranted) { await Permission.camera.request(); } return isGranted; } Future<bool> isMediaGranted() async { bool isGranted = await Permission.mediaLibrary.request().isGranted; if (!isGranted) { await Permission.mediaLibrary.request(); } return isGranted; } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib
mirrored_repositories/eAttendance/eattendance_faculty/lib/controllers/login_controller.dart
import '../../repositories/auth/auth_repository.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; class LoginController extends GetxController { static LoginController get instance => Get.find(); final email = TextEditingController(); final password = TextEditingController(); void loginUser(String email, String password) { AuthenticationRepository.instance .loginUserWithNameEmailAndPassword(email, password); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib
mirrored_repositories/eAttendance/eattendance_faculty/lib/models/subject_model.dart
import 'dart:convert'; class Subject { int subjectId; String subjectName; Subject({ required this.subjectId, required this.subjectName, }); Map<String, dynamic> toMap() { return <String, dynamic>{ 'subjectId': subjectId, 'subjectName': subjectName, }; } factory Subject.fromMap(Map<String, dynamic> map) { return Subject( subjectId: map['subjectId'] as int, subjectName: map['subjectName'] as String, ); } String toJson() => json.encode({ 'subjectId': subjectId, 'subjectName': subjectName, }); factory Subject.fromJson(Map<String, dynamic> map) => Subject( subjectId: map['subjectId'] as int, subjectName: map['subjectName'] as String, ); }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib
mirrored_repositories/eAttendance/eattendance_faculty/lib/models/batch_model.dart
import 'dart:convert'; class Batch { int id; String batchName; Batch({ required this.id, required this.batchName, }); Map<String, dynamic> toMap() { return <String, dynamic>{ 'id': id, 'batchName': batchName, }; } factory Batch.fromMap(Map<String, dynamic> map) { return Batch( id: map['id'] as int, batchName: map['batchName'] as String, ); } String toJson() => json.encode(toMap()); factory Batch.fromJson(String source) => Batch.fromMap(json.decode(source) as Map<String, dynamic>); }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib
mirrored_repositories/eAttendance/eattendance_faculty/lib/models/faculty_model.dart
import 'dart:convert'; class Faculty { int facultyId; String enrollment; String email; String username; String token; Faculty({ required this.facultyId, required this.enrollment, required this.email, required this.username, required this.token, }); Map<String, dynamic> toMap() { return <String, dynamic>{ 'facultyId': facultyId, 'enrollment': enrollment, 'email': email, 'username': username, 'token': token, }; } factory Faculty.fromMap(Map<String, dynamic> map) { return Faculty( facultyId: map['facultyId'] as int, enrollment: map['enrollment'] as String, email: map['email'] as String, username: map['username'] as String, token: map['token'] as String, ); } String toJson() => json.encode(toMap()); factory Faculty.fromJson(String source) => Faculty.fromMap(json.decode(source) as Map<String, dynamic>); }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib
mirrored_repositories/eAttendance/eattendance_faculty/lib/models/token_manager.dart
import 'package:shared_preferences/shared_preferences.dart'; class TokenManager { static const String _tokenKey = 'auth_token'; static Future<String?> getToken() async { SharedPreferences prefs = await SharedPreferences.getInstance(); return prefs.getString(_tokenKey); } static Future<void> saveToken(String token) async { SharedPreferences prefs = await SharedPreferences.getInstance(); await prefs.setString(_tokenKey, token); } static Future<void> removeToken() async { SharedPreferences prefs = await SharedPreferences.getInstance(); await prefs.remove(_tokenKey); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib
mirrored_repositories/eAttendance/eattendance_faculty/lib/models/mapping_model.dart
import 'faculty_model.dart'; import 'semester_model.dart'; import 'subject_model.dart'; class Mapping { int mapId; Course course; Subject subject; Semester semester; Faculty faculty; Mapping({ required this.mapId, required this.course, required this.subject, required this.semester, required this.faculty, }); factory Mapping.fromJson(Map<String, dynamic> json) { return Mapping( mapId: json['mapId'] as int, course: Course.fromJson(json['course']), subject: Subject.fromJson(json['subject']), semester: Semester.fromJson(json['semester']), faculty: Faculty.fromJson(json['faculty']), ); } } class Course { String courseId; // Other properties and constructor Course({ required this.courseId, // Other constructor parameters }); factory Course.fromJson(Map<String, dynamic> json) { return Course( courseId: json['courseId'] as String, // Initialize other properties from the JSON map ); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib
mirrored_repositories/eAttendance/eattendance_faculty/lib/models/course_model.dart
// ignore_for_file: public_member_api_docs, sort_constructors_first import 'dart:convert'; class Course { final int courseId; final String courseName; Course({ required this.courseId, required this.courseName, }); factory Course.fromJson(Map<String, dynamic> json) { return Course( courseId: json['courseId'], courseName: json['courseName'], ); } Map<String, dynamic> toMap() { return <String, dynamic>{ 'courseId': courseId, 'courseName': courseName, }; } factory Course.fromMap(Map<String, dynamic> map) { return Course( courseId: map['courseId'] as int, courseName: map['courseName'] as String, ); } String toJson() => json.encode(toMap()); } extension JsonConversion on Course { Map<String, dynamic> toJson() { return { 'courseId': courseId, 'courseName': courseName, }; } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib
mirrored_repositories/eAttendance/eattendance_faculty/lib/models/semester_model.dart
import 'dart:convert'; // ignore_for_file: public_member_api_docs, sort_constructors_first class Semester { int semesterId; String semesterName; Semester({ required this.semesterId, required this.semesterName, }); Map<String, dynamic> toMap() { return <String, dynamic>{ 'semesterId': semesterId, 'semesterName': semesterName, }; } factory Semester.fromMap(Map<String, dynamic> map) { return Semester( semesterId: map['semesterId'] as int, semesterName: map['semesterName'] as String, ); } String toJson() => json.encode(toMap()); factory Semester.fromJson(Map<String, dynamic> json) { return Semester( semesterId: json['semesterId'], semesterName: json['semesterName'], ); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib
mirrored_repositories/eAttendance/eattendance_faculty/lib/models/auth_request.dart
// ignore_for_file: public_member_api_docs, sort_constructors_first import 'dart:convert'; class AuthRequest { String username; String password; AuthRequest({ required this.username, required this.password, }); AuthRequest copyWith({ String? username, String? password, }) { return AuthRequest( username: username ?? this.username, password: password ?? this.password, ); } Map<String, dynamic> toMap() { return <String, dynamic>{ 'username': username, 'password': password, }; } factory AuthRequest.fromMap(Map<String, dynamic> map) { return AuthRequest( username: map['username'] as String, password: map['password'] as String, ); } String toJson() => json.encode(toMap()); factory AuthRequest.fromJson(String source) => AuthRequest.fromMap(json.decode(source) as Map<String, dynamic>); @override String toString() => 'AuthRequest(username: $username, password: $password)'; @override bool operator ==(covariant AuthRequest other) { if (identical(this, other)) return true; return other.username == username && other.password == password; } @override int get hashCode => username.hashCode ^ password.hashCode; }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib
mirrored_repositories/eAttendance/eattendance_faculty/lib/models/user_model.dart
class UserModel { late String? id; final String name; final String email; final String password; UserModel({ this.id, required this.name, required this.email, required this.password, }); toJson() { return { "Name": name, "email": email, "password": password, }; } Map<String, dynamic> toFirestore() { return { "name": name, "email": email, "country": password, if (id != null) "id": id, }; } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib
mirrored_repositories/eAttendance/eattendance_faculty/lib/utility/constants.dart
const String appName = "eAttendance Faculty"; const String appLogo = "assets/images/logo.png"; Map<String, String> createAuthorizationHeaders(String? token) { return {"Authorization": 'Bearer $token'}; } const endpoint = "/api/v1"; // HOST URL const hosturl = "https://b348-2406-b400-d11-87eb-58c6-324e-a9f1-1203.ngrok-free.app"; const String apiUrl = "$hosturl$endpoint";
0
mirrored_repositories/eAttendance/eattendance_faculty/lib
mirrored_repositories/eAttendance/eattendance_faculty/lib/utility/utils.dart
import 'package:flutter/material.dart'; import 'package:get/get.dart'; void showSnackkBar({message, title = '', icon = const Icon(Icons.done)}) { Get.snackbar( message, title, snackPosition: SnackPosition.BOTTOM, icon: icon, ); }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/repositories
mirrored_repositories/eAttendance/eattendance_faculty/lib/repositories/subject/subject_repository.dart
import 'dart:convert'; import 'package:eattendance_faculty/models/token_manager.dart'; import '../../models/subject_model.dart'; import '../../repositories/course/course_repository.dart'; import '../../utility/constants.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:http/http.dart' as http; class SubjectRepository { static CourseRepository get instance => Get.find(); Future<List<Subject>> getSubjects() async { final response = await http.get(Uri.parse("$apiUrl/subjects/getAll"), headers: createAuthorizationHeaders(await TokenManager.getToken())); if (response.statusCode == 200) { List<dynamic> subjectList = jsonDecode(response.body); List<Subject> subjects = subjectList.map((e) => Subject.fromJson(e)).toList(); return subjects; } else { throw Exception("Failed to Load Subjects"); } } Future<List<DropdownMenuItem<String>>> getSubjectsDropdownItems() async { List<Subject> subjects = await getSubjects(); return subjects .map((subject) => DropdownMenuItem( value: subject.subjectId .toString(), // Assuming 'id' is the unique identifier for the course child: Text(subject .subjectName), // Replace 'name' with the actual course name field )) .toList(); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/repositories
mirrored_repositories/eAttendance/eattendance_faculty/lib/repositories/semsster/semester_repository.dart
import 'dart:convert'; import 'package:eattendance_faculty/models/token_manager.dart'; import '../../models/semester_model.dart'; import '../../utility/constants.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:http/http.dart' as http; class SemesterRepository { static SemesterRepository get instance => Get.find(); Future<List<Semester>> getSemesters() async { final response = await http.get(Uri.parse("$apiUrl/semester/getAll"), headers: createAuthorizationHeaders(await TokenManager.getToken())); if (response.statusCode == 200) { List<dynamic> semesterList = jsonDecode(response.body); List<Semester> semesters = semesterList.map((e) => Semester.fromJson(e)).toList(); return semesters; } else { throw Exception("Failed To Load Semesters"); } } Future<List<DropdownMenuItem<String>>> getSemestersDropdownItems() async { List<Semester> semesters = await getSemesters(); return semesters .map((semester) => DropdownMenuItem( value: semester.semesterId .toString(), // Assuming 'id' is the unique identifier for the course child: Text(semester .semesterName), // Replace 'name' with the actual course name field )) .toList(); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/repositories
mirrored_repositories/eAttendance/eattendance_faculty/lib/repositories/divisions/divisons_repository.dart
import 'dart:convert'; import 'package:eattendance_faculty/models/token_manager.dart'; import '../../utility/constants.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:http/http.dart' as http; class DivisionsRepository { static DivisionsRepository get instance => Get.find(); Future<List<String>> getDivisons() async { final response = await http.get(Uri.parse("$apiUrl/student/getDivisions"), headers: createAuthorizationHeaders(await TokenManager.getToken())); if (response.statusCode == 200) { List<dynamic> divisionList = jsonDecode(response.body); List<String> divisions = divisionList.map((dynamic division) { return division.toString(); }).toList(); return divisions; } else { throw Exception('Failed to load Divisions'); } } Future<List<DropdownMenuItem<String>>> getDivisionDropdownItems() async { List<String> divisions = await getDivisons(); // Assuming getDivisions returns a List of String List<DropdownMenuItem<String>> divisionItems = []; for (String division in divisions) { divisionItems.add(DropdownMenuItem<String>( value: division, child: Text(division), )); } return divisionItems; } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/repositories
mirrored_repositories/eAttendance/eattendance_faculty/lib/repositories/course/course_repository.dart
import 'dart:convert'; import 'package:eattendance_faculty/models/token_manager.dart'; import '../../models/course_model.dart'; import '../../utility/constants.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:http/http.dart' as http; class CourseRepository { static CourseRepository get instance => Get.find(); Future<List<Course>> getCourses() async { final response = await http.get(Uri.parse("$apiUrl/course/getAll"), headers: createAuthorizationHeaders(await TokenManager.getToken())); if (response.statusCode == 200) { List<dynamic> courseList = jsonDecode(response.body); List<Course> courses = courseList.map((json) => Course.fromJson(json)).toList(); return courses; } else { throw Exception('Failed to load courses'); } } Future<List<DropdownMenuItem<String>>> getCoursesDropdownItems() async { List<Course> courses = await getCourses(); return courses .map((course) => DropdownMenuItem( value: course.courseId .toString(), // Assuming 'id' is the unique identifier for the course child: Text(course .courseName), // Replace 'name' with the actual course name field )) .toList(); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/repositories
mirrored_repositories/eAttendance/eattendance_faculty/lib/repositories/auth/auth_repository.dart
import 'package:eattendance_faculty/models/token_manager.dart'; import '../../models/auth_request.dart'; import '../../models/faculty_model.dart'; import '../../screens/authentication/login.dart'; import '../../screens/screen_navigator.dart'; import '../../exceptions/auth/auth_exceptions.dart'; import '../../utility/constants.dart'; import '../../utility/utils.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:http/http.dart' as http; import 'package:shared_preferences/shared_preferences.dart'; class AuthenticationRepository extends GetxController { static AuthenticationRepository get instance => Get.find(); late Rx<Faculty?> faculty = Rx<Faculty?>(null); late SharedPreferences prefs; @override void onReady() async { prefs = await SharedPreferences.getInstance(); bool isLoggedIn = prefs.getBool("isLoggedIn") ?? false; if (isLoggedIn) { faculty.value = Faculty.fromJson(prefs.getString("faculty") ?? Faculty( facultyId: 0, enrollment: 'enrollment', email: 'email', username: 'username', token: 'token', ).toJson()); } _setInitialScreen(faculty); } _setInitialScreen(Rx<Faculty?> user) { user.value == null ? Get.offAll(() => const LoginScreen()) : Get.offAll(() => const ScreenNavigator()); } Future<void> loginUserWithNameEmailAndPassword( String email, String password) async { try { final response = await http.post(Uri.parse("$apiUrl/auth/login"), body: AuthRequest(username: email, password: password).toJson(), headers: {'Content-Type': 'application/json'}); if (response.statusCode == 200) { faculty = Rx<Faculty?>(Faculty.fromJson(response.body)); await prefs.setBool("isLoggedIn", true); await prefs.setString("faculty", faculty.value!.toJson()); await TokenManager.saveToken(faculty.value!.token); } if (response.statusCode == 404) { throw SignUpWithEmailAndPasswordFailure.code("404"); } faculty.value != null ? Get.offAll(() => const ScreenNavigator()) : Get.offAll(() => const LoginScreen()); } catch (_) { final ex = SignUpWithEmailAndPasswordFailure(); showSnackkBar( message: ex.message, title: 'Try Again', icon: const Icon(Icons.error), ); } } Future<void> resetPassword(email) async { Get.offAll(() => const LoginScreen()); showSnackkBar( message: 'Password Reset Mail Send SuccessFully', title: 'Check Your Mail', icon: const Icon(Icons.done), ); } Future<void> logOut() async { prefs.clear(); Get.offAll(() => const LoginScreen()); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/repositories
mirrored_repositories/eAttendance/eattendance_faculty/lib/repositories/session/session_repository.dart
import 'dart:developer'; import 'package:eattendance_faculty/models/token_manager.dart'; import '../../utility/constants.dart'; import 'package:get/get.dart'; import 'package:http/http.dart' as http; class SessionRepository { static SessionRepository get instance => Get.find(); Future<String> startSession(String? selectedCourse, String? selectedSubject, String? selectedSem, String? selectedDivision, int facultyId) async { final response = await http.get( Uri.parse( "$apiUrl/session/start/$selectedCourse/$selectedSubject/$selectedSem/$selectedDivision/$facultyId"), headers: createAuthorizationHeaders(await TokenManager.getToken())); if (response.statusCode == 200) { String result = response.body; return result; } else { throw Exception('Failed to Start Session'); } } Future<String> stopSession(String? selectedCourse, String? selectedSubject, String? selectedSem, String? selectedDivision, int facultyId) async { final response = await http.get( Uri.parse( "$apiUrl/session/stop/$selectedCourse/$selectedSubject/$selectedSem/$selectedDivision/$facultyId"), headers: createAuthorizationHeaders(await TokenManager.getToken())); log(response.body.toString()); if (response.statusCode == 200) { String result = response.body.toString(); return result; } else { return response.body.toString(); } } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/exceptions
mirrored_repositories/eAttendance/eattendance_faculty/lib/exceptions/auth/auth_exceptions.dart
class SignUpWithEmailAndPasswordFailure { final String message; SignUpWithEmailAndPasswordFailure( [this.message = "An Unknown Error Occurred"]); factory SignUpWithEmailAndPasswordFailure.code(String code) { switch (code) { case 'weak-password': return SignUpWithEmailAndPasswordFailure( 'Please Enter A Stronger Password'); case 'invalid-email': return SignUpWithEmailAndPasswordFailure( 'Email is Not valid or badly formated'); case 'email-already-in-use': return SignUpWithEmailAndPasswordFailure( 'An account already exists for this email'); case 'operation-not-allowed': return SignUpWithEmailAndPasswordFailure( 'operation not allowed please contact support team'); case 'user-disabled': return SignUpWithEmailAndPasswordFailure( 'the user has been disabled please contact support for help'); case '404': return SignUpWithEmailAndPasswordFailure( 'Email or Password dosen\'t match'); default: return SignUpWithEmailAndPasswordFailure(); } } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens/screen_navigator.dart
import '../screens/profile/user_profile_screen.dart'; import '../screens/attendance_report/attendance_report.dart'; import '../screens/home/home_screen.dart'; import 'package:flutter/material.dart'; import 'components/drawer_navigation.dart'; import 'components/custom_appbar.dart'; class ScreenNavigator extends StatefulWidget { const ScreenNavigator({super.key}); @override State<ScreenNavigator> createState() => _ScreenNavigatorState(); } class _ScreenNavigatorState extends State<ScreenNavigator> { int _currentIndex = 0; @override Widget build(BuildContext context) { final List<Widget> currentScreen = [ const Home(), const ExpertList(), const UserProfileScreen(), ]; return Scaffold( drawer: const DrawerNavigation(), appBar: CustomAppBar().customAppBar(), body: SafeArea( maintainBottomViewPadding: true, child: Container( color: Colors.greenAccent.withOpacity(0.1), child: currentScreen[_currentIndex], ), ), bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.fixed, items: const [ BottomNavigationBarItem( tooltip: 'Home', icon: Icon(Icons.home), label: 'Home', ), BottomNavigationBarItem( icon: Icon(Icons.picture_as_pdf), label: 'Attendance Report', tooltip: 'Attendance Report', ), BottomNavigationBarItem( icon: Icon(Icons.person), label: 'Profile', tooltip: 'Profile', ) ], currentIndex: _currentIndex, onTap: (index) { setState(() { _currentIndex = index; }); }, ), ); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens/contact_us/contact_us.dart
import '../../utility/constants.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; class ContactUs extends StatelessWidget { const ContactUs({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.white, title: const Text( "Contact Us", style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold), ), ), body: Center( child: Padding( padding: const EdgeInsets.all(20.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ const Image( height: 200, width: 200, image: AssetImage(appLogo), ), const SizedBox(height: 30), buildContactInfo("Our toll-free number:", "816-052-4421"), const SizedBox(height: 20), buildContactInfo("Website:", "Smit Joshi"), const SizedBox(height: 50), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ buildSocialIcon( icon: Icons.phone, iconColor: Colors.green, onTap: () { launchUrl(Uri.parse("tel: +91 8160524421")); }), const SizedBox(width: 20), buildSocialIcon( icon: Icons.web, iconColor: Colors.blue, onTap: () { launchUrl( Uri.parse("https://resumesmitjoshi.blogspot.com/"), mode: LaunchMode.inAppWebView, ); }), ], ), ], ), ), ), ); } Widget buildContactInfo(String label, String value) { return Column( children: [ Text( label, style: const TextStyle( color: Colors.black, fontSize: 20, fontWeight: FontWeight.w600, ), ), const SizedBox(height: 5), Text( value, style: const TextStyle( color: Colors.black, fontSize: 18, ), ), ], ); } Widget buildSocialIcon({icon, iconColor, onTap}) { return GestureDetector( onTap: onTap, child: Container( height: 70, width: 70, decoration: BoxDecoration( color: iconColor, shape: BoxShape.circle, ), child: Center( child: Icon( icon, color: Colors.white, size: 40, ), ), ), ); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens/contact_us/about_us.dart
import '../../utility/constants.dart'; import 'package:flutter/material.dart'; class AboutUs extends StatelessWidget { const AboutUs({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.white, title: const Text( "About Us", style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold), ), ), body: const Center( child: Padding( padding: EdgeInsets.all(20.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Image( height: 200, width: 200, image: AssetImage(appLogo), ), SizedBox(height: 30), Text( "Welcome to our app!", style: TextStyle( color: Colors.black, fontSize: 24, fontWeight: FontWeight.bold, ), ), SizedBox(height: 20), Text( "Our Mission", style: TextStyle( color: Colors.black, fontSize: 20, fontWeight: FontWeight.bold, ), ), SizedBox(height: 10), Text( "To reduce time taken by manual proccess of taking attendance", style: TextStyle( color: Colors.black, fontSize: 18, ), textAlign: TextAlign.center, ), SizedBox(height: 20), Text( "Developed By", style: TextStyle( color: Colors.black, fontSize: 20, fontWeight: FontWeight.bold, ), ), SizedBox(height: 10), Text( "MSCIT Students - Semester 1", style: TextStyle( color: Colors.black, fontSize: 18, ), textAlign: TextAlign.center, ), ], ), ), ), ); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens/components/drawer_navigation.dart
import '../../utility/constants.dart'; import 'package:flutter/material.dart'; import '../../repositories/auth/auth_repository.dart'; import '../contact_us/about_us.dart'; import '../contact_us/contact_us.dart'; class DrawerNavigation extends StatelessWidget { const DrawerNavigation({super.key}); @override Widget build(BuildContext context) { return Drawer( child: Column( children: [ const DrawerHeader( child: Center( child: Image(height: 100, width: 100, image: AssetImage(appLogo)), ), ), ListTile( leading: const Icon(Icons.group), title: const Text( 'About Us', style: TextStyle(fontSize: 20), ), onTap: () { Navigator.of(context).push( MaterialPageRoute(builder: (context) => const AboutUs())); }, ), ListTile( leading: const Icon(Icons.support), title: const Text( 'Contact Us', style: TextStyle(fontSize: 20), ), onTap: () { Navigator.of(context).push( MaterialPageRoute(builder: (context) => const ContactUs())); }, ), // const Spacer(), SizedBox( width: double.infinity, // Full width child: TextButton.icon( label: const Text('LogOut'), onPressed: () { AuthenticationRepository.instance.logOut(); }, icon: const Icon(Icons.logout), ), ), ], ), ); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens/components/dropdown_widget.dart
import 'package:flutter/material.dart'; class DropdownWidget<T> extends StatelessWidget { final String label; final T? value; final List<DropdownMenuItem<T>> items; final ValueChanged<T?> onChanged; const DropdownWidget({ super.key, required this.label, required this.value, required this.items, required this.onChanged, }); @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( label, style: const TextStyle( fontSize: 16, color: Color.fromARGB(255, 17, 41, 1), ), ), Container( width: 250, // Set the width as per your preference decoration: BoxDecoration( border: Border.all( color: const Color.fromARGB(255, 36, 80, 7), width: 1), borderRadius: BorderRadius.circular(10), ), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ DropdownButtonHideUnderline( child: DropdownButton<T>( value: value, items: items, onChanged: onChanged, style: const TextStyle( fontSize: 16, color: Colors.black, ), icon: const Icon(Icons.arrow_drop_down), ), ), ], ), ), ], ); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens/components/custom_appbar.dart
import '../../utility/constants.dart'; import 'package:flutter/material.dart'; class CustomAppBar { PreferredSizeWidget customAppBar({title = appName}) { return AppBar( title: Text( title, style: const TextStyle( color: Colors.black, fontSize: 20, ), ), centerTitle: true, backgroundColor: Colors.transparent, forceMaterialTransparency: true, ); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens/profile/user_profile_screen.dart
import '../../repositories/auth/auth_repository.dart'; import '../../utility/constants.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; class UserProfileScreen extends StatefulWidget { const UserProfileScreen({super.key}); @override State<UserProfileScreen> createState() => _UserProfileScreenState(); } class _UserProfileScreenState extends State<UserProfileScreen> { final AuthenticationRepository authRepo = Get.find(); @override Widget build(BuildContext context) { return Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ const CircleAvatar( backgroundColor: Colors.black12, radius: 60, backgroundImage: AssetImage(appLogo), ), const SizedBox(height: 10), Text( authRepo.faculty.value!.username, style: const TextStyle( fontSize: 24, fontWeight: FontWeight.bold, letterSpacing: 2.5, ), ), const SizedBox( height: 20, width: 200, child: Divider(color: Colors.black12), ), // InfoCard( // text: phone, icon: Icons.phone, onPressed: () async {}), // InfoCard( // text: location, // icon: Icons.location_city, // onPressed: () async {}), InfoCard( text: authRepo.faculty.value!.enrollment, icon: Icons.email, onPressed: () async {}, ), InfoCard( text: authRepo.faculty.value!.email, icon: Icons.email, onPressed: () async {}, ), ], ); } } class InfoCard extends StatelessWidget { final String text; final IconData icon; final Function onPressed; const InfoCard({ super.key, required this.text, required this.icon, required this.onPressed, }); @override Widget build(BuildContext context) { return GestureDetector( child: Card( margin: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 20.0), child: ListTile( leading: Icon( icon, ), title: Text( text, style: const TextStyle( fontSize: 20, ), ), ), ), ); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens/attendance_report/attendance_report.dart
import 'package:flutter/material.dart'; class ExpertList extends StatelessWidget { const ExpertList({super.key}); @override Widget build(BuildContext context) { return Center( child: FilledButton.icon( label: const Text('Download Attendance Report'), icon: const Icon(Icons.document_scanner), onPressed: () {}, ), ); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens/home/home_screen.dart
import '../../repositories/session/session_repository.dart'; import '../../repositories/course/course_repository.dart'; import '../../repositories/divisions/divisons_repository.dart'; import '../../repositories/semsster/semester_repository.dart'; import '../../repositories/subject/subject_repository.dart'; import '../../screens/components/dropdown_widget.dart'; import '../../utility/utils.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../repositories/auth/auth_repository.dart'; class Home extends StatefulWidget { const Home({super.key}); @override State<Home> createState() => _HomeState(); } class _HomeState extends State<Home> { final AuthenticationRepository authRepo = Get.find(); CourseRepository courseRepo = Get.put(CourseRepository()); SubjectRepository subjectRepo = Get.put(SubjectRepository()); SemesterRepository semRepo = Get.put(SemesterRepository()); DivisionsRepository divrepo = Get.put(DivisionsRepository()); SessionRepository sessionRepo = Get.put(SessionRepository()); List<DropdownMenuItem<String>> courses = []; List<DropdownMenuItem<String>> div = []; List<DropdownMenuItem<String>> semesters = []; List<DropdownMenuItem<String>> subjects = []; String? selectedCourse; String? selectedDivision; String? selectedSem; String? selectedSubject; String? result; String? sessionText = "Start Session"; bool isSession = false; @override void initState() { super.initState(); selectedDivision = 'div_1'; // Fetch and set courses data courseRepo.getCoursesDropdownItems().then((result) { setState(() { courses = result; selectedCourse = courses.first.value; }); }); subjectRepo.getSubjectsDropdownItems().then((value) { setState(() { subjects = value; selectedSubject = subjects.first.value; }); }); semRepo.getSemestersDropdownItems().then((value) { setState(() { semesters = value; selectedSem = semesters.first.value; }); }); divrepo.getDivisionDropdownItems().then((value) { setState(() { div = value; selectedDivision = div.first.value; }); }); } @override Widget build(BuildContext context) { return Center( child: Column( children: [ const SizedBox(height: 30), SizedBox( width: 250, child: DropdownWidget( label: 'Select Course:', value: selectedCourse, items: courses, onChanged: (value) { setState(() { selectedCourse = value; }); }, ), ), const SizedBox(height: 20), ConstrainedBox( constraints: const BoxConstraints( maxWidth: 250, ), child: DropdownWidget( label: 'Select Subject:', value: selectedSubject, items: subjects, onChanged: (value) { setState(() { selectedSubject = value; }); }, ), ), const SizedBox(height: 20), SizedBox( width: 250, child: DropdownWidget( label: 'Select Semester:', value: selectedSem, items: semesters, onChanged: (value) { setState(() { selectedSem = value; }); }, ), ), const SizedBox(height: 20), SizedBox( width: 250, child: DropdownWidget( label: 'Select Division:', value: selectedDivision, items: div, onChanged: (value) { setState(() { selectedDivision = value; }); }, ), ), const SizedBox(height: 40), // FilledButton.icon FilledButton.icon( label: Text(isSession ? 'Stop Session' : 'Start Session'), icon: const Icon(Icons.wifi), onPressed: () async { if (!isSession) { result = await sessionRepo.startSession( selectedCourse, selectedSubject, selectedSem, selectedDivision, authRepo.faculty.value!.facultyId); setState(() { result; isSession = true; }); showSnackkBar( icon: const Icon(Icons.done), title: '', message: result); } else { result = await sessionRepo.stopSession( selectedCourse, selectedSubject, selectedSem, selectedDivision, authRepo.faculty.value!.facultyId); setState(() { result; isSession = false; }); showSnackkBar( icon: const Icon(Icons.done), title: '', message: result); } }, ), ], ), ); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens/splash/splash_screen.dart
import 'dart:async'; import '../../utility/constants.dart'; import 'package:flutter/material.dart'; class SplashScreen extends StatelessWidget { const SplashScreen({super.key}); @override Widget build(BuildContext context) { Timer(const Duration(seconds: 3), () {}); return Scaffold( body: Container( width: double.infinity, height: double.infinity, decoration: const BoxDecoration(color: Colors.white), child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Column( children: [ Image.asset( appLogo, height: 300.0, width: 300.0, ), const SizedBox( height: 40, ), const Text( appName, textAlign: TextAlign.center, style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 18.0, ), ), ], ), const CircularProgressIndicator( color: Colors.green, ), ], ), ), ); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens/authentication/register.dart
import '../../screens/authentication/forms/registration_forms.dart'; import 'package:flutter/material.dart'; class RegisterScreen extends StatefulWidget { const RegisterScreen({super.key}); @override State<RegisterScreen> createState() => _RegisterScreenState(); } class _RegisterScreenState extends State<RegisterScreen> with SingleTickerProviderStateMixin { late AnimationController _animationController; late Animation<double> _animation; @override void initState() { super.initState(); _animationController = AnimationController( vsync: this, duration: const Duration( milliseconds: 500, )); _animation = CurvedAnimation( parent: _animationController, curve: Curves.easeIn, ); _animation.addListener(() { setState(() {}); }); _animationController.forward(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.transparent, ), body: SingleChildScrollView( child: Center( child: RegistrationForm( animationController: _animationController, animation: _animation), ), ), ); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens/authentication/forgot_password.dart
import '../../screens/authentication/forms/forgotpassword_form.dart'; import 'package:flutter/material.dart'; class ForgotPasswordScreen extends StatefulWidget { const ForgotPasswordScreen({super.key}); @override State<ForgotPasswordScreen> createState() => _ForgotPasswordScreenState(); } class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> with SingleTickerProviderStateMixin { late AnimationController _animationController; late Animation<double> _animation; @override void initState() { super.initState(); _animationController = AnimationController( vsync: this, duration: const Duration( milliseconds: 500, )); _animation = CurvedAnimation( parent: _animationController, curve: Curves.easeIn, ); _animation.addListener(() { setState(() {}); }); _animationController.forward(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.transparent, ), body: SingleChildScrollView( child: Center( child: ForgotPasswordForm( animationController: _animationController, animation: _animation), ), ), ); } }
0
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens
mirrored_repositories/eAttendance/eattendance_faculty/lib/screens/authentication/login.dart
import '../../screens/authentication/forms/login_form.dart'; import 'package:flutter/material.dart'; class LoginScreen extends StatefulWidget { const LoginScreen({super.key}); @override State<LoginScreen> createState() => _LoginScreenState(); } class _LoginScreenState extends State<LoginScreen> with SingleTickerProviderStateMixin { late AnimationController _animationController; late Animation<double> _animation; @override void initState() { super.initState(); _animationController = AnimationController( vsync: this, duration: const Duration( milliseconds: 500, )); _animation = CurvedAnimation( parent: _animationController, curve: Curves.easeIn, ); _animation.addListener(() { setState(() {}); }); _animationController.forward(); } @override Widget build(BuildContext context) { return Scaffold( body: SingleChildScrollView( child: Padding( padding: EdgeInsets.only(top: MediaQuery.sizeOf(context).height / 6), child: Center( child: LoginForm( animationController: _animationController, animation: _animation), ), ), ), ); } }
0