repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/whalert/lib
mirrored_repositories/whalert/lib/websockets/bitstamp_socket.dart
import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter_trading_volume/models/supported_pairs.dart'; import 'package:flutter_trading_volume/websockets/base_socket.dart'; import 'package:web_socket_channel/html.dart'; class BitstampSocket implements BaseSocket { SupportedPairs pair; HtmlWebSocketChannel socket; BitstampSocket({@required this.pair}); @override HtmlWebSocketChannel connect() { if(socket == null) { socket = HtmlWebSocketChannel.connect(wsUrl()); } if(socket != null && socket.sink != null) { socket.sink.add(wsSubscribeUnsubscribeMessage()); } return socket; } @override void closeConnection() { if(socket != null && socket.sink != null) { socket.sink.add(wsSubscribeUnsubscribeMessage(subscribe: false)); socket.sink.close(); } socket = null; } @override String wsUrl() { return 'wss://ws.bitstamp.net'; } @override String wsSubscribeUnsubscribeMessage({bool subscribe = true}) { return json.encode({ 'event': subscribe ? 'bts:subscribe' : 'bts:subscribe', 'data': { 'channel': 'live_trades_${pair.toStringUSD().toLowerCase()}' } }); } }
0
mirrored_repositories/whalert/lib/websockets
mirrored_repositories/whalert/lib/websockets/callbacks/exchange_callbacks.dart
import 'package:flutter_trading_volume/models/trades/base_trade.dart'; abstract class ExchangeCallbacks { void onTrade(BaseTrade trade, int id); }
0
mirrored_repositories/whalert/lib/websockets
mirrored_repositories/whalert/lib/websockets/manager/exchange_manager.dart
import 'dart:convert'; import 'package:archive/archive.dart'; import 'package:flutter_trading_volume/models/supported_pairs.dart'; import 'package:flutter_trading_volume/models/trades/binance_trade.dart'; import 'package:flutter_trading_volume/models/trades/bitfinex_trade.dart'; import 'package:flutter_trading_volume/models/trades/bitmex_trade.dart'; import 'package:flutter_trading_volume/models/trades/bitstamp_trade.dart'; import 'package:flutter_trading_volume/models/trades/bybit_trade.dart'; import 'package:flutter_trading_volume/models/trades/coinbase_trade.dart'; import 'package:flutter_trading_volume/models/trades/ftx_trade.dart'; import 'package:flutter_trading_volume/models/trades/kraken_trade.dart'; import 'package:flutter_trading_volume/models/trades/okex_trade.dart'; import 'package:flutter_trading_volume/utils/constants.dart'; import 'package:flutter_trading_volume/websockets/bitstamp_socket.dart'; import 'package:flutter_trading_volume/websockets/callbacks/exchange_callbacks.dart'; import 'package:flutter_trading_volume/websockets/coinbase_socket.dart'; import 'package:flutter_trading_volume/websockets/huobi_socket.dart'; import 'package:flutter_trading_volume/websockets/okex_socket.dart'; import '../binance_socket.dart'; import '../bitfinex_socket.dart'; import '../bitmex_socket.dart'; import '../bybit_socket.dart'; import '../ftx_socket.dart'; import '../kraken_socket.dart'; class ExchangeManager { SupportedPairs _currentPair; //Sockets BinanceSocket _binanceSocket; FtxSocket _ftxSocket; ByBitSocket _byBitSocket; BitmexSocket _bitmexSocket; BitfinexSocket _bitfinexSocket; KrakenSocket _krakenSocket; BitstampSocket _bitstampSocket; CoinbaseSocket _coinbaseSocket; HuobiSocket _huobiSocket; OkExSocket _okExSocket; //Callbacks ExchangeCallbacks _exchangeCallbacks; ExchangeManager(SupportedPairs pair, ExchangeCallbacks callbacks) { this._exchangeCallbacks = callbacks; this._currentPair = pair; _initExchanges(); } void _initExchanges() { _binanceSocket = new BinanceSocket(pair: _currentPair); _ftxSocket = new FtxSocket(pair: _currentPair); _byBitSocket = new ByBitSocket(pair: _currentPair); _bitmexSocket = new BitmexSocket(pair: _currentPair); _bitfinexSocket = new BitfinexSocket(pair: _currentPair); _krakenSocket = new KrakenSocket(pair: _currentPair); _bitstampSocket = new BitstampSocket(pair: _currentPair); _coinbaseSocket = new CoinbaseSocket(pair: _currentPair); _huobiSocket = new HuobiSocket(pair: _currentPair); _okExSocket = new OkExSocket(pair: _currentPair); } void updatePairs(SupportedPairs pair) { this._currentPair = pair; _initExchanges(); } void _listenForDataUpdate() { _binanceSocket.socket.stream.listen((event) { final trade = BinanceTrade.fromJson(event.toString()); _exchangeCallbacks.onTrade(trade, BINANCE_PRICE_ID); }); _ftxSocket.socket.stream.listen((event) { final trades = FtxTrade.fromJson(event.toString()); if(trades != null && trades.isNotEmpty) { trades.forEach((trade) { _exchangeCallbacks.onTrade(trade, FTX_PRICE_ID); }); } }); _byBitSocket.socket.stream.listen((event) { final trade = ByBitTrade.fromJson(event.toString()); _exchangeCallbacks.onTrade(trade, BYBIT_PRICE_ID); }); _bitmexSocket.socket.stream.listen((event) { final trade = BitmexTrade.fromJson(event.toString()); _exchangeCallbacks.onTrade(trade, BITMEX_PRICE_ID); }); _bitfinexSocket.socket.stream.listen((event) { final trades = BitfinexTrade.fromJson(event.toString()); if(trades != null && trades.isNotEmpty) { trades.forEach((trade) { _exchangeCallbacks.onTrade(trade, BITFINEX_PRICE_ID); }); } }); _krakenSocket.socket.stream.listen((event) { final trades = KrakenTrade.fromJson(event.toString()); if(trades != null && trades.isNotEmpty) { trades.forEach((trade) { _exchangeCallbacks.onTrade(trade, KRAKEN_PRICE_ID); }); } }); _bitstampSocket.socket.stream.listen((event) { final trade = BitstampTrade.fromJson(event.toString()); _exchangeCallbacks.onTrade(trade, BITSTAMP_PRICE_ID); }); _coinbaseSocket.socket.stream.listen((event) { final trade = CoinbaseTrade.fromJson(event.toString()); _exchangeCallbacks.onTrade(trade, COINBASE_PRICE_ID); }); _okExSocket.socket.stream.listen((event) { final inflater = Inflate(event); final trades = OkExTrade.fromJson(utf8.decode(inflater.getBytes())); if(trades != null && trades.isNotEmpty) { trades.forEach((trade) { _exchangeCallbacks.onTrade(trade, OKEX_PRICE_ID); }); } }); //TODO: connection doesn't work, why?... _huobiSocket.socket.stream.listen((event) { //print(event); //final trade = CoinbaseTrade.fromJson(event.toString()); //_exchangeCallbacks.onTrade(trade, COINBASE_PRICE_ID); }); } void connectToSocket() { if (_binanceSocket.socket == null/* && (_currentExchange == SupportedExchange.ALL || _currentExchange == SupportedExchange.BINANCE)*/) { _binanceSocket.connect(); } if (_ftxSocket.socket == null/* && (_currentExchange == SupportedExchange.ALL || _currentExchange == SupportedExchange.FTX)*/) { _ftxSocket.connect(); } if(_byBitSocket.socket == null && _currentPair == SupportedPairs.BTC_USDT){ //TODO: Currently we don't support other pairs for ByBit _byBitSocket.connect(); } if(_bitmexSocket.socket == null && _currentPair == SupportedPairs.BTC_USDT){ //TODO: Currently we don't support other pairs for BitMEX _bitmexSocket.connect(); } if(_bitfinexSocket.socket == null ){ _bitfinexSocket.connect(); } if(_krakenSocket.socket == null ){ _krakenSocket.connect(); } if(_bitstampSocket.socket == null ){ _bitstampSocket.connect(); } if(_coinbaseSocket.socket == null ){ _coinbaseSocket.connect(); } if(_huobiSocket.socket == null ){ _huobiSocket.connect(); } if(_okExSocket.socket == null ){ _okExSocket.connect(); } _listenForDataUpdate(); } void closeConnection() { _binanceSocket.closeConnection(); _ftxSocket.closeConnection(); _byBitSocket.closeConnection(); _bitmexSocket.closeConnection(); _bitfinexSocket.closeConnection(); _krakenSocket.closeConnection(); _bitstampSocket.closeConnection(); _coinbaseSocket.closeConnection(); _huobiSocket.closeConnection(); _okExSocket.closeConnection(); } }
0
mirrored_repositories/whalert/lib
mirrored_repositories/whalert/lib/utils/constants.dart
const WALLET_PUBLIC_ADDR = "1BhC5AgogaeNfqmaonKJwGQxaHMK8wHSsA"; const GITHUB_URL = "https://github.com/michelelacorte/whalert"; const EXPORT_CSV_FILENAME = 'export.csv'; const BINANCE_PRICE_ID = 1; const FTX_PRICE_ID = 2; const BYBIT_PRICE_ID = 3; const BITMEX_PRICE_ID = 4; const BITFINEX_PRICE_ID = 5; const KRAKEN_PRICE_ID = 6; const BITSTAMP_PRICE_ID = 7; const COINBASE_PRICE_ID = 8; const OKEX_PRICE_ID = 9;
0
mirrored_repositories/whalert/lib
mirrored_repositories/whalert/lib/utils/utils.dart
import 'dart:convert'; import 'dart:math' as math; import 'package:flutter_trading_volume/utils/constants.dart'; import 'package:universal_html/html.dart' as html; void downloadStringAsCsv(String toExport) { final bytes = utf8.encode(toExport); final blob = html.Blob([bytes]); final url = html.Url.createObjectUrlFromBlob(blob); final anchor = html.document.createElement('a') as html.AnchorElement ..href = url ..style.display = 'none' ..download = EXPORT_CSV_FILENAME; html.document.body.children.add(anchor); anchor.click(); html.document.body.children.remove(anchor); html.Url.revokeObjectUrl(url); } String humanReadableNumberGenerator(double num, {int asFixed = 4}) { final numAbs = num.abs(); if (numAbs > 999 && numAbs < 99999) { return "${(num / 1000).toStringAsFixed(1)}K "; } else if (numAbs > 99999 && numAbs < 999999) { return "${(num / 1000).toStringAsFixed(0)}K "; } else if (numAbs > 999999 && numAbs < 999999999) { return "${(num / 1000000).toStringAsFixed(1)}M "; } else if (numAbs > 999999999) { return "${(num / 1000000000).toStringAsFixed(1)}B "; } else { return num.toStringAsFixed(asFixed); } } extension FancyIterable on Iterable<int> { int get max => reduce(math.max); int get min => reduce(math.min); }
0
mirrored_repositories/whalert/lib
mirrored_repositories/whalert/lib/utils/decimal_text_input_formatter.dart
import 'package:flutter/services.dart'; import 'dart:math' as math; class DecimalTextInputFormatter extends TextInputFormatter { DecimalTextInputFormatter({this.decimalRange}) : assert(decimalRange == null || decimalRange > 0); final int decimalRange; @override TextEditingValue formatEditUpdate( TextEditingValue oldValue, // unused. TextEditingValue newValue, ) { TextSelection newSelection = newValue.selection; String truncated = newValue.text; if (decimalRange != null) { String value = newValue.text; if (value.contains(".") && value.substring(value.indexOf(".") + 1).length > decimalRange) { truncated = oldValue.text; newSelection = oldValue.selection; } else if (value == ".") { truncated = "0."; newSelection = newValue.selection.copyWith( baseOffset: math.min(truncated.length, truncated.length + 1), extentOffset: math.min(truncated.length, truncated.length + 1), ); } return TextEditingValue( text: truncated, selection: newSelection, composing: TextRange.empty, ); } return newValue; } }
0
mirrored_repositories/whalert
mirrored_repositories/whalert/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_trading_volume/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/coder_status
mirrored_repositories/coder_status/lib/main.dart
import 'dart:async'; import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/firebase_layer/authenticate.dart'; import 'package:coder_status/firebase_layer/googleSignInProvider.dart'; import 'package:coder_status/components/noInternet.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter_phoenix/flutter_phoenix.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import 'package:provider/provider.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); SystemChrome.setPreferredOrientations( [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]); runApp(Phoenix(child: MyApp())); } class MyApp extends StatefulWidget { MyApp({Key key}) : super(key: key); @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { // ignore: cancel_subscriptions StreamSubscription subscription; @override void initState() { super.initState(); InternetConnectionChecker().onStatusChange.listen((status) { final hasInternet = status == InternetConnectionStatus.connected; if (!hasInternet) noInternet(context); }); } @override Widget build(BuildContext context) { return ChangeNotifierProvider( create: (context) => GoogleSigInProvider(), child: MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( accentColor: ColorSchemeClass.primarygreen, primaryColor: ColorSchemeClass.primarygreen, scaffoldBackgroundColor: ColorSchemeClass.dark, textTheme: TextTheme( bodyText1: TextStyle(fontFamily: 'young', color: Colors.white), headline1: TextStyle(fontFamily: 'young', color: Colors.white))), home: Authenticate()), ); } }
0
mirrored_repositories/coder_status
mirrored_repositories/coder_status/lib/home.dart
import 'dart:async'; import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/urls.dart'; import 'package:coder_status/firebase_layer/getUserInfo.dart'; import 'package:coder_status/screens/myDashboardScreen.dart'; import 'package:coder_status/screens/peersScreen.dart'; import 'package:coder_status/screens/rankingScreen.dart'; import 'package:coder_status/screens/searchScreen.dart'; import 'package:coder_status/screens/settingScreen.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import 'components/generalLoader.dart'; import 'components/myAvatarButton.dart'; import 'components/noInternet.dart'; class Home extends StatefulWidget { @override State<StatefulWidget> createState() => HomeState(); } class HomeState extends State<Home> { StreamSubscription subscription; bool isFirstTimeFlag = true; String avatarurl = Urls.avatar1url; String _currentPage = "MyDashboardScreen"; List<String> pageKeys = [ "RankingScreen", "SearchScreen", "MyDashboardScreen", "PeersScreen", "SettingsScreen" ]; Map<String, GlobalKey<NavigatorState>> _navigatorKeys = { "RankingScreen": GlobalKey<NavigatorState>(), "SearchScreen": GlobalKey<NavigatorState>(), "MyDashboardScreen": GlobalKey<NavigatorState>(), "PeersScreen": GlobalKey<NavigatorState>(), "SettingsScreen": GlobalKey<NavigatorState>(), }; int _selectedIndex = 2; void _selectTab(String tabItem, int index) { if (tabItem == _currentPage) { _navigatorKeys[tabItem].currentState.popUntil((route) => route.isFirst); } else { setState(() { _currentPage = pageKeys[index]; _selectedIndex = index; }); } } readyUserData() async { if (!await InternetConnectionChecker().hasConnection) { noInternet(this.context); return; } avatarurl = await GetUserInfo.getUserAvatarUrl(); setState(() { isFirstTimeFlag = false; }); } Future futureFunction; @override initState() { super.initState(); futureFunction = readyUserData(); subscription = InternetConnectionChecker().onStatusChange.listen((status) { final hasInternet = status == InternetConnectionStatus.connected; if (!hasInternet) noInternet(this.context); }); } @override void dispose() { subscription.cancel(); super.dispose(); } @override Widget build(BuildContext context) { return isFirstTimeFlag ? FutureBuilder( future: futureFunction, builder: (context, snapshot) { return Scaffold( body: GeneralLoader(''), ); }) : WillPopScope( onWillPop: () async { final isFirstRouteInCurrentTab = !await _navigatorKeys[_currentPage].currentState.maybePop(); if (isFirstRouteInCurrentTab) { if (_currentPage != "MyDashboardScreen") { _selectTab("MyDashBoardScreen", 2); return false; } } // let system handle back button if we're on the first route return isFirstRouteInCurrentTab; }, child: Scaffold( body: Stack(children: <Widget>[ _buildOffstageNavigator("RankingScreen"), _buildOffstageNavigator("SearchScreen"), _buildOffstageNavigator("MyDashboardScreen"), _buildOffstageNavigator("PeersScreen"), _buildOffstageNavigator("SettingsScreen"), ]), bottomNavigationBar: Theme( data: ThemeData( splashColor: Colors.transparent, primaryColor: ColorSchemeClass.primarygreen, accentColor: ColorSchemeClass.primarygreen), child: BottomNavigationBar( backgroundColor: ColorSchemeClass.dark, showSelectedLabels: true, showUnselectedLabels: true, unselectedItemColor: ColorSchemeClass.lightgrey, unselectedLabelStyle: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.017), selectedLabelStyle: TextStyle( color: ColorSchemeClass.primarygreen, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.017), unselectedIconTheme: IconThemeData( opacity: 0.7, size: MediaQuery.of(context).size.height * 0.04, color: ColorSchemeClass.lightgrey), selectedIconTheme: IconThemeData( opacity: 1, size: MediaQuery.of(context).size.height * 0.04, color: ColorSchemeClass.primarygreen), onTap: (int index) { _selectTab(pageKeys[index], index); }, currentIndex: _selectedIndex, items: [ BottomNavigationBarItem( icon: (_selectedIndex == 0) ? FaIcon(FontAwesomeIcons.trophy) : Icon(Icons.emoji_events_outlined), label: 'Ranking', ), BottomNavigationBarItem( icon: (_selectedIndex == 1) ? FaIcon(FontAwesomeIcons.search) : Icon(Icons.search), label: 'Search', ), BottomNavigationBarItem( icon: (_selectedIndex == 2) ? MyAvatarButton(Image.network(avatarurl), true) : MyAvatarButton(Image.network(avatarurl), false), label: 'Profile', ), BottomNavigationBarItem( icon: (_selectedIndex == 3) ? FaIcon(FontAwesomeIcons.users) : Icon(CupertinoIcons.person_3), label: 'Peers', ), BottomNavigationBarItem( icon: (_selectedIndex == 4) ? FaIcon(FontAwesomeIcons.cog) : Icon(Icons.settings_outlined), label: 'Settings', ), ], type: BottomNavigationBarType.fixed, ), ), ), ); } /* Widget _buildOffstageNavigator(String tabItem) { return Offstage( offstage: _currentPage != tabItem, child: TabNavigator( navigatorKey: _navigatorKeys[tabItem], tabItem: tabItem, ), ); } }*/ Widget _buildOffstageNavigator(String tabItem) { Widget child; if (tabItem == "RankingScreen") child = RankingScreen(); else if (tabItem == "SearchScreen") child = SearchScreen(); else if (tabItem == "MyDashboardScreen") child = MyDashboardScreen(); else if (tabItem == "PeersScreen") child = PeersScreen(); else if (tabItem == "SettingsScreen") child = SettingScreen(); return Offstage( offstage: _currentPage != tabItem, child: Navigator( key: _navigatorKeys[tabItem], onGenerateRoute: (routeSettings) { return MaterialPageRoute(builder: (context) => child); }, )); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/mySettingTiles.dart
import 'package:flutter/material.dart'; import 'colorscheme.dart'; //ignore: must_be_immutable class MySettingsNonExpansionTile extends StatelessWidget { Icon leadingIcon; String title; Color tilecolor; Color extrusioncolor; MySettingsNonExpansionTile(Icon leadingIcon, String title, [Color tilecolor = ColorSchemeClass.unactivatedblack, Color extrusioncolor = ColorSchemeClass.darkgrey]) { this.leadingIcon = leadingIcon; this.title = title; this.tilecolor = tilecolor; this.extrusioncolor = extrusioncolor; } @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.symmetric(vertical: 4), child: Container( padding: EdgeInsets.all(4), width: double.infinity, child: Column( children: [ Container( width: double.infinity, child: Theme( data: ThemeData( splashColor: Colors.transparent, highlightColor: Colors.transparent, hoverColor: Colors.transparent, unselectedWidgetColor: ColorSchemeClass.lightgrey, accentColor: ColorSchemeClass.dark, fontFamily: 'young', textTheme: TextTheme( subtitle1: TextStyle(color: ColorSchemeClass.lightgrey))), child: DecoratedBox( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), boxShadow: [ BoxShadow( spreadRadius: 0, color: extrusioncolor.withOpacity(0.5), offset: Offset(0, 4), blurRadius: 0, ) ], ), child: ClipRRect( borderRadius: BorderRadius.circular(15), child: ListTile( tileColor: tilecolor, leading: leadingIcon, title: Text( title, style: TextStyle( fontSize: MediaQuery.of(context).size.height * 0.025, fontWeight: FontWeight.bold), ), ), ), ), ), ) ], )), ); } } //ignore: must_be_immutable class MySettingsExpansionTile extends StatelessWidget { Icon leadingIcon; String title; List<Widget> children; MySettingsExpansionTile( Icon leadingIcon, String title, List<Widget> children) { this.leadingIcon = leadingIcon; this.title = title; this.children = children; } @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.symmetric(vertical: 4), child: Container( padding: EdgeInsets.all(4), width: double.infinity, child: Column( children: [ Container( width: double.infinity, child: Theme( data: ThemeData( splashColor: Colors.transparent, highlightColor: Colors.transparent, hoverColor: Colors.transparent, unselectedWidgetColor: ColorSchemeClass.lightgrey, accentColor: ColorSchemeClass.dark, fontFamily: 'young', textTheme: TextTheme( subtitle1: TextStyle(color: ColorSchemeClass.lightgrey))), child: DecoratedBox( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), boxShadow: [ BoxShadow( spreadRadius: 0, color: ColorSchemeClass.darkgrey.withOpacity(0.5), offset: Offset(0, 4), blurRadius: 0, ) ], ), child: ClipRRect( borderRadius: BorderRadius.circular(15), child: ExpansionTile( collapsedBackgroundColor: ColorSchemeClass.unactivatedblack, backgroundColor: ColorSchemeClass.lightgrey, leading: leadingIcon, title: Text( title, style: TextStyle( fontSize: MediaQuery.of(context).size.height * 0.025, fontWeight: FontWeight.bold), ), children: children, ), ), ), ), ) ], )), ); } } //ignore: must_be_immutable class MyChildListTile extends StatelessWidget { Icon leadingicon; String title; Color fontcolor; MyChildListTile(Icon leadingicon, String title, [Color fontcolor = ColorSchemeClass.dark]) { this.leadingicon = leadingicon; this.title = title; this.fontcolor = fontcolor; } @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 0), child: ListTile( tileColor: ColorSchemeClass.lightgrey, leading: leadingicon, title: Text( title, style: TextStyle( color: fontcolor, fontSize: MediaQuery.of(context).size.height * 0.02, fontWeight: FontWeight.bold), ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/noInternet.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/myButtons.dart'; import 'package:flutter/material.dart'; import 'package:flutter_phoenix/flutter_phoenix.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import 'package:rive/rive.dart'; noInternet(BuildContext context) { OverlayState overlayState = Overlay.of(context); OverlayEntry overlayEntry; overlayEntry = OverlayEntry(builder: (context) { return Scaffold( body: SafeArea( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Flexible( child: Container( height: MediaQuery.of(context).size.height * 0.45, child: RiveAnimation.asset( 'assets/cup-crying.riv', fit: BoxFit.fitHeight, ), ), ), Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: [ Flexible( child: Icon( Icons.wifi_off, color: Colors.white, size: MediaQuery.of(context).size.height * 0.08, ), ), SizedBox( width: MediaQuery.of(context).size.width * 0.05, ), Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( 'No Internet', style: TextStyle( color: Colors.white, fontFamily: 'young', fontWeight: FontWeight.bold, fontSize: MediaQuery.of(context).size.height * 0.05), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Text( 'Please connect to Internet', textAlign: TextAlign.center, style: TextStyle( color: Colors.white.withOpacity(0.8), fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.025), ), ], ) ], ), SizedBox( height: MediaQuery.of(context).size.height * 0.1, ), Flexible( child: Container( width: MediaQuery.of(context).size.height * 0.5, child: MyButton(ColorSchemeClass.primarygreen, 'Try Again', () { Phoenix.rebirth(context); }, Icons.refresh), ), ) ], ), ), ); }); overlayState.insert(overlayEntry); InternetConnectionChecker().onStatusChange.listen((status) { final hasInternet = status == InternetConnectionStatus.connected; if (!hasInternet) Phoenix.rebirth(context); }); }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/topThreeRankingCard.dart
import 'package:coder_status/components/myCircleAvatar.dart'; import 'package:flutter/material.dart'; import 'package:rive/rive.dart'; import 'colorscheme.dart'; //ignore: must_be_immutable class TopThreeRankingCard extends StatelessWidget { String avatarurl1 = '', avatarurl2 = '', avatarurl3 = '', userhandle1 = '', userhandle2 = '', userhandle3 = '', userRating1 = '', userRating2 = '', userRating3 = ''; TopThreeRankingCard( this.avatarurl1, this.avatarurl2, this.avatarurl3, this.userhandle1, this.userhandle2, this.userhandle3, this.userRating1, this.userRating2, this.userRating3); @override Widget build(BuildContext context) { return ListTile( title: Stack( children: [ Container( width: double.infinity, height: MediaQuery.of(context).size.height * 0.45, ), Column( children: [ SizedBox( height: MediaQuery.of(context).size.height * 0.1, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( width: MediaQuery.of(context).size.width * 0.4, height: MediaQuery.of(context).size.height * 0.45, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Flexible( child: Icon( Icons.arrow_drop_down, color: ColorSchemeClass.lightgrey, size: MediaQuery.of(context).size.height * 0.032, ), ), Flexible( child: FittedBox( fit: BoxFit.scaleDown, child: Text( '2', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.032), ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02), Container( height: MediaQuery.of(context).size.width * 0.3, width: MediaQuery.of(context).size.width * 0.3, child: MyCircleAvatar(Image.network(avatarurl2))), SizedBox( height: MediaQuery.of(context).size.height * 0.03, ), Flexible( child: Container( width: MediaQuery.of(context).size.width * 0.2, child: FittedBox( fit: BoxFit.scaleDown, child: Text( '@' + userhandle2, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.03), ), ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01, ), Flexible( child: FittedBox( fit: BoxFit.scaleDown, child: Text( userRating2 + ' pts', style: TextStyle( color: ColorSchemeClass.primarygreen, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.04), ), ), ) ], ), ), Center( child: Container( width: MediaQuery.of(context).size.width * 0.4, height: MediaQuery.of(context).size.height * 0.45, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Flexible( child: Icon( Icons.arrow_drop_down, color: ColorSchemeClass.lightgrey, size: MediaQuery.of(context).size.height * 0.032, ), ), Flexible( child: FittedBox( fit: BoxFit.scaleDown, child: Text( '3', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.032), ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02), Container( height: MediaQuery.of(context).size.width * 0.3, width: MediaQuery.of(context).size.width * 0.3, child: MyCircleAvatar(Image.network(avatarurl3))), SizedBox( height: MediaQuery.of(context).size.height * 0.03, ), Flexible( child: Container( width: MediaQuery.of(context).size.width * 0.2, child: FittedBox( fit: BoxFit.scaleDown, child: Text( '@' + userhandle3, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.03), )), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01, ), Flexible( child: FittedBox( fit: BoxFit.scaleDown, child: Text( userRating3 + ' pts', style: TextStyle( color: ColorSchemeClass.primarygreen, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.04), ), ), ) ], ), ), ), ], ), ], ), Center( child: Container( width: MediaQuery.of(context).size.width * 0.4, height: MediaQuery.of(context).size.height * 0.45, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Flexible( child: Icon( Icons.arrow_drop_down, color: ColorSchemeClass.lightgrey, size: MediaQuery.of(context).size.height * 0.032, ), ), Flexible( child: FittedBox( fit: BoxFit.scaleDown, child: Text( '1', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.032), ), ), ), Flexible( child: Container( height: MediaQuery.of(context).size.height * 0.05, width: MediaQuery.of(context).size.height * 0.05, child: RiveAnimation.asset('assets/crown.riv'), ), ), SizedBox(height: MediaQuery.of(context).size.height * 0.02), Container( height: MediaQuery.of(context).size.width * 0.4, width: MediaQuery.of(context).size.width * 0.4, child: MyCircleAvatar(Image.network(avatarurl1))), SizedBox( height: MediaQuery.of(context).size.height * 0.03, ), Flexible( child: Container( width: MediaQuery.of(context).size.width * 0.2, child: FittedBox( fit: BoxFit.scaleDown, child: Text( '@' + userhandle1, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.025), ), ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01, ), Flexible( child: FittedBox( fit: BoxFit.scaleDown, child: Text( userRating1 + ' pts', style: TextStyle( color: ColorSchemeClass.primarygreen, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.04), ), ), ) ], ), ), ), ], ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/myButtons.dart
import 'package:flutter/material.dart'; import 'colorscheme.dart'; // ignore: must_be_immutable class MyButton extends StatelessWidget { Function dofunction; bool prominent; Color buttoncolor; Color titlecolor; String title; IconData iconData; MyButton(Color buttoncolor, String title, Function dofunction, [IconData iconData = Icons.no_encryption, Color titlecolor = Colors.white]) { this.prominent = prominent; this.title = title; this.dofunction = dofunction; this.titlecolor = titlecolor; this.buttoncolor = buttoncolor; this.iconData = iconData; } @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.02), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), color: buttoncolor, boxShadow: [ BoxShadow( color: buttoncolor.withOpacity(0.4), offset: Offset( 0, MediaQuery.of(context).size.height * 0.007, ), spreadRadius: 0, blurRadius: 0) ]), height: MediaQuery.of(context).size.height * 0.07, width: double.infinity, child: MaterialButton( onPressed: dofunction, minWidth: double.infinity, height: double.infinity, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ iconData == Icons.no_encryption ? SizedBox.shrink() : Row( children: [ Icon( iconData, color: ColorSchemeClass.lightgrey, size: MediaQuery.of(context).size.height * 0.03, ), SizedBox( width: MediaQuery.of(context).size.height * 0.025, ) ], ), Flexible( child: Container( child: FittedBox( fit: BoxFit.contain, child: Text( title, textAlign: TextAlign.center, style: TextStyle( color: titlecolor, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.025), ), ), ), ), ], ), ), ), ); } } //ignore: must_be_immutable class MyOutlineButton extends StatelessWidget { Function dofunction; bool prominent; Color buttoncolor; Color titlecolor; String title; IconData iconData; MyOutlineButton(Color buttoncolor, String title, Function dofunction, [IconData iconData = Icons.no_encryption]) { this.prominent = prominent; this.title = title; this.dofunction = dofunction; titlecolor = buttoncolor; this.buttoncolor = buttoncolor; this.iconData = iconData; } @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 8), child: Container( decoration: BoxDecoration( color: Colors.transparent, border: Border.all(color: buttoncolor, width: 3), borderRadius: BorderRadius.circular(7)), height: MediaQuery.of(context).size.height * 0.076, width: double.infinity, child: MaterialButton( onPressed: dofunction, minWidth: double.infinity, height: double.infinity, child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ iconData == Icons.no_encryption ? SizedBox() : Row( children: [ Icon( iconData, color: buttoncolor, size: MediaQuery.of(context).size.height * 0.03, ), SizedBox( width: MediaQuery.of(context).size.height * 0.025, ) ], ), Flexible( child: Container( child: FittedBox( fit: BoxFit.scaleDown, child: Text( title, textAlign: TextAlign.center, style: TextStyle( color: titlecolor, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.025), ), ), ), ), ], ), ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/myAppBar.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:coder_status/components/colorscheme.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; //Add below as parent to myAppBar : //PreferredSize( preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.12), //ignore: must_be_immutable class MyAppBar extends StatelessWidget { String title; MyAppBar(String title) { this.title = title; } @override Widget build(BuildContext context) { return AppBar( backgroundColor: ColorSchemeClass.dark, centerTitle: true, title: Text( title, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.035), ), ); } } //ignore: must_be_immutable class MyAppBarWithBack extends StatelessWidget { String title; MyAppBarWithBack(String title) { this.title = title; } @override Widget build(BuildContext context) { return AppBar( backgroundColor: ColorSchemeClass.dark, leading: GestureDetector( onTap: () { Navigator.pop(context); }, child: Center( child: FaIcon(FontAwesomeIcons.angleLeft, size: MediaQuery.of(context).size.height * 0.05, color: ColorSchemeClass.lightgrey), ), ), centerTitle: true, title: Text( title, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.035), ), ); } } //ignore: must_be_immutable class MyAppBarWithBackAndDone extends StatelessWidget { String title; Function function; MyAppBarWithBackAndDone(String title, Function function) { this.title = title; this.function = function; } @override Widget build(BuildContext context) { return AppBar( backgroundColor: ColorSchemeClass.dark, leading: GestureDetector( onTap: () { Navigator.pop(context); }, child: Center( child: FaIcon(FontAwesomeIcons.angleLeft, size: MediaQuery.of(context).size.height * 0.05, color: ColorSchemeClass.lightgrey), ), ), actions: [ GestureDetector( onTap: function, child: Padding( padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.height * 0.01), child: Center( child: FaIcon(FontAwesomeIcons.check, size: MediaQuery.of(context).size.height * 0.05, color: ColorSchemeClass.primarygreen), ), ), ) ], centerTitle: true, title: Text( title, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.035), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/myOtherCircleAvatar.dart
import 'package:flutter/material.dart'; //ignore: must_be_immutable class MyOtherCircleAvatar extends StatelessWidget { Image avatarimage; Color borderColor; MyOtherCircleAvatar(this.avatarimage, this.borderColor); @override Widget build(BuildContext context) { return Container( height: double.infinity, width: double.infinity, decoration: BoxDecoration( border: Border.all(color: borderColor, width: 4), shape: BoxShape.circle, image: DecorationImage(fit: BoxFit.fitWidth, image: avatarimage.image)), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/codeforcesDialog.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:flutter/material.dart'; import 'package:glassmorphism_ui/glassmorphism_ui.dart'; showCodeforcesDialog(BuildContext context, Rect rect, String codeforcesHandle, String codeforcesRating) { String codeforcesTitle = ''; int rating = int.parse(codeforcesRating); if (rating <= 1199) { codeforcesTitle = 'NEWBIE'; } else if (rating <= 1399) { codeforcesTitle = 'PUPIL'; } else if (rating <= 1599) { codeforcesTitle = 'SPECIALIST'; } else if (rating <= 1899) { codeforcesTitle = 'EXPERT'; } else if (rating <= 2099) { codeforcesTitle = 'CANDIDATE MASTER'; } else if (rating <= 2299) { codeforcesTitle = 'MASTER'; } else if (rating <= 2399) { codeforcesTitle = 'INTERNATIONAL MASTER'; } else if (rating <= 2599) { codeforcesTitle = 'GRANDMASTER'; } else if (rating <= 2999) { codeforcesTitle = 'INTERNATIONAL GRANDMASTER'; } else if (rating >= 3000) { codeforcesTitle = 'LEGENDARY GRANDMASTER'; } OverlayState overlayState = Overlay.of(context); OverlayEntry overlayEntry; overlayEntry = OverlayEntry(builder: (context) { return GestureDetector( onTap: () { overlayEntry.remove(); }, child: Container( padding: EdgeInsets.all(0), height: double.infinity, width: double.infinity, color: Colors.transparent, child: Column( children: [ SizedBox( height: rect.top - MediaQuery.of(context).size.height * 0.13, ), Row( children: [ SizedBox( width: rect.left - MediaQuery.of(context).size.width * 0.034, ), GestureDetector( onTap: () {}, child: Stack( children: [ GlassContainer( blur: 3, width: MediaQuery.of(context).size.width * 0.42, height: MediaQuery.of(context).size.height * 0.1265, borderRadius: BorderRadius.circular(10), ), Container( width: MediaQuery.of(context).size.width * 0.42, height: MediaQuery.of(context).size.height * 0.157, decoration: BoxDecoration( image: DecorationImage( fit: BoxFit.fill, image: AssetImage( 'images/dialogCodeforces.png'))), child: Container( margin: EdgeInsets.fromLTRB( MediaQuery.of(context).size.width * 0.02, MediaQuery.of(context).size.width * 0.025, MediaQuery.of(context).size.width * 0.02, MediaQuery.of(context).size.height * 0.04), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Flexible( child: FittedBox( fit: BoxFit.scaleDown, child: Row( children: [ Text( 'Platform : ', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.018), ), Text( 'CODEFORCES', style: TextStyle( color: ColorSchemeClass .codeforcespurple, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.02, fontWeight: FontWeight.bold), ) ], ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01), Flexible( child: FittedBox( fit: BoxFit.scaleDown, child: Row( children: [ Text( 'Username : ', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.018), ), Text( '@' + codeforcesHandle, style: TextStyle( color: ColorSchemeClass .codeforcespurple, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.02, fontWeight: FontWeight.bold), ) ], ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01), Flexible( child: Row( children: [ Text( 'Rating : ', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.018), ), Text( codeforcesRating, style: TextStyle( color: ColorSchemeClass .codeforcespurple, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.025, fontWeight: FontWeight.bold), ), Text( ' pts', style: TextStyle( color: ColorSchemeClass .codeforcespurple, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.015, fontWeight: FontWeight.bold), ) ], ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01), Flexible( child: FittedBox( fit: BoxFit.scaleDown, child: Row( children: [ Text( 'Title : ', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.018), ), Text( codeforcesTitle, style: TextStyle( color: ColorSchemeClass .codeforcespurple, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.02, fontWeight: FontWeight.bold), ) ], ), ), ) ], ), ), ), ], ), ), ], ) ], )), ); }); overlayState.insert(overlayEntry); }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/showAnimatedToast.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; void showAnimatedToast(BuildContext context, String headline, bool alert) { FToast myToast = FToast(); myToast.init(context); myToast.showToast( child: AnimatedToast(alert, context, headline), gravity: ToastGravity.CENTER, toastDuration: Duration(seconds: 3), fadeDuration: 700); } //ignore: must_be_immutable class AnimatedToast extends StatefulWidget { String headline = ''; bool alert; Icon leadingIcon; Color toastColor; BuildContext context; AnimatedToast(bool alert, BuildContext context, String headline) { this.alert = alert; this.headline = headline; this.context = context; } @override _AnimatedToastState createState() => _AnimatedToastState(alert, context, headline); } class _AnimatedToastState extends State<AnimatedToast> { String headline = ''; bool alert; IconData leadingIcon; Color toastColor; double height; BuildContext context; double opacity; _AnimatedToastState(bool alert, BuildContext context, String headline) { this.context = context; this.alert = alert; this.opacity = 0.02; this.height = 0; this.headline = headline; if (alert) { leadingIcon = Icons.check_circle; toastColor = ColorSchemeClass.primarygreen; } else { leadingIcon = Icons.error; toastColor = ColorSchemeClass.dangerred; } } @override void initState() { super.initState(); WidgetsBinding.instance.addPostFrameCallback((_) { setState(() { height = MediaQuery.of(context).size.height * 0.3; opacity = 1; }); }); } @override Widget build(BuildContext context) { return Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.end, children: [ AnimatedOpacity( opacity: opacity, duration: Duration(milliseconds: 300), child: Container( width: MediaQuery.of(context).size.width * 0.9, decoration: BoxDecoration( color: toastColor.withOpacity(0.5), borderRadius: BorderRadius.circular(15), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.7), offset: Offset.fromDirection( 1.57, MediaQuery.of(context).size.height * 0.008), blurRadius: 5, spreadRadius: 1) ]), padding: EdgeInsets.symmetric( vertical: MediaQuery.of(context).size.height * 0.01, horizontal: MediaQuery.of(context).size.width * 0.05), child: Row( children: [ Icon(leadingIcon, color: ColorSchemeClass.lightgrey, size: MediaQuery.of(context).size.height * 0.05), SizedBox( width: MediaQuery.of(context).size.width * 0.06, ), Flexible( child: Text( headline, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontWeight: FontWeight.bold, fontSize: MediaQuery.of(context).size.height * 0.018), ), ) ], ), ), ), AnimatedContainer( duration: Duration(milliseconds: 500), height: height, curve: Curves.decelerate, ) ], ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/myUserTile.dart
import 'package:coder_status/screens/viewAnotherUserScreen.dart'; import 'package:flutter/material.dart'; import 'colorscheme.dart'; //ignore: must_be_immutable class MyUserTile extends StatelessWidget { String uid, avatarUrl, name, codername; MyUserTile(this.uid, this.avatarUrl, this.name, this.codername); @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.02, vertical: MediaQuery.of(context).size.width * 0.01), child: ListTile( title: GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return ViewAnotherUserScreen(uid); })); }, child: Container( width: MediaQuery.of(context).size.width * 0.9, height: MediaQuery.of(context).size.height * 0.08, decoration: BoxDecoration( color: ColorSchemeClass.unactivatedblack, borderRadius: BorderRadius.circular(100), boxShadow: [ BoxShadow( color: ColorSchemeClass.darkgrey.withOpacity(0.3), offset: Offset( 0, MediaQuery.of(context).size.height * 0.005, ), blurRadius: 0, spreadRadius: 0) ]), child: Row( children: [ Flexible( child: CircleAvatar( backgroundImage: NetworkImage(avatarUrl), radius: MediaQuery.of(context).size.height * 0.04, ), ), SizedBox( width: MediaQuery.of(context).size.width * 0.15, ), Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Flexible( child: Container( width: MediaQuery.of(context).size.width * 0.4, child: FittedBox( fit: BoxFit.scaleDown, child: Text( name, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontWeight: FontWeight.bold, fontSize: MediaQuery.of(context).size.height * 0.025), ), ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01, ), Flexible( child: Container( width: MediaQuery.of(context).size.width * 0.4, child: FittedBox( fit: BoxFit.scaleDown, child: Text( '@' + codername, style: TextStyle( color: ColorSchemeClass.lightgrey.withOpacity(0.6), fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02), ), ), ), ) ], ) ], ), ), ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/urls.dart
class Urls { static String avatar1url = "https://firebasestorage.googleapis.com/v0/b/coderstatus.appspot.com/o/avatar1.jpg?alt=media&token=e09f9c48-1f5b-44d7-8401-6410e3623e53"; static String avatar2url = "https://firebasestorage.googleapis.com/v0/b/coderstatus.appspot.com/o/avatar2.jpg?alt=media&token=d8129ee5-3e43-44fa-8ef6-15cb1e76f9b7"; static String avatar3url = "https://firebasestorage.googleapis.com/v0/b/coderstatus.appspot.com/o/avatar3.jpg?alt=media&token=4fbe71fa-8051-472e-873f-417ffe78a055"; static String avatar4url = "https://firebasestorage.googleapis.com/v0/b/coderstatus.appspot.com/o/avatar4.jpg?alt=media&token=8fd037b8-2ec1-4445-b736-c6173db86c85"; static String avatar5url = "https://firebasestorage.googleapis.com/v0/b/coderstatus.appspot.com/o/avatar5.jpg?alt=media&token=ce62004a-4084-4789-9213-86074dd6c9a5"; static String avatar6url = "https://firebasestorage.googleapis.com/v0/b/coderstatus.appspot.com/o/avatar6.jpg?alt=media&token=c2ae7f5a-b04c-466c-942f-41540885fa3d"; static String avatar7url = "https://firebasestorage.googleapis.com/v0/b/coderstatus.appspot.com/o/avatar7.jpg?alt=media&token=4e032cb6-12fe-4501-bfca-ac118393a949"; }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/confirmationDialog.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/myButtons.dart'; import 'package:flutter/material.dart'; showConfirmationDialog(BuildContext context, String title, String message, Function toDoIfConfirmed, bool alertType, [IconData displayIcon = Icons.done]) async { return await showDialog<bool>( context: context, builder: (context) { return GestureDetector( onTap: () { Navigator.of(context).pop(); }, child: Scaffold( backgroundColor: ColorSchemeClass.dark.withOpacity(0.5), body: Padding( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.15), child: Center( child: GestureDetector( onTap: () {}, child: Container( decoration: BoxDecoration( color: alertType ? ColorSchemeClass.primarygreen : ColorSchemeClass.dangerred, borderRadius: BorderRadius.circular(10)), width: double.infinity, child: Padding( padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.04), child: Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Row( mainAxisAlignment: MainAxisAlignment.end, mainAxisSize: MainAxisSize.max, children: [ GestureDetector( onTap: () { Navigator.of(context).pop(); }, child: Icon( Icons.close, color: Colors.white.withOpacity(0.5), size: MediaQuery.of(context).size.height * 0.03, ), ) ], ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Container( width: double.infinity, child: FittedBox( fit: BoxFit.scaleDown, child: Text( title, textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontSize: MediaQuery.of(context).size.height * 0.05, fontFamily: 'young', fontWeight: FontWeight.bold), ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Icon( displayIcon, color: Colors.white, size: MediaQuery.of(context).size.height * 0.1, ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Text( message, textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontSize: MediaQuery.of(context).size.height * 0.025, fontFamily: 'young'), ), SizedBox( height: MediaQuery.of(context).size.height * 0.03, ), Container( height: MediaQuery.of(context).size.height * 0.06, child: FittedBox( fit: BoxFit.scaleDown, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: MediaQuery.of(context).size.width * 0.3, child: MyOutlineButton( Colors.white, 'No', () { Navigator.of(context).pop(); }, ), ), SizedBox( width: MediaQuery.of(context).size.width * 0.05, ), Container( width: MediaQuery.of(context).size.width * 0.3, child: MyButton(Colors.white, 'Yes', () { toDoIfConfirmed(); Navigator.of(context).pop(); }, null, alertType ? ColorSchemeClass.primarygreen : ColorSchemeClass.dangerred), ), ], ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.03, ), ], ), ), ), ), ), ), ), ); }); }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/introSlider.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:flutter/material.dart'; import '../home.dart'; class IntroSlider extends StatefulWidget { const IntroSlider({Key key}) : super(key: key); @override _IntroSliderState createState() => _IntroSliderState(); } class _IntroSliderState extends State<IntroSlider> { final controller = PageController(initialPage: 0); int currentPage = 0; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: ColorSchemeClass.primarygreen, body: Column( children: [ Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.06), width: double.infinity, height: MediaQuery.of(context).size.height * 0.15, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Row( mainAxisAlignment: MainAxisAlignment.end, mainAxisSize: MainAxisSize.max, children: [ GestureDetector( onTap: () { Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) { return Home(); }), ModalRoute.withName('/home')); }, child: Text( 'Skip', style: TextStyle( color: Colors.white.withOpacity(0.8), fontFamily: 'young', fontSize: MediaQuery.of(context).size.width * 0.05), ), ), SizedBox( width: MediaQuery.of(context).size.width * 0.04, ), GestureDetector( onTap: () { if (currentPage == 2) { Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) { return Home(); }), ModalRoute.withName('/home')); } else { controller.animateToPage(currentPage + 1, duration: Duration(milliseconds: 300), curve: Curves.easeInOut); } }, child: Text( 'Next', style: TextStyle( color: Colors.white, fontFamily: 'young', fontSize: MediaQuery.of(context).size.width * 0.05), ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: [ currentPage == 0 ? OnDOt() : OffDot(), currentPage == 1 ? OnDOt() : OffDot(), currentPage == 2 ? OnDOt() : OffDot(), ], ) ], ), ), Flexible( child: PageView( onPageChanged: (index) { setState(() { currentPage = index; }); }, controller: controller, children: [ Container( width: double.infinity, height: double.infinity, child: Image.asset( 'images/mockUpArt1.jpg', fit: BoxFit.fitHeight, ), ), Container( width: double.infinity, height: double.infinity, child: Image.asset( 'images/mockUpArt2.jpg', fit: BoxFit.fitHeight, ), ), Container( width: double.infinity, height: double.infinity, child: Image.asset( 'images/mockUpArt3.jpg', fit: BoxFit.fitHeight, ), ), ], ), ), ], ), ); } } class OnDOt extends StatelessWidget { @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.symmetric( vertical: 0, horizontal: MediaQuery.of(context).size.width * 0.01), width: MediaQuery.of(context).size.width * 0.05, height: MediaQuery.of(context).size.height * 0.01, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(100)), ); } } class OffDot extends StatelessWidget { @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.symmetric( vertical: 0, horizontal: MediaQuery.of(context).size.width * 0.01), width: MediaQuery.of(context).size.width * 0.025, height: MediaQuery.of(context).size.height * 0.01, decoration: BoxDecoration( color: Colors.white.withOpacity(0.7), borderRadius: BorderRadius.circular(100)), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/myDividerWithTitle.dart
import 'package:flutter/material.dart'; import 'colorscheme.dart'; //ignore: must_be_immutable class MyDividerWithTitle extends StatelessWidget { String title; MyDividerWithTitle(this.title); @override Widget build(BuildContext context) { return Row( children: [ Flexible( flex: 1, child: Divider( color: ColorSchemeClass.darkgrey, endIndent: MediaQuery.of(context).size.width * 0.02, ), ), Text( title, style: TextStyle( color: ColorSchemeClass.darkgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.025), ), Flexible( flex: 14, child: Divider( color: ColorSchemeClass.darkgrey, indent: MediaQuery.of(context).size.width * 0.02, ), ), ], ); } } //ignore: must_be_immutable class MyMidDividerWithTitle extends StatelessWidget { String title; MyMidDividerWithTitle(this.title); @override Widget build(BuildContext context) { return Row( children: [ Flexible( flex: 1, child: Divider( color: ColorSchemeClass.darkgrey, endIndent: MediaQuery.of(context).size.width * 0.02, ), ), Text( title, style: TextStyle( color: ColorSchemeClass.darkgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.025), ), Flexible( flex: 1, child: Divider( color: ColorSchemeClass.darkgrey, indent: MediaQuery.of(context).size.width * 0.02, ), ), ], ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/rankingScreenSkeleton.dart
import 'package:flutter/material.dart'; import 'package:rive/rive.dart'; import 'colorscheme.dart'; class RankingScreenSkeleton extends StatefulWidget { @override _RankingScreenSkeletonState createState() => _RankingScreenSkeletonState(); } class _RankingScreenSkeletonState extends State<RankingScreenSkeleton> { @override Widget build(BuildContext context) { return ListView( children: [ TopThreeSkeleton(), MyRankingUserTileSkeleton(4), MyRankingUserTileSkeleton(5), MyRankingUserTileSkeleton(6), MyRankingUserTileSkeleton(7), MyRankingUserTileSkeleton(8), MyRankingUserTileSkeleton(9), MyRankingUserTileSkeleton(10) ], ); } } class TopThreeSkeleton extends StatelessWidget { const TopThreeSkeleton({ Key key, }) : super(key: key); @override Widget build(BuildContext context) { return ListTile( title: Stack( children: [ Container( width: double.infinity, height: MediaQuery.of(context).size.height * 0.45, ), Column( children: [ SizedBox( height: MediaQuery.of(context).size.height * 0.1, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( width: MediaQuery.of(context).size.width * 0.4, height: MediaQuery.of(context).size.height * 0.45, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.arrow_drop_down, color: ColorSchemeClass.lightgrey, size: MediaQuery.of(context).size.height * 0.032, ), FittedBox( fit: BoxFit.scaleDown, child: Text( '2', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.032), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02), ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( height: MediaQuery.of(context).size.width * 0.3, width: MediaQuery.of(context).size.width * 0.3, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, )), ), SizedBox( height: MediaQuery.of(context).size.height * 0.03, ), /*Container( width: MediaQuery.of(context).size.width * 0.2, child: FittedBox( fit: BoxFit.scaleDown, child: Text( '@' + userhandle2, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.03), ), ), ),*/ ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( height: MediaQuery.of(context).size.height * 0.03, width: MediaQuery.of(context).size.width * 0.2, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, )), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01, ), /*FittedBox( fit: BoxFit.scaleDown, child: Text( userRating2 + ' pts', style: TextStyle( color: ColorSchemeClass.primarygreen, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.04), ), )*/ ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( height: MediaQuery.of(context).size.height * 0.04, width: double.infinity, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, )), ), ], ), ), Center( child: Container( width: MediaQuery.of(context).size.width * 0.4, height: MediaQuery.of(context).size.height * 0.45, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.arrow_drop_down, color: ColorSchemeClass.lightgrey, size: MediaQuery.of(context).size.height * 0.032, ), FittedBox( fit: BoxFit.scaleDown, child: Text( '3', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.032), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02), ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( height: MediaQuery.of(context).size.width * 0.3, width: MediaQuery.of(context).size.width * 0.3, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, )), ), SizedBox( height: MediaQuery.of(context).size.height * 0.03, ), ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( height: MediaQuery.of(context).size.height * 0.03, width: MediaQuery.of(context).size.width * 0.2, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, )), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01, ), /*FittedBox( fit: BoxFit.scaleDown, child: Text( userRating3 + ' pts', style: TextStyle( color: ColorSchemeClass.primarygreen, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.04), ), )*/ ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( height: MediaQuery.of(context).size.height * 0.04, width: double.infinity, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, )), ), ], ), ), ), ], ), ], ), Center( child: Container( width: MediaQuery.of(context).size.width * 0.4, height: MediaQuery.of(context).size.height * 0.45, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.arrow_drop_down, color: ColorSchemeClass.lightgrey, size: MediaQuery.of(context).size.height * 0.032, ), FittedBox( fit: BoxFit.scaleDown, child: Text( '1', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.032), ), ), Container( height: MediaQuery.of(context).size.height * 0.05, width: MediaQuery.of(context).size.height * 0.05, child: RiveAnimation.asset('assets/crown.riv'), ), SizedBox(height: MediaQuery.of(context).size.height * 0.02), ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( height: MediaQuery.of(context).size.width * 0.4, width: MediaQuery.of(context).size.width * 0.4, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, )), ), SizedBox( height: MediaQuery.of(context).size.height * 0.03, ), /*Container( width: MediaQuery.of(context).size.width * 0.2, child: FittedBox( fit: BoxFit.scaleDown, child: Text( '@' + userhandle1, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.025), ), ), ),*/ ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( height: MediaQuery.of(context).size.height * 0.025, width: MediaQuery.of(context).size.width * 0.2, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, )), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01, ), /*FittedBox( fit: BoxFit.scaleDown, child: Text( userRating1 + ' pts', style: TextStyle( color: ColorSchemeClass.primarygreen, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.04), ), )*/ ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( height: MediaQuery.of(context).size.height * 0.04, width: double.infinity, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, )), ), ], ), ), ), ], ), ); } } //ignore: must_be_immutable class MyRankingUserTileSkeleton extends StatelessWidget { int rank; MyRankingUserTileSkeleton(this.rank); @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.02, vertical: MediaQuery.of(context).size.width * 0.01), child: ListTile( title: Row( children: [ Container( width: MediaQuery.of(context).size.width * 0.1, child: Center( child: Row( children: [ Icon( Icons.play_arrow, size: MediaQuery.of(context).size.width * 0.05, color: ColorSchemeClass.lightgrey, ), SizedBox( width: MediaQuery.of(context).size.width * 0.015, ), Container( width: MediaQuery.of(context).size.width * 0.03, child: FittedBox( fit: BoxFit.scaleDown, child: Text( rank.toString(), style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.width * 0.06), ), ), ), ], ), ), ), SizedBox( width: MediaQuery.of(context).size.width * 0.05, ), Container( width: MediaQuery.of(context).size.width * 0.7, height: MediaQuery.of(context).size.height * 0.08, decoration: BoxDecoration( color: ColorSchemeClass.unactivatedblack, borderRadius: BorderRadius.circular(100), boxShadow: [ BoxShadow( color: ColorSchemeClass.darkgrey.withOpacity(0.3), offset: Offset( 0, MediaQuery.of(context).size.height * 0.005, ), blurRadius: 0, spreadRadius: 0) ]), child: Row( children: [ ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( height: MediaQuery.of(context).size.height * 0.08, width: MediaQuery.of(context).size.height * 0.08, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, )), ), SizedBox( width: MediaQuery.of(context).size.width * 0.03, ), Row( children: [ ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( height: MediaQuery.of(context).size.height * 0.02, width: MediaQuery.of(context).size.width * 0.24, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, )), ), SizedBox( width: MediaQuery.of(context).size.width * 0.03, ), ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( height: MediaQuery.of(context).size.height * 0.03, width: MediaQuery.of(context).size.width * 0.2, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, )), ), ], ) ], ), ), ], ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/myTextFormFields.dart
import 'package:flutter/material.dart'; import 'colorscheme.dart'; import 'constants.dart'; //ignore: must_be_immutable class MyTextFormField extends StatelessWidget { Icon tficon; String tfhintText; bool isobscure; Function onchangedfunction; TextInputType textinputtype; Function validation; Color bordercolor; TextEditingController textEditingController; MyTextFormField( Icon tficon, String tfhintText, bool isobscure, Function onchangedfunction, TextInputType textinputtype, Function validation, [TextEditingController textEditingController, Color bordercolor = ColorSchemeClass.primarygreen]) { this.tficon = tficon; this.tfhintText = tfhintText; this.isobscure = isobscure; this.onchangedfunction = onchangedfunction; this.textinputtype = textinputtype; this.validation = validation; this.bordercolor = bordercolor; this.textEditingController = textEditingController; } @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.02, ), child: TextFormField( textAlignVertical: TextAlignVertical.center, controller: textEditingController, validator: validation, onChanged: onchangedfunction, keyboardType: textinputtype, cursorColor: bordercolor, obscureText: isobscure, style: TextStyle( color: Colors.white, fontFamily: 'young', fontSize: 17, fontWeight: FontWeight.normal), decoration: myInputDecoration.copyWith( hintText: tfhintText, prefixIcon: tficon, focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(5), borderSide: BorderSide(color: bordercolor, width: 2)), ), ), ); } } //ignore: must_be_immutable class MyPassageTextEormField extends StatelessWidget { String tfhintText; Function onchangedfunction; Function validation; Color bordercolor; TextEditingController textEditingController; MyPassageTextEormField( String tfhintText, Function onchangedfunction, Function validation, [ TextEditingController textEditingController, Color bordercolor = ColorSchemeClass.primarygreen, ]) { this.tfhintText = tfhintText; this.onchangedfunction = onchangedfunction; this.validation = validation; this.bordercolor = bordercolor; this.textEditingController = textEditingController; } @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.02, ), child: TextFormField( controller: textEditingController, maxLines: null, validator: validation, onChanged: onchangedfunction, keyboardType: TextInputType.multiline, cursorColor: bordercolor, obscureText: false, style: TextStyle( color: Colors.white, fontFamily: 'young', fontSize: 17, fontWeight: FontWeight.normal), decoration: myPassageInputDecoration.copyWith( hintText: tfhintText, focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(5), borderSide: BorderSide(color: bordercolor, width: 2)), ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/spojDialog.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:flutter/material.dart'; import 'package:glassmorphism_ui/glassmorphism_ui.dart'; showSpojDialog( BuildContext context, Rect rect, String spojHandle, String spojRating) { OverlayState overlayState = Overlay.of(context); OverlayEntry overlayEntry; overlayEntry = OverlayEntry(builder: (context) { return GestureDetector( onTap: () { overlayEntry.remove(); }, child: Container( height: double.infinity, width: double.infinity, color: Colors.transparent, child: Column( children: [ SizedBox( height: rect.top - MediaQuery.of(context).size.height * 0.13, ), Row( children: [ SizedBox( width: rect.left - MediaQuery.of(context).size.width * 0.034, ), GestureDetector( onTap: () {}, child: Stack( children: [ Container( width: MediaQuery.of(context).size.width * 0.42, height: MediaQuery.of(context).size.height * 0.1265, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: ColorSchemeClass.unactivatedblack .withOpacity(0.7), ), ), GlassContainer( blur: 3, width: MediaQuery.of(context).size.width * 0.42, height: MediaQuery.of(context).size.height * 0.1265, borderRadius: BorderRadius.circular(10), ), Container( width: MediaQuery.of(context).size.width * 0.42, height: MediaQuery.of(context).size.height * 0.157, decoration: BoxDecoration( image: DecorationImage( fit: BoxFit.fill, image: AssetImage('images/dialogSpoj.png'))), child: Container( margin: EdgeInsets.fromLTRB( MediaQuery.of(context).size.width * 0.02, MediaQuery.of(context).size.width * 0.025, MediaQuery.of(context).size.width * 0.02, MediaQuery.of(context).size.height * 0.04), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Flexible( child: FittedBox( fit: BoxFit.scaleDown, child: Row( children: [ Text( 'Platform : ', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.018), ), Text( 'SPOJ', style: TextStyle( color: ColorSchemeClass.spojblue, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.02, fontWeight: FontWeight.bold), ) ], ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01), Flexible( child: FittedBox( fit: BoxFit.scaleDown, child: Row( children: [ Text( 'Username : ', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.018), ), Text( '@' + spojHandle, style: TextStyle( color: ColorSchemeClass.spojblue, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.02, fontWeight: FontWeight.bold), ) ], ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01), Flexible( child: Row( children: [ Text( 'Rating : ', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.018), ), Text( spojRating, style: TextStyle( color: ColorSchemeClass.spojblue, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.025, fontWeight: FontWeight.bold), ), Text( ' pts', style: TextStyle( color: ColorSchemeClass.spojblue, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.015, fontWeight: FontWeight.bold), ) ], ), ) ], ), ), ), ], ), ), ], ) ], )), ); }); overlayState.insert(overlayEntry); }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/constants.dart
import 'package:flutter/material.dart'; import 'colorscheme.dart'; InputDecoration myInputDecoration = InputDecoration( contentPadding: EdgeInsets.all(5), fillColor: ColorSchemeClass.darkgrey, filled: true, prefixIcon: Icon( Icons.transit_enterexit, color: ColorSchemeClass.lightgrey, ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(5), borderSide: BorderSide(color: ColorSchemeClass.primarygreen, width: 2)), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(5), ), errorBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(5), borderSide: BorderSide(color: Colors.red, width: 1)), focusedErrorBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(5), borderSide: BorderSide(color: Colors.red, width: 2)), hintText: 'Enter a value', hintStyle: TextStyle(color: ColorSchemeClass.unactivatedblack, fontSize: 17)); InputDecoration myPassageInputDecoration = InputDecoration( fillColor: ColorSchemeClass.darkgrey, filled: true, focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(5), borderSide: BorderSide(color: ColorSchemeClass.primarygreen, width: 2)), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(5), ), errorBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(5), borderSide: BorderSide(color: Colors.red, width: 1)), focusedErrorBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(5), borderSide: BorderSide(color: Colors.red, width: 2)), hintText: 'Enter a value', hintStyle: TextStyle(color: ColorSchemeClass.unactivatedblack, fontSize: 17));
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/myAvatarButton.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:flutter/material.dart'; //ignore: must_be_immutable class MyAvatarButton extends StatelessWidget { Image avatarimage; double borderwidth = 2; Color bordercolor = ColorSchemeClass.lightgrey; MyAvatarButton(Image avatarimage, bool onoff) { this.avatarimage = avatarimage; if (onoff) { bordercolor = ColorSchemeClass.primarygreen; borderwidth = 4; } } @override Widget build(BuildContext context) { return Container( height: MediaQuery.of(context).size.height * 0.05, width: MediaQuery.of(context).size.height * 0.05, decoration: BoxDecoration( boxShadow: [ BoxShadow( color: bordercolor.withOpacity(0.5), blurRadius: borderwidth, ) ], border: Border.all(color: bordercolor, width: borderwidth), shape: BoxShape.circle, image: DecorationImage( image: avatarimage.image, )), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/colorscheme.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class ColorSchemeClass { static const Color primarygreen = Color(0xff00de71); static const Color secondarygreen = Color(0xffa6f2cd); static const Color tertiarygreen = Color(0xffe2faee); static const Color lightgrey = Color(0xffe4e5e4); static const Color darkgrey = Color(0xff5a5e5a); static const Color dark = Color(0xff141514); static const Color unactivatedblack = Color(0xff1d201d); static const Color codeforcespurple = Color(0xffd982ff); static const Color codechefbrown = Color(0xffffc19b); static const Color spojblue = Color(0xff82c8ff); static const Color atcodergrey = Color(0xffdbebff); static const Color dangerred = Color(0xffDB4437); static const Color morphdangerred = Color(0xff561715); static const Color morphprimarygreen = Color(0xff155735); }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/myRatingCard.dart
import 'package:flutter/material.dart'; import 'package:rive/rive.dart'; //ignore: must_be_immutable class MyRatingCard extends StatelessWidget { AssetImage tileimage; Color tilecolor; String tilestring; MyRatingCard(AssetImage tileimage, Color tilecolor, String tilestring) { this.tileimage = tileimage; this.tilecolor = tilecolor; this.tilestring = tilestring; } @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.05), child: Stack( children: [ Container( height: MediaQuery.of(context).size.width * 0.25, width: MediaQuery.of(context).size.width * 0.2, child: Image( image: tileimage, ), ), Container( height: MediaQuery.of(context).size.width * 0.25, width: MediaQuery.of(context).size.width * 0.2, child: Center( child: Column( children: [ SizedBox(height: MediaQuery.of(context).size.width * 0.19), FittedBox( fit: BoxFit.scaleDown, child: Text(tilestring, style: TextStyle( color: tilecolor, fontFamily: 'young', fontSize: MediaQuery.of(context).size.width * 0.04, fontWeight: FontWeight.bold, shadows: [ Shadow( // bottomLeft offset: Offset(-1, -1), color: Colors.black.withOpacity(0.3)), Shadow( // bottomRight offset: Offset(1, -1), color: Colors.black.withOpacity(0.3)), Shadow( // topRight offset: Offset(1, 1), color: Colors.black.withOpacity(0.3)), Shadow( // topLeft offset: Offset(-1, 1), color: Colors.black.withOpacity(0.3)) ])), ), ], )), ), Container( height: MediaQuery.of(context).size.width * 0.25, width: MediaQuery.of(context).size.width * 0.2, child: RiveAnimation.asset( 'assets/shine.riv', fit: BoxFit.cover, )), ], ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/generalLoader.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:flutter/material.dart'; import 'package:rive/rive.dart'; //ignore: must_be_immutable class GeneralLoader extends StatelessWidget { String heading; GeneralLoader(String heading) { this.heading = heading; } @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: MediaQuery.of(context).size.width * 0.3, height: MediaQuery.of(context).size.width * 0.3, child: Hero( tag: 'cup', child: RiveAnimation.asset('assets/cup.riv'))), SizedBox( height: MediaQuery.of(context).size.height * 0.01, ), Text( heading, style: TextStyle( color: Colors.white, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02), ) ], ), ), ); } } //ignore: must_be_immutable class GeneralLoaderTransparent extends StatelessWidget { String heading; GeneralLoaderTransparent(String heading) { this.heading = heading; } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: ColorSchemeClass.dark.withOpacity(0.5), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: MediaQuery.of(context).size.width * 0.3, height: MediaQuery.of(context).size.width * 0.3, child: RiveAnimation.asset('assets/cup.riv')), SizedBox( height: MediaQuery.of(context).size.height * 0.01, ), Text( heading, style: TextStyle( color: Colors.white, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02), ) ], ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/viewAnotherUserScreenSkeleton.dart
import 'package:coder_status/components/myDividerWithTitle.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:rive/rive.dart'; import 'myAppBar.dart'; class ViewAnotherUserScreenSkeleton extends StatefulWidget { @override _ViewAnotherUserScreenSkeletonState createState() => _ViewAnotherUserScreenSkeletonState(); } class _ViewAnotherUserScreenSkeletonState extends State<ViewAnotherUserScreenSkeleton> { @override Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( child: MyAppBarWithBack('User'), preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.08), ), body: SafeArea( child: Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.03), child: SingleChildScrollView( child: Column( children: [ Column( children: [ SizedBox( height: MediaQuery.of(context).size.height * 0.03, ), Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Padding( padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.02), child: ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( height: MediaQuery.of(context).size.height * 0.15, width: MediaQuery.of(context).size.height * 0.15, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv')), ), ), SizedBox( width: MediaQuery.of(context).size.width * 0.15, ), Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( width: MediaQuery.of(context).size.width * 0.4, height: MediaQuery.of(context).size.height * 0.03, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, ))), SizedBox( height: MediaQuery.of(context).size.height * 0.007, ), /* FittedBox( fit: BoxFit.scaleDown, child: Text( '@' + codername, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02), ), ),*/ ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( width: MediaQuery.of(context).size.width * 0.3, height: MediaQuery.of(context).size.height * 0.02, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, ))), ], ) ], ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), /*MyButton(ColorSchemeClass.primarygreen, 'Add as a Peer', () { addInPeers(); }, Icons.add_circle),*/ Padding( padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.02), child: ClipRRect( borderRadius: BorderRadius.circular(5), child: Container( width: double.infinity, height: MediaQuery.of(context).size.height * 0.07, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, ))), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), MyMidDividerWithTitle('Bio'), SizedBox( height: MediaQuery.of(context).size.height * 0.015, ), /*Text( bio, textAlign: TextAlign.center, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02), ),*/ ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( width: MediaQuery.of(context).size.width * 0.7, height: MediaQuery.of(context).size.height * 0.02, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, ))), SizedBox( height: MediaQuery.of(context).size.height * 0.015, ), MyMidDividerWithTitle('Ratings'), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Container( height: MediaQuery.of(context).size.height * 0.32, width: MediaQuery.of(context).size.width * 0.6, child: Theme( data: ThemeData(accentColor: Colors.transparent), child: GridView.count(crossAxisCount: 2, children: [ Container( child: Center( child: ClipRRect( borderRadius: BorderRadius.circular(5), child: Container( width: MediaQuery.of(context).size.width * 0.2, height: MediaQuery.of(context).size.width * 0.25, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, ))), ), ), Container( child: Center( child: ClipRRect( borderRadius: BorderRadius.circular(5), child: Container( width: MediaQuery.of(context).size.width * 0.2, height: MediaQuery.of(context).size.width * 0.25, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, ))), ), ), Container( child: Center( child: ClipRRect( borderRadius: BorderRadius.circular(5), child: Container( width: MediaQuery.of(context).size.width * 0.2, height: MediaQuery.of(context).size.width * 0.25, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, ))), ), ), Container( child: Center( child: ClipRRect( borderRadius: BorderRadius.circular(5), child: Container( width: MediaQuery.of(context).size.width * 0.2, height: MediaQuery.of(context).size.width * 0.25, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, ))), ), ), ]), ), ) ], ), ], ), ), ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/myAvatarSelection.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:flutter/material.dart'; //ignore: must_be_immutable class MyAvatarSelection extends StatelessWidget { Image avatarimage; double borderwidth = 2; Color bordercolor = ColorSchemeClass.lightgrey; MyAvatarSelection(Image avatarimage, bool onoff) { this.avatarimage = avatarimage; if (onoff) { bordercolor = ColorSchemeClass.primarygreen; borderwidth = 4; } } @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.all(MediaQuery.of(context).size.height * 0.01), height: MediaQuery.of(context).size.height * 0.09, width: MediaQuery.of(context).size.height * 0.09, decoration: BoxDecoration( boxShadow: [ BoxShadow( color: bordercolor.withOpacity(0.5), blurRadius: borderwidth, ) ], border: Border.all(color: bordercolor, width: borderwidth), shape: BoxShape.circle, image: DecorationImage( image: avatarimage.image, )), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/peerScreenSkeleton.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/myAppBar.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:rive/rive.dart'; class PeersScreenSkeleton extends StatefulWidget { const PeersScreenSkeleton({Key key}) : super(key: key); @override _PeersScreenSkeletonState createState() => _PeersScreenSkeletonState(); } class _PeersScreenSkeletonState extends State<PeersScreenSkeleton> { List<Widget> listOfUserTiles = List.filled(10, MyUserTileSkeleton()); @override Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( child: MyAppBar('Peers'), preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.08), ), body: ListView( children: listOfUserTiles, ), ); } } class MyUserTileSkeleton extends StatelessWidget { @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.02, vertical: MediaQuery.of(context).size.width * 0.01), child: ListTile( title: Container( width: MediaQuery.of(context).size.width * 0.9, height: MediaQuery.of(context).size.height * 0.08, decoration: BoxDecoration( color: ColorSchemeClass.unactivatedblack, borderRadius: BorderRadius.circular(100), boxShadow: [ BoxShadow( color: ColorSchemeClass.darkgrey.withOpacity(0.3), offset: Offset( 0, MediaQuery.of(context).size.height * 0.005, ), blurRadius: 0, spreadRadius: 0) ]), child: Row( children: [ ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( height: MediaQuery.of(context).size.height * 0.08, width: MediaQuery.of(context).size.height * 0.08, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, )), ), SizedBox( width: MediaQuery.of(context).size.width * 0.15, ), Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ /*FittedBox( fit: BoxFit.scaleDown, child: Text( name, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontWeight: FontWeight.bold, fontSize: MediaQuery.of(context).size.height * 0.025), ), ),*/ ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( height: MediaQuery.of(context).size.height * 0.025, width: MediaQuery.of(context).size.width * 0.4, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, )), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01, ), /*FittedBox( fit: BoxFit.scaleDown, child: Text( '@' + codername, style: TextStyle( color: ColorSchemeClass.lightgrey.withOpacity(0.6), fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02), ), )*/ ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( height: MediaQuery.of(context).size.height * 0.02, width: MediaQuery.of(context).size.width * 0.25, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, )), ), ], ) ], ), ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/myDashboardScreenSkeleton.dart
import 'package:flutter/material.dart'; import 'package:rive/rive.dart'; import 'myDividerWithTitle.dart'; class MyDashboardScreenSkeleton extends StatefulWidget { @override _MyDashboardScreenSkeletonState createState() => _MyDashboardScreenSkeletonState(); } class _MyDashboardScreenSkeletonState extends State<MyDashboardScreenSkeleton> { @override Widget build(BuildContext context) { return Scaffold( body: SafeArea( child: Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.03), child: SingleChildScrollView( child: Column( children: [ Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.015), width: double.infinity, height: MediaQuery.of(context).size.height * 0.07, child: Center( child: Image(image: AssetImage('images/appiconnoback.png')), ), ), Column( children: [ SizedBox( height: MediaQuery.of(context).size.height * 0.03, ), ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( height: MediaQuery.of(context).size.height * 0.22, width: MediaQuery.of(context).size.height * 0.22, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, )), ), SizedBox( height: MediaQuery.of(context).size.height * 0.025, ), /*Text( name, style: TextStyle( color: Colors.white, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.035), ),*/ ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( width: MediaQuery.of(context).size.width * 0.45, height: MediaQuery.of(context).size.height * 0.035, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, ))), SizedBox( height: MediaQuery.of(context).size.height * 0.007, ), /*Text( '@' + codername, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.025), ),*/ ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( width: MediaQuery.of(context).size.width * 0.3, height: MediaQuery.of(context).size.height * 0.025, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, ))), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), MyMidDividerWithTitle('Bio'), SizedBox( height: MediaQuery.of(context).size.height * 0.015, ), /*Text( bio, textAlign: TextAlign.center, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02), ),*/ ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( width: MediaQuery.of(context).size.width * 0.7, height: MediaQuery.of(context).size.height * 0.02, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, ))), SizedBox( height: MediaQuery.of(context).size.height * 0.015, ), MyMidDividerWithTitle('Ratings'), SizedBox( height: MediaQuery.of(context).size.height * 0.01, ), Container( height: MediaQuery.of(context).size.height * 0.32, width: MediaQuery.of(context).size.width * 0.6, child: Theme( data: ThemeData(accentColor: Colors.transparent), child: GridView.count(crossAxisCount: 2, children: [ Container( child: Center( child: ClipRRect( borderRadius: BorderRadius.circular(5), child: Container( width: MediaQuery.of(context).size.width * 0.2, height: MediaQuery.of(context).size.width * 0.25, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, ))), ), ), Container( child: Center( child: ClipRRect( borderRadius: BorderRadius.circular(5), child: Container( width: MediaQuery.of(context).size.width * 0.2, height: MediaQuery.of(context).size.width * 0.25, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, ))), ), ), Container( child: Center( child: ClipRRect( borderRadius: BorderRadius.circular(5), child: Container( width: MediaQuery.of(context).size.width * 0.2, height: MediaQuery.of(context).size.width * 0.25, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, ))), ), ), Container( child: Center( child: ClipRRect( borderRadius: BorderRadius.circular(5), child: Container( width: MediaQuery.of(context).size.width * 0.2, height: MediaQuery.of(context).size.width * 0.25, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, ))), ), ), ]), ), ) ], ), ], ), ), ), ), ); } } /* */
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/myCircleAvatar.dart
import 'package:flutter/material.dart'; import 'package:coder_status/components/colorscheme.dart'; //ignore: must_be_immutable class MyCircleAvatar extends StatelessWidget { Image avatarimage; MyCircleAvatar(this.avatarimage); @override Widget build(BuildContext context) { return Container( height: double.infinity, width: double.infinity, decoration: BoxDecoration( boxShadow: [ BoxShadow(color: ColorSchemeClass.primarygreen, blurRadius: 20) ], border: Border.all(color: ColorSchemeClass.primarygreen, width: 5), shape: BoxShape.circle, image: DecorationImage(fit: BoxFit.fitWidth, image: avatarimage.image)), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/myRankingUserTile.dart
import 'package:flutter/material.dart'; import 'package:rive/rive.dart'; import 'colorscheme.dart'; //ignore: must_be_immutable class MyRankingUserTile extends StatelessWidget { String avatarUrl, userHandle, rating; int rank; MyRankingUserTile(this.avatarUrl, this.userHandle, this.rating, this.rank); @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.02, vertical: MediaQuery.of(context).size.width * 0.01), child: ListTile( title: Row( children: [ Container( width: MediaQuery.of(context).size.width * 0.1, child: Center( child: rank == 1 ? Row( children: [ Container( width: MediaQuery.of(context).size.width * 0.06, height: MediaQuery.of(context).size.width * 0.06, child: RiveAnimation.asset('assets/crown.riv')), SizedBox( width: MediaQuery.of(context).size.width * 0.015, ), Container( width: MediaQuery.of(context).size.width * 0.025, child: FittedBox( fit: BoxFit.scaleDown, child: Text( rank.toString(), style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.width * 0.06), ), ), ), ], ) : Row( children: [ Icon( Icons.play_arrow, size: MediaQuery.of(context).size.width * 0.05, color: ColorSchemeClass.lightgrey, ), SizedBox( width: MediaQuery.of(context).size.width * 0.015, ), Container( width: MediaQuery.of(context).size.width * 0.03, child: FittedBox( fit: BoxFit.scaleDown, child: Text( rank.toString(), style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.width * 0.06), ), ), ), ], ), ), ), SizedBox( width: MediaQuery.of(context).size.width * 0.05, ), Container( width: MediaQuery.of(context).size.width * 0.7, height: MediaQuery.of(context).size.height * 0.08, decoration: BoxDecoration( color: ColorSchemeClass.unactivatedblack, borderRadius: BorderRadius.circular(100), boxShadow: [ BoxShadow( color: ColorSchemeClass.darkgrey.withOpacity(0.3), offset: Offset( 0, MediaQuery.of(context).size.height * 0.005, ), blurRadius: 0, spreadRadius: 0) ]), child: Row( children: [ CircleAvatar( backgroundImage: NetworkImage(avatarUrl), radius: MediaQuery.of(context).size.height * 0.04, ), SizedBox( width: MediaQuery.of(context).size.width * 0.03, ), Row( children: [ Container( width: MediaQuery.of(context).size.width * 0.24, child: FittedBox( alignment: Alignment.centerLeft, fit: BoxFit.scaleDown, child: Text( '@' + userHandle, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02), ), ), ), SizedBox( width: MediaQuery.of(context).size.width * 0.03, ), Container( width: MediaQuery.of(context).size.width * 0.2, child: FittedBox( fit: BoxFit.scaleDown, child: Text( rating + ' pts', style: TextStyle( color: ColorSchemeClass.primarygreen, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.03), ), ), ), ], ) ], ), ), ], ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/atcoderDialog.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:flutter/material.dart'; import 'package:glassmorphism_ui/glassmorphism_ui.dart'; showAtcoderDialog(BuildContext context, Rect rect, String atcoderHandle, String atcoderRating) { OverlayState overlayState = Overlay.of(context); OverlayEntry overlayEntry; overlayEntry = OverlayEntry(builder: (context) { return GestureDetector( onTap: () { overlayEntry.remove(); }, child: Container( height: double.infinity, width: double.infinity, color: Colors.transparent, child: Column( children: [ SizedBox( height: rect.top - MediaQuery.of(context).size.height * 0.13, ), Row( children: [ SizedBox( width: rect.left - MediaQuery.of(context).size.width * 0.034, ), GestureDetector( onTap: () {}, child: Stack( children: [ Container( width: MediaQuery.of(context).size.width * 0.42, height: MediaQuery.of(context).size.height * 0.1265, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: ColorSchemeClass.unactivatedblack .withOpacity(0.7), ), ), GlassContainer( blur: 3, width: MediaQuery.of(context).size.width * 0.42, height: MediaQuery.of(context).size.height * 0.1265, borderRadius: BorderRadius.circular(10), ), Container( width: MediaQuery.of(context).size.width * 0.42, height: MediaQuery.of(context).size.height * 0.157, decoration: BoxDecoration( image: DecorationImage( fit: BoxFit.fill, image: AssetImage('images/dialogAtcoder.png'))), child: Container( margin: EdgeInsets.fromLTRB( MediaQuery.of(context).size.width * 0.02, MediaQuery.of(context).size.width * 0.025, MediaQuery.of(context).size.width * 0.02, MediaQuery.of(context).size.height * 0.04), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Flexible( child: FittedBox( fit: BoxFit.scaleDown, child: Row( children: [ Text( 'Platform : ', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.018), ), Text( 'ATCODER', style: TextStyle( color: ColorSchemeClass.atcodergrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.02, fontWeight: FontWeight.bold), ) ], ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01), Flexible( child: FittedBox( fit: BoxFit.scaleDown, child: Row( children: [ Text( 'Username : ', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.018), ), Text( '@' + atcoderHandle, style: TextStyle( color: ColorSchemeClass.atcodergrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.02, fontWeight: FontWeight.bold), ) ], ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01), Flexible( child: Row( children: [ Text( 'Rating : ', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.018), ), Text( atcoderRating, style: TextStyle( color: ColorSchemeClass.atcodergrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.025, fontWeight: FontWeight.bold), ), Text( ' pts', style: TextStyle( color: ColorSchemeClass.atcodergrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.015, fontWeight: FontWeight.bold), ) ], ), ) ], ), ), ), ], ), ), ], ) ], )), ); }); overlayState.insert(overlayEntry); }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/components/codechefDialog.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:glassmorphism_ui/glassmorphism_ui.dart'; showCodechefDialog(BuildContext context, Rect rect, String codechefHandle, String codechefRating) { int codechefStarCount = 1; int rating = int.parse(codechefRating); if (rating <= 1399) { codechefStarCount = 1; } else if (rating <= 1599) { codechefStarCount = 2; } else if (rating <= 1799) { codechefStarCount = 3; } else if (rating <= 1999) { codechefStarCount = 4; } else if (rating <= 2199) { codechefStarCount = 5; } else if (rating <= 2499) { codechefStarCount = 6; } else if (rating >= 2500) { codechefStarCount = 7; } List<Icon> listOfStars = []; for (int i = 1; i <= codechefStarCount; i++) { listOfStars.add(Icon( FontAwesomeIcons.solidStar, size: MediaQuery.of(context).size.width * 0.035, color: ColorSchemeClass.codechefbrown, )); } OverlayState overlayState = Overlay.of(context); OverlayEntry overlayEntry; overlayEntry = OverlayEntry(builder: (context) { return GestureDetector( onTap: () { overlayEntry.remove(); }, child: Container( height: double.infinity, width: double.infinity, color: Colors.transparent, child: Column( children: [ SizedBox( height: rect.top - MediaQuery.of(context).size.height * 0.13, ), Row( children: [ SizedBox( width: rect.left - MediaQuery.of(context).size.width * 0.034, ), GestureDetector( onTap: () {}, child: Stack( children: [ GlassContainer( blur: 3, width: MediaQuery.of(context).size.width * 0.42, height: MediaQuery.of(context).size.height * 0.1265, borderRadius: BorderRadius.circular(10), ), Container( width: MediaQuery.of(context).size.width * 0.42, height: MediaQuery.of(context).size.height * 0.157, decoration: BoxDecoration( image: DecorationImage( fit: BoxFit.fill, image: AssetImage('images/dialogCodechef.png'))), child: Container( margin: EdgeInsets.fromLTRB( MediaQuery.of(context).size.width * 0.02, MediaQuery.of(context).size.width * 0.025, MediaQuery.of(context).size.width * 0.02, MediaQuery.of(context).size.height * 0.04), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Flexible( child: FittedBox( fit: BoxFit.scaleDown, child: Row( children: [ Text( 'Platform : ', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.018), ), Text( 'CODECHEF', style: TextStyle( color: ColorSchemeClass .codechefbrown, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.02, fontWeight: FontWeight.bold), ) ], ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01), Flexible( child: FittedBox( fit: BoxFit.scaleDown, child: Row( children: [ Text( 'Username : ', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.018), ), Text( '@' + codechefHandle, style: TextStyle( color: ColorSchemeClass .codechefbrown, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.02, fontWeight: FontWeight.bold), ) ], ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01), Flexible( child: Row( children: [ Text( 'Rating : ', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.018), ), Text( codechefRating, style: TextStyle( color: ColorSchemeClass.codechefbrown, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.025, fontWeight: FontWeight.bold), ), Text( ' pts', style: TextStyle( color: ColorSchemeClass.codechefbrown, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.015, fontWeight: FontWeight.bold), ) ], ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01), Flexible( child: Row( children: [ Text( 'Stars : ', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.018), ), FittedBox( fit: BoxFit.scaleDown, child: Row( children: listOfStars, ), ) ], ), ) ], ), ), ), ], ), ), ], ) ], )), ); }); overlayState.insert(overlayEntry); }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/firebase_layer/validatePassword.dart
import 'package:firebase_auth/firebase_auth.dart'; Future<bool> validatePassword(String password) async { var authCredentials = EmailAuthProvider.credential( email: FirebaseAuth.instance.currentUser.email, password: password); try { var authResult = await FirebaseAuth.instance.currentUser .reauthenticateWithCredential(authCredentials); return authResult.user != null; } catch (e) { return false; } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/firebase_layer/authenticate.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:coder_status/components/generalLoader.dart'; import 'package:coder_status/screens/getStartedScreen.dart'; import 'package:coder_status/home.dart'; import 'package:coder_status/screens/registerNameScreen.dart'; import 'package:coder_status/screens/verifyEmailScreen.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; //ignore: must_be_immutable class Authenticate extends StatelessWidget { FirebaseAuth _auth = FirebaseAuth.instance; bool flag = false; Future updateFlag() async { try { await FirebaseFirestore.instance .collection('users') .doc(_auth.currentUser.uid) .get() .then((doc) { flag = doc.exists; }); } catch (e) { flag = false; } } @override Widget build(BuildContext context) { return FutureBuilder( future: updateFlag(), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.done) { if (_auth.currentUser != null) { if (_auth.currentUser.emailVerified) { if (flag) { return Home(); } else { return Registernamescreen(); } } else { return VerifyEmailScreen(); } } else { return GetStartedScreen(); } } else { return GeneralLoader(''); } }, ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/firebase_layer/getUserInfo.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; class GetUserInfo { static getUserDocument([String uid = '']) async { if (uid == '') { FirebaseAuth _auth = FirebaseAuth.instance; final user = _auth.currentUser; uid = user.uid.toString(); } final mapofdocument = await FirebaseFirestore.instance.collection("users").doc(uid).get(); return mapofdocument.data(); } static Future<String> getUserName([String uid = '']) async { if (uid == '') { FirebaseAuth _auth = FirebaseAuth.instance; final user = _auth.currentUser; uid = user.uid.toString(); } final mapofdocument = await FirebaseFirestore.instance.collection("users").doc(uid).get(); String name = mapofdocument.data()['name']; return name; } static Future<String> getUserCoderName([String uid = '']) async { if (uid == '') { FirebaseAuth _auth = FirebaseAuth.instance; final user = _auth.currentUser; uid = user.uid.toString(); } final mapofdocument = await FirebaseFirestore.instance.collection("users").doc(uid).get(); String codername = mapofdocument.data()['codername']; return codername; } static Future<String> getUserAvatarUrl([String uid = '']) async { if (uid == '') { FirebaseAuth _auth = FirebaseAuth.instance; final user = _auth.currentUser; uid = user.uid.toString(); } final mapofdocument = await FirebaseFirestore.instance.collection("users").doc(uid).get(); String avatarurl = mapofdocument.data()['avatarurl']; return avatarurl; } static Future<String> getUserBio([String uid = '']) async { if (uid == '') { FirebaseAuth _auth = FirebaseAuth.instance; final user = _auth.currentUser; uid = user.uid.toString(); } final mapofdocument = await FirebaseFirestore.instance.collection("users").doc(uid).get(); String bio = mapofdocument.data()['bio']; return bio; } static getUserSeachKey([String uid = '']) async { if (uid == '') { FirebaseAuth _auth = FirebaseAuth.instance; final user = _auth.currentUser; uid = user.uid.toString(); } final mapofdocument = await FirebaseFirestore.instance.collection("users").doc(uid).get(); var searchKey = mapofdocument.data()['searchKey']; return searchKey; } static getUserPeers() async { FirebaseAuth _auth = FirebaseAuth.instance; final user = _auth.currentUser; final uid = user.uid.toString(); final mapofdocument = await FirebaseFirestore.instance.collection("users").doc(uid).get(); var peers = mapofdocument.data()['peers']; return peers; } static Future<List<String>> getUserHandles([String uid = '']) async { if (uid == '') { FirebaseAuth _auth = FirebaseAuth.instance; final user = _auth.currentUser; uid = user.uid.toString(); } final mapofdocument = await FirebaseFirestore.instance.collection("users").doc(uid).get(); String codeforces = mapofdocument.data()['codeforces']; String codechef = mapofdocument.data()['codechef']; String atcoder = mapofdocument.data()['atcoder']; String spoj = mapofdocument.data()['spoj']; return [codeforces, codechef, atcoder, spoj]; } static getUserEmail() { FirebaseAuth _auth = FirebaseAuth.instance; String email = _auth.currentUser.email; return email; } static getUserUid() { FirebaseAuth _auth = FirebaseAuth.instance; String uid = _auth.currentUser.uid; return uid; } static getUserDocumentChnges() async { FirebaseAuth _auth = FirebaseAuth.instance; final user = _auth.currentUser; final uid = user.uid.toString(); var documentStream = FirebaseFirestore.instance.collection('users').doc(uid).snapshots(); return documentStream; } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/firebase_layer/updatePassword.dart
import 'package:firebase_auth/firebase_auth.dart'; updatePassword(String oldpassword, String newpassword) async { FirebaseAuth _auth = FirebaseAuth.instance; final currentuser = _auth.currentUser; final user = currentuser; final cred = EmailAuthProvider.credential(email: user.email, password: oldpassword); user.reauthenticateWithCredential(cred).then((value) { user.updatePassword(newpassword).then((_) {}).catchError((error) {}); }).catchError((err) {}); }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/firebase_layer/uploadAvatar.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'dart:io'; import 'package:firebase_storage/firebase_storage.dart'; class UploadUserAvatar { static Future<String> uploadUserAvatar(File avatarImageFile) async { UploadTask imageUploadTask; FirebaseAuth _auth = FirebaseAuth.instance; final user = _auth.currentUser; final uid = user.uid; Reference imageReference = FirebaseStorage.instance .ref() .child(uid + 'avatar' + DateTime.now().toString()); imageUploadTask = imageReference.putFile(avatarImageFile); await imageUploadTask.whenComplete(() {}); var dowurl = await imageReference.getDownloadURL(); String url = dowurl.toString(); return url; } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/firebase_layer/emailVerification.dart
import 'package:firebase_auth/firebase_auth.dart'; sendVerificationEmail(String email) async { FirebaseAuth _auth = FirebaseAuth.instance; var user = _auth.currentUser; user.sendEmailVerification(); } Future<bool> checkEmailVerified() async { FirebaseAuth _auth = FirebaseAuth.instance; var user = _auth.currentUser; user.reload(); if (user.emailVerified) { return true; } else { return false; } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/firebase_layer/googleSignInProvider.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/cupertino.dart'; import 'package:google_sign_in/google_sign_in.dart'; class GoogleSigInProvider extends ChangeNotifier { final googleSignIn = GoogleSignIn(); GoogleSignInAccount _user; GoogleSignInAccount get user => _user; googleLogin() async { try { final googleUser = await googleSignIn.signIn(); if (googleUser == null) return null; _user = googleUser; final googleAuth = await googleUser.authentication; final credential = GoogleAuthProvider.credential( accessToken: googleAuth.accessToken, idToken: googleAuth.idToken); await FirebaseAuth.instance.signInWithCredential(credential); notifyListeners(); return FirebaseAuth.instance.currentUser; } catch (e) { return null; } } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/firebase_layer/resetPassword.dart
import 'package:firebase_auth/firebase_auth.dart'; resetpassword(String email) async { FirebaseAuth _auth = FirebaseAuth.instance; try { _auth.sendPasswordResetEmail(email: email); } catch (e) {} }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/firebase_layer/setUserInfo.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:coder_status/firebase_layer/getUserInfo.dart'; import 'package:firebase_auth/firebase_auth.dart'; class SetUserInfo { static Future setUserCredentials( String name, String codername, String avatarurl, String bio, String codeforces, String codechef, String spoj, String atcoder) async { FirebaseAuth _auth = FirebaseAuth.instance; final user = _auth.currentUser; final uid = user.uid.toString(); List<String> emptyList = []; return await FirebaseFirestore.instance.collection("users").doc(uid).set({ "name": name, "codername": codername, "bio": bio, "avatarurl": avatarurl, "codeforces": codeforces, "codechef": codechef, "atcoder": atcoder, "spoj": spoj, "searchKey": [name[0].toUpperCase(), codername[0].toUpperCase()], "id": uid, "peers": emptyList }); } static Future updateName(String name) async { FirebaseAuth _auth = FirebaseAuth.instance; final user = _auth.currentUser; final uid = user.uid.toString(); var searchKey = await GetUserInfo.getUserSeachKey(); searchKey[0] = name[0].toUpperCase(); return await FirebaseFirestore.instance .collection('users') .doc(uid) .update({'name': name, 'searchKey': searchKey}); } static Future updateCodername(String codername) async { FirebaseAuth _auth = FirebaseAuth.instance; final user = _auth.currentUser; final uid = user.uid; var searchKey = await GetUserInfo.getUserSeachKey(); searchKey[1] = codername[0].toUpperCase(); return await FirebaseFirestore.instance .collection('users') .doc(uid) .update({'codername': codername, 'searchKey': searchKey}); } static Future updateAvatar(String urltobeupdated) async { FirebaseAuth _auth = FirebaseAuth.instance; final user = _auth.currentUser; final uid = user.uid.toString(); return await FirebaseFirestore.instance .collection('users') .doc(uid) .update({'avatarurl': urltobeupdated}); } static Future updateBio(String bio) async { FirebaseAuth _auth = FirebaseAuth.instance; final user = _auth.currentUser; final uid = user.uid; return await FirebaseFirestore.instance .collection('users') .doc(uid) .update({'bio': bio}); } static Future updatePeers(var peers) async { FirebaseAuth _auth = FirebaseAuth.instance; final user = _auth.currentUser; final uid = user.uid; if (peers == null) { peers = []; } return await FirebaseFirestore.instance .collection('users') .doc(uid) .update({'peers': peers}); } static Future updateHandles( String codeforces, String codechef, String atcoder, String spoj) async { FirebaseAuth _auth = FirebaseAuth.instance; final user = _auth.currentUser; final uid = user.uid.toString(); return await FirebaseFirestore.instance .collection('users') .doc(uid) .update({ "codeforces": codeforces, "codechef": codechef, "atcoder": atcoder, "spoj": spoj }); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/firebase_layer/search.dart
import 'package:cloud_firestore/cloud_firestore.dart'; class SearchDatabase { searchByKey(String searchfield) async { return await FirebaseFirestore.instance .collection('users') .where('searchKey', arrayContains: searchfield) .get(); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/firebase_layer/createuser.dart
import 'package:firebase_auth/firebase_auth.dart'; createAccount(String email, String password) async { FirebaseAuth _auth = FirebaseAuth.instance; try { User user = (await _auth.createUserWithEmailAndPassword( email: email, password: password)) .user; if (user != null) { return user; } else { return user; } } catch (e) {} }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/firebase_layer/logoutUser.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter_phoenix/flutter_phoenix.dart'; import 'package:google_sign_in/google_sign_in.dart'; logout(context) async { FirebaseAuth _auth = FirebaseAuth.instance; try { GoogleSignIn().disconnect(); await _auth.signOut(); Phoenix.rebirth(context); } catch (e) { print(e); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/firebase_layer/deleteUser.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:google_sign_in/google_sign_in.dart'; Future deleteUser([String password = '']) async { FirebaseAuth _auth = FirebaseAuth.instance; try { User user = _auth.currentUser; var authCredentials; if (user.photoURL == null) authCredentials = EmailAuthProvider.credential(email: user.email, password: password); else { final googleUser = await GoogleSignIn().signIn(); final googleAuth = await googleUser.authentication; authCredentials = GoogleAuthProvider.credential( accessToken: googleAuth.accessToken, idToken: googleAuth.idToken); } var authResult = await user.reauthenticateWithCredential(authCredentials); await FirebaseFirestore.instance.collection("users").doc(user.uid).delete(); authResult.user.delete(); } catch (e) {} }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/firebase_layer/loginUser.dart
import 'package:firebase_auth/firebase_auth.dart'; login(String email, String password) async { FirebaseAuth _auth = FirebaseAuth.instance; try { User user = (await _auth.signInWithEmailAndPassword( email: email, password: password)) .user; if (user != null) { return user; } else { return user; } } catch (e) {} }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/rankingScreen.dart
import 'package:coder_status/screens/atcoderRankingScreen.dart'; import 'package:coder_status/screens/codechefRankingScreen.dart'; import 'package:coder_status/screens/codeforcesRankingScreen.dart'; import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/myAppBar.dart'; import 'package:coder_status/screens/spojRankingScreen.dart'; import 'package:flutter/material.dart'; class RankingScreen extends StatefulWidget { const RankingScreen({Key key}) : super(key: key); @override _RankingScreenState createState() => _RankingScreenState(); } class _RankingScreenState extends State<RankingScreen> { @override Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( child: MyAppBar('Ranking'), preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.08), ), body: SafeArea( child: Padding( padding: EdgeInsets.all(MediaQuery.of(context).size.height * 0.04), child: Container( height: double.infinity, width: double.infinity, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Choose Platform', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.033), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Text( 'Choose a platform to view a ranklist among your peers', textAlign: TextAlign.center, style: TextStyle( color: ColorSchemeClass.darkgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.023), ), SizedBox( height: MediaQuery.of(context).size.height * 0.05, ), Container( child: GridView.count( shrinkWrap: true, crossAxisCount: 2, mainAxisSpacing: MediaQuery.of(context).size.width * 0.07, crossAxisSpacing: MediaQuery.of(context).size.width * 0.07, children: [ GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return CodeforcesRankingScreen(); })); }, child: Container( margin: EdgeInsets.all( MediaQuery.of(context).size.width * 0.02), decoration: BoxDecoration( border: Border.all( color: ColorSchemeClass.codeforcespurple .withOpacity(0.5), width: 2), boxShadow: [ BoxShadow( color: ColorSchemeClass.codeforcespurple .withOpacity(0.2), offset: Offset( 0, MediaQuery.of(context).size.height * 0.007)) ], borderRadius: BorderRadius.circular(10), image: DecorationImage( image: AssetImage( 'images/codeforcesSquare.jpg'))), ), ), GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return CodechefRankingScreen(); })); }, child: Container( margin: EdgeInsets.all( MediaQuery.of(context).size.width * 0.02), decoration: BoxDecoration( border: Border.all( color: ColorSchemeClass.codechefbrown .withOpacity(0.5), width: 2), boxShadow: [ BoxShadow( color: ColorSchemeClass.codechefbrown .withOpacity(0.2), offset: Offset( 0, MediaQuery.of(context).size.height * 0.007)) ], borderRadius: BorderRadius.circular(10), image: DecorationImage( image: AssetImage( 'images/codechefSquare.jpg'))), ), ), GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return AtcoderRankingScreen(); })); }, child: Container( margin: EdgeInsets.all( MediaQuery.of(context).size.width * 0.02), decoration: BoxDecoration( border: Border.all( color: ColorSchemeClass.atcodergrey .withOpacity(0.5), width: 2), boxShadow: [ BoxShadow( color: ColorSchemeClass.atcodergrey .withOpacity(0.2), offset: Offset( 0, MediaQuery.of(context).size.height * 0.007)) ], borderRadius: BorderRadius.circular(10), image: DecorationImage( image: AssetImage( 'images/atcoderSquare.jpg'))), ), ), GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return SpojRankingScreen(); })); }, child: Container( margin: EdgeInsets.all( MediaQuery.of(context).size.width * 0.02), decoration: BoxDecoration( border: Border.all( color: ColorSchemeClass.spojblue .withOpacity(0.5), width: 2), boxShadow: [ BoxShadow( color: ColorSchemeClass.spojblue .withOpacity(0.2), offset: Offset( 0, MediaQuery.of(context).size.height * 0.007)) ], borderRadius: BorderRadius.circular(10), image: DecorationImage( image: AssetImage('images/spojSquare.jpg'))), ), ) ], ), ), ], )), ), ), ); } } /* */
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/registerUserHandleScreen.dart
import 'dart:async'; import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/generalLoader.dart'; import 'package:coder_status/components/myButtons.dart'; import 'package:coder_status/components/myTextFormFields.dart'; import 'package:coder_status/firebase_layer/setUserInfo.dart'; import 'package:coder_status/components/introSlider.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import '../components/noInternet.dart'; class RegisterUserHandleScreen extends StatefulWidget { RegisterUserHandleScreen( String name, String codername, String avatarurl, String bio) { _RegisterUserHandleScreenState.name = name; _RegisterUserHandleScreenState.codername = codername; _RegisterUserHandleScreenState.avatarurl = avatarurl; _RegisterUserHandleScreenState.bio = bio; } @override _RegisterUserHandleScreenState createState() => _RegisterUserHandleScreenState(); } class _RegisterUserHandleScreenState extends State<RegisterUserHandleScreen> { static String name = ''; static String codername = ''; static String avatarurl = ''; static String bio = ''; StreamSubscription subscription; @override initState() { super.initState(); subscription = InternetConnectionChecker().onStatusChange.listen((status) { final hasInternet = status == InternetConnectionStatus.connected; if (!hasInternet) noInternet(this.context); }); } @override void dispose() { subscription.cancel(); super.dispose(); } String codeforces = '', codechef = '', atcoder = '', spoj = ''; final _formkey = GlobalKey<FormState>(); bool isloading = false; void _submit() async { if (_formkey.currentState.validate()) { _formkey.currentState.save(); setState(() { isloading = true; }); await SetUserInfo.setUserCredentials( name, codername, avatarurl, bio, codeforces, codechef, spoj, atcoder); setState(() { isloading = false; }); Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) { return IntroSlider(); }), ModalRoute.withName('/introSlider')); } } @override Widget build(BuildContext context) { return isloading ? GeneralLoader('Creating Account...') : GestureDetector( onTap: () { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } }, child: Scaffold( backgroundColor: ColorSchemeClass.dark, body: SafeArea( child: Container( width: double.infinity, height: double.infinity, padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.015), child: SingleChildScrollView( child: Form( key: _formkey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( height: MediaQuery.of(context).size.height * 0.1, ), Hero( tag: 'appIcon', child: Image( image: AssetImage('images/appiconnoback.png'), height: MediaQuery.of(context).size.height * 0.1, ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Text( 'Add Your User Handles', style: TextStyle( color: Colors.white, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.045), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Text( '*If you are not on a particular platform you can leave that field empty.', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02), textAlign: TextAlign.center, ), SizedBox( height: MediaQuery.of(context).size.height * 0.02), Container( width: double.infinity, height: MediaQuery.of(context).size.height * 0.1, child: Row( children: [ Image( image: AssetImage( 'images/codeforceswhitelogo.png'), width: MediaQuery.of(context).size.width * 0.15), Flexible( child: MyTextFormField( Icon(FontAwesomeIcons.at), 'codeforces_handle', false, (val) { codeforces = val; }, TextInputType.name, (val) => val .trim() .toString() .contains(' ') ? 'User handle should\'nt contain spaces' : null), ) ], )), Container( width: double.infinity, height: MediaQuery.of(context).size.height * 0.1, child: Row( children: [ Image( image: AssetImage( 'images/codechefwhitelogo.png'), width: MediaQuery.of(context).size.width * 0.15), Flexible( child: MyTextFormField( Icon(FontAwesomeIcons.at), 'codechef_handle', false, (val) { codechef = val; }, TextInputType.name, (val) => val .trim() .toString() .contains(' ') ? 'User handle should\'nt contain spaces' : null), ) ], )), Container( width: double.infinity, height: MediaQuery.of(context).size.height * 0.1, child: Row( children: [ Image( image: AssetImage( 'images/atcoderwhitelogo.png'), width: MediaQuery.of(context).size.width * 0.15), Flexible( child: MyTextFormField( Icon(FontAwesomeIcons.at), 'atcoder_handle', false, (val) { atcoder = val; }, TextInputType.name, (val) => val .trim() .toString() .contains(' ') ? 'User handle should\'nt contain spaces' : null), ) ], )), Container( width: double.infinity, height: MediaQuery.of(context).size.height * 0.1, child: Row( children: [ Image( image: AssetImage('images/spojwhitelogo.png'), width: MediaQuery.of(context).size.width * 0.15, ), Flexible( child: MyTextFormField( Icon(FontAwesomeIcons.at), 'spoj_handle', false, (val) { spoj = val; }, TextInputType.name, (val) => val .trim() .toString() .contains(' ') ? 'User handle should\'nt contain spaces' : null), ) ], )), Container( padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.02, vertical: MediaQuery.of(context).size.height * 0.01), height: MediaQuery.of(context).size.height * 0.09, child: MyButton(ColorSchemeClass.primarygreen, 'Create Account', _submit), ), ], ), ), ), ))), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/codeforcesRankingScreen.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/myRankingUserTile.dart'; import 'package:coder_status/components/rankingScreenSkeleton.dart'; import 'package:coder_status/components/topThreeRankingCard.dart'; import 'package:coder_status/firebase_layer/getUserInfo.dart'; import 'package:coder_status/functions/getRating.dart'; import 'package:flutter/material.dart'; import '../components/myAppBar.dart'; import '../components/myButtons.dart'; class CodeforcesRankingScreen extends StatefulWidget { const CodeforcesRankingScreen({Key key}) : super(key: key); @override _CodeforcesRankingScreenState createState() => _CodeforcesRankingScreenState(); } class _CodeforcesRankingScreenState extends State<CodeforcesRankingScreen> { List<Widget> listOfUserTiles = []; bool isFirstTime = true; var listOfUserData = []; getPeersList() async { //initializing the lists empty listOfUserTiles = []; listOfUserData = []; //getting my own map data var myAvatarurl = await GetUserInfo.getUserAvatarUrl(); var myUserHandles = await GetUserInfo.getUserHandles(); //if I have that handle only then add me to ranking data if (myUserHandles[0] != "") { var myRating = await GetRating.getCodeforcesRating(myUserHandles[0]); //if I have rating other than 0 only then add me to ranking data if (myRating != '0') { listOfUserData.add({ 'avatarurl': myAvatarurl, 'userHandle': myUserHandles[0], 'rating': myRating }); } } //getting list of uids of my peers var peers = await GetUserInfo.getUserPeers(); //If I have peers only then proceed if (peers.length != 0) { //loop through all peer uids for (int i = 0; i < peers.length; i++) { //get document map of uid var peerDocument = await GetUserInfo.getUserDocument(peers[i]); //if the peer's document map has user Handle then then add it to ranking data try { if (peerDocument['codeforces'] != '') { //fetch rating for the current peer var rating = await GetRating.getCodeforcesRating(peerDocument['codeforces']); //if current peer has rating not equal to zero then add it to ranking data if (rating != '0') { //if initial list is not empty add to ranking data in descending sort if (listOfUserData.length != 0) { for (int j = 0; j < listOfUserData.length; j++) { if (double.parse(listOfUserData[j]['rating']) <= double.parse(rating)) { listOfUserData.insert(j, { 'avatarurl': peerDocument['avatarurl'], 'userHandle': peerDocument['codeforces'], 'rating': rating }); break; } else { if (j == (listOfUserData.length - 1)) { listOfUserData.add({ 'avatarurl': peerDocument['avatarurl'], 'userHandle': peerDocument['codeforces'], 'rating': rating }); break; } } } } else { //since initial list is empty listOfUserData.add({ 'avatarurl': peerDocument['avatarurl'], 'userHandle': peerDocument['codeforces'], 'rating': rating }); } } } } catch (e) { continue; } } //converting ranking data into widgets } if (listOfUserData.length >= 3) { listOfUserTiles.add(TopThreeRankingCard( listOfUserData[0]['avatarurl'], listOfUserData[1]['avatarurl'], listOfUserData[2]['avatarurl'], listOfUserData[0]['userHandle'], listOfUserData[1]['userHandle'], listOfUserData[2]['userHandle'], listOfUserData[0]['rating'], listOfUserData[1]['rating'], listOfUserData[2]['rating'])); for (int j = 3; j < listOfUserData.length; j++) { listOfUserTiles.add(MyRankingUserTile( listOfUserData[j]['avatarurl'], listOfUserData[j]['userHandle'], listOfUserData[j]['rating'], (j + 1))); } } else { for (int j = 0; j < listOfUserData.length; j++) { listOfUserTiles.add(MyRankingUserTile( listOfUserData[j]['avatarurl'], listOfUserData[j]['userHandle'], listOfUserData[j]['rating'], (j + 1))); } } setState(() { isFirstTime = false; }); } Future futureFunction; @override void initState() { super.initState(); futureFunction = getPeersList(); } @override Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( child: MyAppBarWithBack('Codeforces Ranking'), preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.08), ), body: isFirstTime ? FutureBuilder( future: futureFunction, builder: (context, snapshot) { return Center( child: RankingScreenSkeleton(), ); }, ) : listOfUserTiles.length == 0 ? Container( height: MediaQuery.of(context).size.height * 0.7, child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'You and your peers are not on Codeforces', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.025), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Container( height: MediaQuery.of(context).size.height * 0.05, width: MediaQuery.of(context).size.width * 0.5, child: MyButton( ColorSchemeClass.primarygreen, 'Refresh', () { setState(() { futureFunction = getPeersList(); isFirstTime = true; }); }, Icons.refresh), ) ], ), ), ) : RefreshIndicator( backgroundColor: ColorSchemeClass.unactivatedblack, onRefresh: () async { await getPeersList(); return 0; }, child: ListView( children: listOfUserTiles, ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/registerCodernameScreen.dart
import 'dart:async'; import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/screens/registerAvatarScreen.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import '../components/myTextFormFields.dart'; import '../components/myButtons.dart'; import '../components/noInternet.dart'; class Registercodernamescreen extends StatefulWidget { Registercodernamescreen(String name) { _RegistercodernamescreenState.name = name; } @override _RegistercodernamescreenState createState() => _RegistercodernamescreenState(); } class _RegistercodernamescreenState extends State<Registercodernamescreen> { static String name = ''; String codername = ''; final _formkey = GlobalKey<FormState>(); StreamSubscription subscription; @override initState() { super.initState(); subscription = InternetConnectionChecker().onStatusChange.listen((status) { final hasInternet = status == InternetConnectionStatus.connected; if (!hasInternet) noInternet(this.context); }); } @override void dispose() { subscription.cancel(); super.dispose(); } void _submit() { if (_formkey.currentState.validate()) { _formkey.currentState.save(); Navigator.push(context, MaterialPageRoute(builder: (context) { return Registeravatarscreen(name, codername); })); } } @override Widget build(BuildContext context) { return GestureDetector( onTap: () { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } }, child: Scaffold( backgroundColor: ColorSchemeClass.dark, body: SafeArea( child: Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.04), child: Form( key: _formkey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Flexible( child: Hero( tag: 'appIcon', child: Image( width: MediaQuery.of(context).size.width * 0.45, image: AssetImage('images/appiconnoback.png'), ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.05, ), Flexible( child: Padding( padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.02), child: Text( 'Choose Codername', style: TextStyle( color: Colors.white, fontSize: MediaQuery.of(context).size.height * 0.035, fontFamily: 'young'), ), )), Flexible( child: Padding( padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.02), child: Text( 'Codername is like a Username,\n*Example: @god_Kira', style: TextStyle( color: ColorSchemeClass.darkgrey, fontSize: MediaQuery.of(context).size.height * 0.022, fontFamily: 'young'), textAlign: TextAlign.center, ), )), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), MyTextFormField(Icon(FontAwesomeIcons.at), 'codername', false, (val) { codername = val.toString().trim(); }, TextInputType.text, (val) => (val.toString().trim().contains(' ') || val.toString().trim().length < 4) ? 'Codername can only be consist a single word' : null), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Container( padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.03, vertical: MediaQuery.of(context).size.height * 0.01), height: MediaQuery.of(context).size.height * 0.09, child: MyButton( ColorSchemeClass.primarygreen, 'Next', _submit), ), ], ), ), ), ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/registerBioScreen.dart
import 'dart:async'; import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/screens/registerUserHandleScreen.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import '../components/myButtons.dart'; import '../components/myTextFormFields.dart'; import '../components/noInternet.dart'; void main() => runApp( MaterialApp( home: Registerbioscreen('Yuvraj Singh', '@curiousyuvi', 'kjfdnndfndfvjv'), ), ); class Registerbioscreen extends StatefulWidget { Registerbioscreen(String name, String codername, String avatarurl) { _RegisterbioscreenState.name = name; _RegisterbioscreenState.codername = codername; _RegisterbioscreenState.avatarurl = avatarurl; } @override _RegisterbioscreenState createState() => _RegisterbioscreenState(); } class _RegisterbioscreenState extends State<Registerbioscreen> { static String name = ''; static String codername = ''; static String avatarurl = ''; static String bio = ''; final _formkey = GlobalKey<FormState>(); StreamSubscription subscription; @override initState() { super.initState(); subscription = InternetConnectionChecker().onStatusChange.listen((status) { final hasInternet = status == InternetConnectionStatus.connected; if (!hasInternet) noInternet(this.context); }); } @override void dispose() { subscription.cancel(); super.dispose(); } void _submit() { if (_formkey.currentState.validate()) { _formkey.currentState.save(); Navigator.push(context, MaterialPageRoute(builder: (context) { return RegisterUserHandleScreen(name, codername, avatarurl, bio); })); } } @override Widget build(BuildContext context) { return GestureDetector( onTap: () { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } }, child: Scaffold( backgroundColor: ColorSchemeClass.dark, body: SafeArea( child: Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.04), child: Form( key: _formkey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Flexible( child: Hero( tag: 'appIcon', child: Image( width: MediaQuery.of(context).size.width * 0.45, image: AssetImage('images/appiconnoback.png'), ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.05, ), Flexible( child: Padding( padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.02), child: Text( 'Write a small Bio about you', style: TextStyle( color: Colors.white, fontSize: MediaQuery.of(context).size.height * 0.033, fontFamily: 'young'), ), )), Flexible( child: Padding( padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.02), child: Text( '*Example: Hey there, I love Competitive Programming', style: TextStyle( color: ColorSchemeClass.darkgrey, fontSize: MediaQuery.of(context).size.height * 0.021, fontFamily: 'young'), textAlign: TextAlign.center, ), )), MyPassageTextEormField('Bio', (val) { bio = val.toString().trim(); }, (val) => val.toString().trim().length > 100 || val.toString().trim().length == 0 ? 'Bio should be under 100 characters' : null), Row( children: [ Flexible( child: Container( padding: EdgeInsets.symmetric( horizontal: 0, vertical: MediaQuery.of(context).size.height * 0.022), height: MediaQuery.of(context).size.height * 0.12, child: MyOutlineButton( ColorSchemeClass.lightgrey, 'Skip', () { bio = 'Hey there, I love Competitive Programming'; Navigator.push(context, MaterialPageRoute(builder: (context) { return RegisterUserHandleScreen( name, codername, avatarurl, bio); })); })), ), Flexible( child: Container( padding: EdgeInsets.symmetric( horizontal: 0, vertical: MediaQuery.of(context).size.height * 0.022), height: MediaQuery.of(context).size.height * 0.115, child: MyButton(ColorSchemeClass.primarygreen, 'Next', _submit)), ), ], ) ], ), ), ), ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/deleteAccountScreen.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/confirmationDialog.dart'; import 'package:coder_status/components/generalLoader.dart'; import 'package:coder_status/firebase_layer/deleteUser.dart'; import 'package:coder_status/firebase_layer/logoutUser.dart'; import 'package:coder_status/firebase_layer/validatePassword.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart' as gradient; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_phoenix/flutter_phoenix.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import '../components/myAppBar.dart'; import '../components/myTextFormFields.dart'; import '../components/myButtons.dart'; class DeleteAccountScreen extends StatefulWidget { @override _DeleteAccountScreenState createState() => _DeleteAccountScreenState(); } class _DeleteAccountScreenState extends State<DeleteAccountScreen> { String password = ''; bool passwordmatch = false; bool isLoading = false; final _formkey = GlobalKey<FormState>(); void _submit() async { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } //start loader setState(() { isLoading = true; }); passwordmatch = await validatePassword(password); //stop loader setState(() { isLoading = false; }); if (_formkey.currentState.validate()) { _formkey.currentState.save(); //start loader setState(() { isLoading = true; }); try { await deleteUser(password); await logout(context); Phoenix.rebirth(context); } catch (e) {} //end loader setState(() { isLoading = false; }); } } @override Widget build(BuildContext context) { return Stack( children: [ GestureDetector( onTap: () { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } }, child: Scaffold( backgroundColor: ColorSchemeClass.dark, appBar: PreferredSize( preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.08), child: MyAppBarWithBack('Delete Account'), ), body: SafeArea( child: Container( padding: EdgeInsets.all(16), child: Form( key: _formkey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Flexible( child: Padding( padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.04), child: ClipRRect( borderRadius: BorderRadius.circular(10), child: Container( decoration: BoxDecoration( gradient: gradient.LinearGradient(stops: [ 0.0, 0.5, ], colors: [ ColorSchemeClass.morphdangerred, ColorSchemeClass.unactivatedblack, ])), width: double.infinity, height: MediaQuery.of(context).size.height * 0.16, child: Padding( padding: EdgeInsets.all( MediaQuery.of(context).size.height * 0.03), child: Row( children: [ Container( height: MediaQuery.of(context).size.height * 0.05, width: MediaQuery.of(context).size.height * 0.05, decoration: BoxDecoration( shape: BoxShape.circle, color: ColorSchemeClass.dangerred), child: Icon(Icons.priority_high)), SizedBox( width: MediaQuery.of(context).size.width * 0.06, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Account Delete Alert', textAlign: TextAlign.left, style: TextStyle( color: ColorSchemeClass.dangerred, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.03), ), SizedBox( height: MediaQuery.of(context) .size .height * 0.01, ), Container( width: MediaQuery.of(context) .size .width * 0.5, height: MediaQuery.of(context) .size .height * 0.06, child: FittedBox( alignment: Alignment.centerLeft, fit: BoxFit.scaleDown, child: Text( 'If you continue further your account\nwill be deleted permanentally and\n all your account\'s data will be lost.\nYou will have to create a new\naccount from scratch', textAlign: TextAlign.left, style: TextStyle( color: ColorSchemeClass .lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.02), ), ), ) ], ) ], )), ), ), )), SizedBox( height: MediaQuery.of(context).size.height * 0.03), Theme( data: ThemeData( accentColor: ColorSchemeClass.dangerred, primaryColor: ColorSchemeClass.dangerred), child: MyTextFormField( Icon(Icons.vpn_key), 'Enter Password', true, (val) { password = val; }, TextInputType.visiblePassword, (password) { return passwordmatch ? null : 'Password is incorrect'; }, null, ColorSchemeClass.dangerred), ), Container( padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.03, vertical: MediaQuery.of(context).size.height * 0.01), height: MediaQuery.of(context).size.height * 0.09, child: MyButton( ColorSchemeClass.dangerred, 'Delete Account', () { showConfirmationDialog( this.context, 'CONFIRM ACCOUNT DELETION', 'If you accept your account will be deleted permanently. Do you want to continue?', () { _submit(); }, false, FontAwesomeIcons.trash); }, Icons.delete), ), ], ), ), ), ), ), ), isLoading ? GeneralLoaderTransparent('') : SizedBox.shrink() ], ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/myDashboardScreen.dart
import 'package:coder_status/components/atcoderDialog.dart'; import 'package:coder_status/components/codechefDialog.dart'; import 'package:coder_status/components/codeforcesDialog.dart'; import 'package:coder_status/components/myDashboardScreenSkeleton.dart'; import 'package:coder_status/components/myDividerWithTitle.dart'; import 'package:coder_status/components/myRatingCard.dart'; import 'package:coder_status/components/spojDialog.dart'; import 'package:coder_status/components/urls.dart'; import 'package:coder_status/firebase_layer/getUserInfo.dart'; import 'package:coder_status/functions/getRating.dart'; import 'package:dotted_border/dotted_border.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:coder_status/components/colorscheme.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:rect_getter/rect_getter.dart'; import 'package:rive/rive.dart'; import '../components/myCircleAvatar.dart'; class MyDashboardScreen extends StatefulWidget { @override _MyDashboardScreenState createState() => _MyDashboardScreenState(); } class _MyDashboardScreenState extends State<MyDashboardScreen> { var globalKey1 = RectGetter.createGlobalKey(); var globalKey2 = RectGetter.createGlobalKey(); var globalKey3 = RectGetter.createGlobalKey(); var globalKey4 = RectGetter.createGlobalKey(); String name = 'name', codername = 'codername', avatarurl = Urls.avatar1url, bio = 'Hey there, I love Competitive Programming'; List<String> userhandles = ['', '', '', ''], userrating = ['0', '0', '0', '0']; bool isFirstTimeUserData = true; bool isFirstTimeUserRatings = true; List<Widget> listOfRatingCards = []; readyUserData() async { final userDocument = await GetUserInfo.getUserDocument(); avatarurl = userDocument['avatarurl']; name = userDocument['name']; codername = userDocument['codername']; bio = userDocument['bio']; setState(() { isFirstTimeUserData = false; }); } readyUserRatings() async { final userDocument = await GetUserInfo.getUserDocument(); userhandles[0] = userDocument['codeforces']; userhandles[1] = userDocument['codechef']; userhandles[2] = userDocument['atcoder']; userhandles[3] = userDocument['spoj']; if (userhandles[0] != '') { userrating[0] = await GetRating.getCodeforcesRating(userhandles[0]); if (userrating[0] != '0') listOfRatingCards.add(RectGetter( key: globalKey1, child: GestureDetector( onTap: () { var rect = RectGetter.getRectFromKey(globalKey1); showCodeforcesDialog( this.context, rect, userhandles[0], userrating[0]); }, child: MyRatingCard(AssetImage('images/codeforcestile.png'), ColorSchemeClass.codeforcespurple, userrating[0] + ' pts'), ), )); } if (userhandles[1] != '') { userrating[1] = await GetRating.getCodechefRating(userhandles[1]); if (userrating[1] != '0') listOfRatingCards.add(RectGetter( key: globalKey2, child: GestureDetector( onTap: () { var rect = RectGetter.getRectFromKey(globalKey2); showCodechefDialog( this.context, rect, userhandles[1], userrating[1]); }, child: MyRatingCard(AssetImage('images/codecheftile.png'), ColorSchemeClass.codechefbrown, userrating[1] + ' pts'), ), )); } if (userhandles[2] != '') { userrating[2] = await GetRating.getAtcoderRating(userhandles[2]); if (userrating[2] != '0') listOfRatingCards.add(RectGetter( key: globalKey3, child: GestureDetector( onTap: () { var rect = RectGetter.getRectFromKey(globalKey3); showAtcoderDialog( this.context, rect, userhandles[2], userrating[2]); }, child: MyRatingCard(AssetImage('images/atcodertile.png'), ColorSchemeClass.atcodergrey, userrating[2] + ' pts'), ), )); } if (userhandles[3] != '') { userrating[3] = await GetRating.getSpojRating(userhandles[3]); if (userrating[3] != '0') listOfRatingCards.add(RectGetter( key: globalKey4, child: GestureDetector( onTap: () { var rect = RectGetter.getRectFromKey(globalKey4); showSpojDialog(this.context, rect, userhandles[3], userrating[3]); }, child: MyRatingCard(AssetImage('images/spojtile.png'), ColorSchemeClass.spojblue, userrating[3] + ' pts'), ), )); } setState(() { isFirstTimeUserRatings = false; }); } Future futureFunctionUserData; Future futureFunctionUserRatings; @override void initState() { super.initState(); futureFunctionUserData = readyUserData(); futureFunctionUserRatings = readyUserRatings(); } @override Widget build(BuildContext context) { return isFirstTimeUserData ? FutureBuilder( builder: (context, snapshot) { return MyDashboardScreenSkeleton(); }, future: futureFunctionUserData, ) : Scaffold( body: SafeArea( child: Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.03), child: SingleChildScrollView( child: Column( children: [ Container( padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.015), width: double.infinity, height: MediaQuery.of(context).size.height * 0.07, child: Center( child: Image( image: AssetImage('images/appiconnoback.png')), ), ), Column( children: [ SizedBox( height: MediaQuery.of(context).size.height * 0.03, ), Container( height: MediaQuery.of(context).size.height * 0.22, width: MediaQuery.of(context).size.height * 0.22, child: MyCircleAvatar(Image.network(avatarurl))), SizedBox( height: MediaQuery.of(context).size.height * 0.025, ), Text( name, style: TextStyle( color: Colors.white, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.035), ), SizedBox( height: MediaQuery.of(context).size.height * 0.007, ), Text( '@' + codername, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.025), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), MyMidDividerWithTitle('Bio'), SizedBox( height: MediaQuery.of(context).size.height * 0.015, ), Text( bio, textAlign: TextAlign.center, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02), ), SizedBox( height: MediaQuery.of(context).size.height * 0.015, ), MyMidDividerWithTitle('Ratings'), SizedBox( height: MediaQuery.of(context).size.height * 0.01, ), isFirstTimeUserRatings ? FutureBuilder( future: futureFunctionUserRatings, builder: (context, snapshot) { return Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: [ RantingTileSkeleton(), RantingTileSkeleton(), ]), Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: [ RantingTileSkeleton(), RantingTileSkeleton(), ]) ], ); }) : listOfRatingCards.length == 0 ? Container( height: MediaQuery.of(context).size.height * 0.3, child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: [ DottedBorder( strokeWidth: 1, dashPattern: [5, 5], color: ColorSchemeClass.lightgrey, child: Container( padding: EdgeInsets.all( MediaQuery.of(context) .size .width * 0.05), child: Text( 'NO RATINGS', textAlign: TextAlign.center, style: TextStyle( color: ColorSchemeClass .lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.02), ), ), ), SizedBox( height: MediaQuery.of(context) .size .height * 0.04, ), Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: [ Text( 'Go to ', style: TextStyle( color: ColorSchemeClass .lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.02), ), Column(children: [ Icon( Icons.settings, color: ColorSchemeClass .primarygreen, size: MediaQuery.of(context) .size .width * 0.08, ), Text( 'Settings', style: TextStyle( color: ColorSchemeClass .primarygreen, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.016), ), ]), Text( ' to add User Handles', style: TextStyle( color: ColorSchemeClass .lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.02), ), ], ), ], ), ) : listOfRatingCards.length == 1 || listOfRatingCards.length == 2 ? Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: listOfRatingCards) ], ) : Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: listOfRatingCards .sublist(0, 2)), Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: listOfRatingCards .sublist(2)) ], ) ], ), ], ), ), ), ), ); } } class RantingTileSkeleton extends StatelessWidget { const RantingTileSkeleton({ Key key, }) : super(key: key); @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.05), child: ClipRRect( borderRadius: BorderRadius.circular(5), child: Container( width: MediaQuery.of(context).size.width * 0.2, height: MediaQuery.of(context).size.width * 0.25, child: RiveAnimation.asset( 'assets/skeleton-place-holder.riv', fit: BoxFit.cover, ))), ); } } /* */
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/signUpScreen.dart
import 'dart:async'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:coder_status/components/generalLoader.dart'; import 'package:coder_status/screens/registerCodernameScreen.dart'; import 'package:coder_status/screens/registerEmailidScreen.dart'; import 'package:coder_status/screens/signInScreen.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import 'package:provider/provider.dart'; import '../components/colorscheme.dart'; import '../components/showAnimatedToast.dart'; import '../firebase_layer/googleSignInProvider.dart'; import '../home.dart'; import '../components/noInternet.dart'; class SignUpScreen extends StatefulWidget { @override _SignUpScreenState createState() => _SignUpScreenState(); } class _SignUpScreenState extends State<SignUpScreen> { bool isLoading = false; StreamSubscription subscription; @override initState() { super.initState(); subscription = InternetConnectionChecker().onStatusChange.listen((status) { final hasInternet = status == InternetConnectionStatus.connected; if (!hasInternet) noInternet(this.context); }); } @override void dispose() { subscription.cancel(); super.dispose(); } @override Widget build(BuildContext context) { return Stack( children: [ Scaffold( body: SafeArea( child: Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.04), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Flexible( child: Hero( tag: 'appIcon', child: Image( width: MediaQuery.of(context).size.width * 0.5, image: AssetImage('images/appiconnoback.png'), ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01, ), RichText( text: TextSpan( style: TextStyle( color: Colors.white, fontFamily: 'headline', fontSize: MediaQuery.of(context).size.height * 0.06), children: [ TextSpan( text: 'CODER', ), TextSpan( text: ' STATUS', style: TextStyle( color: ColorSchemeClass.primarygreen)) ]), ), SizedBox( height: MediaQuery.of(context).size.height * 0.1, ), GestureDetector( onTap: () async { final provider = Provider.of<GoogleSigInProvider>(context, listen: false); setState(() { isLoading = true; }); final user = await provider.googleLogin(); if (user == null) { setState(() { isLoading = false; }); showAnimatedToast( this.context, 'Something went wrong', false); } else { bool flag = false; try { await FirebaseFirestore.instance .collection('users') .doc(user.uid) .get() .then((doc) { flag = doc.exists; }); } catch (e) { flag = false; } if (flag) { Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) { return Home(); }), ModalRoute.withName('/home')); } else { Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) { return Registercodernamescreen( user.displayName.toString().trim()); }), ModalRoute.withName('/registerCodername')); } } }, child: Container( width: double.infinity, height: MediaQuery.of(context).size.height * 0.07, padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.15, vertical: MediaQuery.of(context).size.width * 0.01), decoration: BoxDecoration( color: ColorSchemeClass.dangerred, borderRadius: BorderRadius.circular(5)), child: FittedBox( fit: BoxFit.scaleDown, child: Row( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ FaIcon( FontAwesomeIcons.google, color: Colors.white, ), SizedBox( width: MediaQuery.of(context).size.width * 0.08, ), Text( 'Sign Up With Google', style: TextStyle( color: Colors.white, fontSize: MediaQuery.of(context).size.width * 0.055, fontFamily: 'young', fontWeight: FontWeight.bold), ) ], ), ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return RegisterEmailidScreen(); })); }, child: Container( width: double.infinity, height: MediaQuery.of(context).size.height * 0.07, padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.15, vertical: MediaQuery.of(context).size.width * 0.01), decoration: BoxDecoration( color: ColorSchemeClass.primarygreen, borderRadius: BorderRadius.circular(5)), child: FittedBox( fit: BoxFit.scaleDown, child: Row( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ FaIcon( FontAwesomeIcons.solidEnvelope, color: Colors.white, ), SizedBox( width: MediaQuery.of(context).size.width * 0.08, ), Text( 'Sign Up With Email', style: TextStyle( color: Colors.white, fontSize: MediaQuery.of(context).size.width * 0.055, fontFamily: 'young', fontWeight: FontWeight.bold), ), ], ), ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.06, ), Flexible( child: GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return SignInScreen(); })); }, child: Text( 'Already have an account?Sign In', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02, decoration: TextDecoration.underline), )), ), ], ), ), ), ), isLoading ? GeneralLoaderTransparent('') : SizedBox.shrink() ], ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/spojRankingScreen.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/myRankingUserTile.dart'; import 'package:coder_status/components/rankingScreenSkeleton.dart'; import 'package:coder_status/firebase_layer/getUserInfo.dart'; import 'package:coder_status/functions/getRating.dart'; import 'package:flutter/material.dart'; import '../components/myAppBar.dart'; import '../components/myButtons.dart'; import '../components/topThreeRankingCard.dart'; class SpojRankingScreen extends StatefulWidget { const SpojRankingScreen({Key key}) : super(key: key); @override _SpojRankingScreenState createState() => _SpojRankingScreenState(); } class _SpojRankingScreenState extends State<SpojRankingScreen> { List<Widget> listOfUserTiles = []; bool isFirstTime = true; var listOfUserData = []; getPeersList() async { //initializing the lists empty listOfUserTiles = []; listOfUserData = []; //getting my own map data var myAvatarurl = await GetUserInfo.getUserAvatarUrl(); var myUserHandles = await GetUserInfo.getUserHandles(); //if I have that handle only then add me to ranking data if (myUserHandles[3] != "") { var myRating = await GetRating.getSpojRating(myUserHandles[3]); //if I have rating other than 0 only then add me to ranking data if (myRating != '0') { listOfUserData.add({ 'avatarurl': myAvatarurl, 'userHandle': myUserHandles[3], 'rating': myRating }); } } //getting list of uids of my peers var peers = await GetUserInfo.getUserPeers(); //If I have peers only then proceed if (peers.length > 0) { //loop through all peer uids for (int i = 0; i < peers.length; i++) { //get document map of uid var peerDocument = await GetUserInfo.getUserDocument(peers[i]); //if the peer's document map has user Handle then then add it to ranking data try { if (peerDocument['spoj'] != '') { //fetch rating for the current peer var rating = await GetRating.getSpojRating(peerDocument['spoj']); //if current peer has rating not equal to zero then add it to ranking data if (rating != '0') { //if initial list is not empty add to ranking data in descending sort if (listOfUserData.length > 0) { for (int j = 0; j < listOfUserData.length; j++) { if (double.parse(listOfUserData[j]['rating']) <= double.parse(rating)) { listOfUserData.insert(j, { 'avatarurl': peerDocument['avatarurl'], 'userHandle': peerDocument['spoj'], 'rating': rating }); break; } else { if (j == (listOfUserData.length - 1)) { listOfUserData.add({ 'avatarurl': peerDocument['avatarurl'], 'userHandle': peerDocument['spoj'], 'rating': rating }); break; } } } } else { //since initial list is empty listOfUserData.add({ 'avatarurl': peerDocument['avatarurl'], 'userHandle': peerDocument['spoj'], 'rating': rating }); } } } } catch (e) { continue; } } //converting ranking data into widgets } if (listOfUserData.length >= 3) { listOfUserTiles.add(TopThreeRankingCard( listOfUserData[0]['avatarurl'], listOfUserData[1]['avatarurl'], listOfUserData[2]['avatarurl'], listOfUserData[0]['userHandle'], listOfUserData[1]['userHandle'], listOfUserData[2]['userHandle'], listOfUserData[0]['rating'], listOfUserData[1]['rating'], listOfUserData[2]['rating'])); for (int j = 3; j < listOfUserData.length; j++) { listOfUserTiles.add(MyRankingUserTile( listOfUserData[j]['avatarurl'], listOfUserData[j]['userHandle'], listOfUserData[j]['rating'], (j + 1))); } } else { for (int j = 0; j < listOfUserData.length; j++) { listOfUserTiles.add(MyRankingUserTile( listOfUserData[j]['avatarurl'], listOfUserData[j]['userHandle'], listOfUserData[j]['rating'], (j + 1))); } } setState(() { isFirstTime = false; }); } Future futureFunction; @override void initState() { super.initState(); futureFunction = getPeersList(); } @override Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( child: MyAppBarWithBack('Spoj Ranking'), preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.08), ), body: isFirstTime ? FutureBuilder( future: futureFunction, builder: (context, snapshot) { return Center( child: RankingScreenSkeleton(), ); }, ) : listOfUserTiles.length == 0 ? Container( height: MediaQuery.of(context).size.height * 0.7, child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'You and your peers are not on Spoj', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.025), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Container( height: MediaQuery.of(context).size.height * 0.05, width: MediaQuery.of(context).size.width * 0.5, child: MyButton( ColorSchemeClass.primarygreen, 'Refresh', () { setState(() { futureFunction = getPeersList(); isFirstTime = true; }); }, Icons.refresh), ) ], ), ), ) : RefreshIndicator( backgroundColor: ColorSchemeClass.unactivatedblack, onRefresh: () async { await getPeersList(); return 0; }, child: ListView( children: listOfUserTiles, ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/updatePasswordScreen.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/confirmationDialog.dart'; import 'package:coder_status/components/showAnimatedToast.dart'; import 'package:coder_status/firebase_layer/updatePassword.dart'; import 'package:coder_status/firebase_layer/validatePassword.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import '../components/generalLoader.dart'; import '../components/myAppBar.dart'; import '../components/myTextFormFields.dart'; import '../components/myButtons.dart'; class UpdatePasswordScreen extends StatefulWidget { @override _UpdatePasswordScreenState createState() => _UpdatePasswordScreenState(); } class _UpdatePasswordScreenState extends State<UpdatePasswordScreen> { String oldPass = ''; String newPass = ''; bool isLoading = false; bool oldpasswordmatch = true; final _formkey = GlobalKey<FormState>(); void _submit() async { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } //start loader setState(() { isLoading = true; }); oldpasswordmatch = await validatePassword(oldPass); //stop loader setState(() { isLoading = false; }); if (_formkey.currentState.validate()) { _formkey.currentState.save(); //start loader setState(() { isLoading = true; }); try { await updatePassword(oldPass, newPass); //Toast showAnimatedToast(this.context, 'Password Updated Successfully.', true); Navigator.pop(context); } catch (e) {} //stop loader setState(() { isLoading = false; }); } } @override Widget build(BuildContext context) { return Stack( children: [ GestureDetector( onTap: () { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } }, child: Scaffold( appBar: PreferredSize( preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.08), child: MyAppBarWithBack('Update Password'), ), backgroundColor: ColorSchemeClass.dark, body: SafeArea( child: Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.04), child: Form( key: _formkey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Flexible( child: Padding( padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.02), child: Text( 'Use a combination of letters, digits and special characters', style: TextStyle( color: ColorSchemeClass.darkgrey, fontSize: MediaQuery.of(context).size.height * 0.022, fontFamily: 'young'), textAlign: TextAlign.center), )), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), MyTextFormField( Icon(Icons.vpn_key), 'old password', true, (val) { setState(() { oldPass = val; }); }, TextInputType.visiblePassword, (oldpassword) { return oldpasswordmatch ? null : 'Old password doesn\'t match'; }), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), MyTextFormField(Icon(Icons.vpn_key), 'new password', true, (val) { setState(() { newPass = val; }); }, TextInputType.visiblePassword, (val) => val.trim().length < 6 ? 'Password must contain atleast 6 characters' : null), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), MyTextFormField( Icon(Icons.vpn_key), 'confirm new password', true, (val) {}, TextInputType.visiblePassword, (val) => val != newPass ? 'Password doesn\'t match' : null), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Container( padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.03, vertical: MediaQuery.of(context).size.height * 0.01), height: MediaQuery.of(context).size.height * 0.09, child: MyButton( ColorSchemeClass.primarygreen, 'Update Password', () { showConfirmationDialog( this.context, 'CONFIRM PASSWORD CHANGE', 'If you accept your account pssword will be changed. Do you want to continue?', () { _submit(); }, true, FontAwesomeIcons.key); }, )), ], ), ), ), ), ), ), isLoading ? GeneralLoaderTransparent('') : SizedBox.shrink() ], ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/registerEmailidScreen.dart
import 'dart:async'; import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/generalLoader.dart'; import 'package:coder_status/screens/signInEmailScreen.dart'; import 'package:coder_status/screens/registerPasswordScreen.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import '../components/myTextFormFields.dart'; import '../components/myButtons.dart'; import '../components/noInternet.dart'; class RegisterEmailidScreen extends StatefulWidget { @override _RegisterEmailidScreenState createState() => _RegisterEmailidScreenState(); } class _RegisterEmailidScreenState extends State<RegisterEmailidScreen> { String emailid = ''; final _formkey = GlobalKey<FormState>(); bool isLoading = false; StreamSubscription subscription; @override initState() { super.initState(); subscription = InternetConnectionChecker().onStatusChange.listen((status) { final hasInternet = status == InternetConnectionStatus.connected; if (!hasInternet) noInternet(this.context); }); } @override void dispose() { subscription.cancel(); super.dispose(); } void _submit() async { if (_formkey.currentState.validate()) { _formkey.currentState.save(); Navigator.push(context, MaterialPageRoute(builder: (context) { return RegisterPasswordScreen(emailid); })); } } @override Widget build(BuildContext context) { return Stack( children: [ GestureDetector( onTap: () { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } }, child: Scaffold( backgroundColor: ColorSchemeClass.dark, body: SafeArea( child: Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.04), child: Form( key: _formkey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ MediaQuery.of(context).viewInsets.bottom == 0 ? Flexible( child: Hero( tag: 'appIcon', child: Image( width: MediaQuery.of(context).size.width * 0.4, image: AssetImage('images/appiconnoback.png'), ), ), ) : SizedBox.shrink(), SizedBox( height: MediaQuery.of(context).size.height * 0.01, ), MediaQuery.of(context).viewInsets.bottom == 0 ? Flexible( child: RichText( text: TextSpan( style: TextStyle( color: Colors.white, fontFamily: 'headline', fontSize: MediaQuery.of(context).size.height * 0.06), children: [ TextSpan( text: 'CODER', ), TextSpan( text: ' STATUS', style: TextStyle( color: ColorSchemeClass .primarygreen)) ]), ), ) : SizedBox.shrink(), SizedBox( height: MediaQuery.of(context).size.height * 0.05, ), Flexible( child: Text( 'Enter Your Email Id', style: TextStyle( color: Colors.white, fontSize: MediaQuery.of(context).size.height * 0.03, fontFamily: 'young'), )), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Flexible( child: Text( 'A verification link will be sent to your given Email', style: TextStyle( color: ColorSchemeClass.darkgrey, fontSize: 15, fontFamily: 'young'), textAlign: TextAlign.center)), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), MyTextFormField(Icon(FontAwesomeIcons.solidEnvelope), 'email id', false, (val) { emailid = val; }, TextInputType.emailAddress, (val) => !val.contains('@') ? 'Please enter a valid email' : null), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Container( padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.03, vertical: MediaQuery.of(context).size.height * 0.01), height: MediaQuery.of(context).size.height * 0.09, child: MyButton( ColorSchemeClass.primarygreen, 'Next', _submit), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return SignInEmailScreen(); })); }, child: Text( 'Already have an account? Log in', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02, decoration: TextDecoration.underline), )), ], ), ), ), ), ), ), isLoading ? GeneralLoaderTransparent('') : SizedBox.shrink() ], ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/settingScreen.dart
import 'package:coder_status/screens/aboutDeveloperScreen.dart'; import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/confirmationDialog.dart'; import 'package:coder_status/components/generalLoader.dart'; import 'package:coder_status/components/myAppBar.dart'; import 'package:coder_status/components/mySettingTiles.dart'; import 'package:coder_status/screens/deleteAccountScreen.dart'; import 'package:coder_status/screens/editProfileScreen.dart'; import 'package:coder_status/firebase_layer/deleteUser.dart'; import 'package:coder_status/firebase_layer/logoutUser.dart'; import 'package:coder_status/screens/updatePasswordScreen.dart'; import 'package:coder_status/screens/editUserHandlesScreen.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:flutter_phoenix/flutter_phoenix.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:google_sign_in/google_sign_in.dart'; class SettingScreen extends StatefulWidget { const SettingScreen({Key key}) : super(key: key); @override _SettingScreenState createState() => _SettingScreenState(); } class _SettingScreenState extends State<SettingScreen> { bool isLoading = false; @override Widget build(BuildContext context) { return Stack( children: [ Scaffold( appBar: PreferredSize( preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.08), child: MyAppBar('Settings'), ), body: SafeArea( child: Container( width: double.infinity, height: double.infinity, padding: EdgeInsets.all(24), child: SingleChildScrollView( child: Column(children: [ SizedBox( height: MediaQuery.of(context).size.height * 0.04, ), GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return EditProfileScreen(); })); }, child: MySettingsNonExpansionTile( Icon( FontAwesomeIcons.solidEdit, color: ColorSchemeClass.lightgrey, ), 'Edit Profile'), ), GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return EditUserHandlesScreen(); })); }, child: MySettingsNonExpansionTile( Icon( FontAwesomeIcons.thLarge, color: ColorSchemeClass.lightgrey, ), 'User Handles'), ), MySettingsExpansionTile( Icon(FontAwesomeIcons.userLock), 'Account & Security', [ GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return UpdatePasswordScreen(); })); }, child: MyChildListTile( Icon( FontAwesomeIcons.key, color: ColorSchemeClass.dark, ), 'Change Password'), ), GestureDetector( onTap: () { if (FirebaseAuth.instance.currentUser.photoURL == null) { Navigator.push(context, MaterialPageRoute(builder: (context) { return DeleteAccountScreen(); })); } else { showConfirmationDialog( this.context, 'CONFIRM ACCOUNT DELETION', 'If you accept your account will be deleted permanently. Do you want to continue?', () async { setState(() { isLoading = true; }); await deleteUser(); await GoogleSignIn().disconnect(); await logout(context); Phoenix.rebirth(context); }, false, FontAwesomeIcons.trash); } }, child: MyChildListTile( Icon( FontAwesomeIcons.trash, color: ColorSchemeClass.dangerred, ), 'Delete Account', ColorSchemeClass.dangerred), ), ], ), GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return AboutDeveloperScreen(); })); }, child: MySettingsNonExpansionTile( Icon( FontAwesomeIcons.info, color: ColorSchemeClass.lightgrey, ), 'About Developer'), ), GestureDetector( onTap: () { showConfirmationDialog( this.context, 'Log Out', 'Do you want to log out?', () { logout(context); }, false, FontAwesomeIcons.signOutAlt); }, child: MySettingsNonExpansionTile( Icon( FontAwesomeIcons.signOutAlt, color: ColorSchemeClass.lightgrey, ), 'Log Out', ColorSchemeClass.dangerred, ColorSchemeClass.dangerred), ), ]), ), ), )), isLoading ? GeneralLoaderTransparent('') : SizedBox.shrink() ], ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/peersScreen.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/myAppBar.dart'; import 'package:coder_status/components/myButtons.dart'; import 'package:coder_status/components/myUserTile.dart'; import 'package:coder_status/components/peerScreenSkeleton.dart'; import 'package:coder_status/firebase_layer/getUserInfo.dart'; import 'package:dotted_border/dotted_border.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:rive/rive.dart'; class PeersScreen extends StatefulWidget { const PeersScreen({Key key}) : super(key: key); @override _PeersScreenState createState() => _PeersScreenState(); } class _PeersScreenState extends State<PeersScreen> { List<Widget> listOfUserTiles = []; bool isFirstTime = true; getPeersList() async { listOfUserTiles = []; var peers = await GetUserInfo.getUserPeers(); if (peers.length != 0) { for (int i = 0; i < peers.length; i++) { try { var peerDocument = await GetUserInfo.getUserDocument(peers[i]); listOfUserTiles.add(MyUserTile( peerDocument['id'], peerDocument['avatarurl'], peerDocument['name'], peerDocument['codername'])); } catch (e) {} } } setState(() { isFirstTime = false; }); } Future futureFunction; @override void initState() { super.initState(); futureFunction = getPeersList(); } @override Widget build(BuildContext context) { return isFirstTime ? FutureBuilder( future: futureFunction, builder: (context, snapshot) { return PeersScreenSkeleton(); }, ) : Scaffold( appBar: PreferredSize( child: MyAppBar('Peers'), preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.08), ), body: listOfUserTiles.length == 0 ? Container( height: MediaQuery.of(context).size.height * 0.7, child: Center( child: FittedBox( fit: BoxFit.scaleDown, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( height: MediaQuery.of(context).size.width * 0.9, width: MediaQuery.of(context).size.width * 0.9, child: RiveAnimation.asset('assets/no-peers.riv'), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), DottedBorder( strokeWidth: 1, dashPattern: [5, 5], color: ColorSchemeClass.lightgrey, child: Container( padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.04), child: Text( 'You haven\'t added any Peers', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02), ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: [ Text( 'Go to ', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02), ), Column(children: [ Icon( CupertinoIcons.search, color: ColorSchemeClass.primarygreen, size: MediaQuery.of(context).size.width * 0.08, ), Text( 'Search', style: TextStyle( color: ColorSchemeClass.primarygreen, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.016), ), ]), Text( ' to add Peers', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02), ), ], ), SizedBox( height: MediaQuery.of(context).size.height * 0.03, ), Container( height: MediaQuery.of(context).size.height * 0.05, width: MediaQuery.of(context).size.width * 0.5, child: MyButton( ColorSchemeClass.primarygreen, 'Refresh', () { setState(() { futureFunction = getPeersList(); isFirstTime = true; }); }, Icons.refresh), ) ], ), ), ), ) : RefreshIndicator( backgroundColor: ColorSchemeClass.unactivatedblack, onRefresh: () async { await getPeersList(); return 0; }, child: ListView( children: listOfUserTiles, ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/signInEmailScreen.dart
import 'dart:async'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/generalLoader.dart'; import 'package:coder_status/components/showAnimatedToast.dart'; import 'package:coder_status/screens/forgotPasswordscreen.dart'; import 'package:coder_status/home.dart'; import 'package:coder_status/firebase_layer/loginUser.dart'; import 'package:coder_status/screens/registerEmailidScreen.dart'; import 'package:coder_status/screens/verifyEmailScreen.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import '../components/myTextFormFields.dart'; import '../components/myButtons.dart'; import '../components/noInternet.dart'; void main() => runApp( MaterialApp( home: SignInEmailScreen(), ), ); class SignInEmailScreen extends StatefulWidget { const SignInEmailScreen({Key key}) : super(key: key); @override _SignInEmailScreenState createState() => _SignInEmailScreenState(); } class _SignInEmailScreenState extends State<SignInEmailScreen> { //Form State StreamSubscription subscription; @override initState() { super.initState(); subscription = InternetConnectionChecker().onStatusChange.listen((status) { final hasInternet = status == InternetConnectionStatus.connected; if (!hasInternet) noInternet(this.context); }); } @override void dispose() { subscription.cancel(); super.dispose(); } final _formkey = GlobalKey<FormState>(); String emailid = ''; String password = ''; bool isLoading = false; void _submit() async { if (_formkey.currentState.validate()) { _formkey.currentState.save(); setState(() { isLoading = true; }); login(emailid.trim(), password.trim()).then((user) async { if (user != null) { bool flag; await FirebaseFirestore.instance .collection('users') .doc(user.uid) .get() .then((doc) { flag = doc.exists; }); if (flag) { Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) { return Home(); }), ModalRoute.withName('/home')); } else { Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) { return VerifyEmailScreen(); }), ModalRoute.withName('/emailVerify')); } } else { setState(() { isLoading = false; }); showAnimatedToast( this.context, 'Email or Password or both are incorrect.', false); } }); } } @override Widget build(BuildContext context) { return Stack( children: [ GestureDetector( onTap: () { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } }, child: Scaffold( body: SafeArea( child: Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.02), child: Form( key: _formkey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ MediaQuery.of(context).viewInsets.bottom == 0 ? Flexible( child: Hero( tag: 'appIcon', child: Image( width: MediaQuery.of(context).size.width * 0.5, image: AssetImage('images/appiconnoback.png'), ), ), ) : SizedBox.shrink(), SizedBox( height: MediaQuery.of(context).size.height * 0.01, ), MediaQuery.of(context).viewInsets.bottom == 0 ? RichText( text: TextSpan( style: TextStyle( color: Colors.white, fontFamily: 'headline', fontSize: MediaQuery.of(context).size.height * 0.06), children: [ TextSpan( text: 'CODER', ), TextSpan( text: ' STATUS', style: TextStyle( color: ColorSchemeClass.primarygreen)) ]), ) : SizedBox.shrink(), SizedBox( height: MediaQuery.of(context).size.height * 0.04, ), SizedBox( height: MediaQuery.of(context).size.height * 0.01, ), MyTextFormField(Icon(Icons.email), 'Email Id', false, (val) { emailid = val; }, TextInputType.emailAddress, (val) => !val.contains('@') ? 'Please enter a valid email' : null), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), MyTextFormField(Icon(Icons.vpn_key), 'Password', true, (val) { password = val; }, TextInputType.visiblePassword, (val) => val.trim().length < 6 ? 'Please enter a valid password' : null), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Container( padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.03, vertical: MediaQuery.of(context).size.height * 0.01), height: MediaQuery.of(context).size.height * 0.09, child: MyButton( ColorSchemeClass.primarygreen, 'Log in', _submit), ), SizedBox( height: MediaQuery.of(context).size.height * 0.025, ), Flexible( child: GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return RegisterEmailidScreen(); })); }, child: Text( 'Create Account', style: TextStyle( color: ColorSchemeClass.primarygreen, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.022, decoration: TextDecoration.underline), )), ), SizedBox( height: MediaQuery.of(context).size.height * 0.025, ), Flexible( child: GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return Forgotpasswordscreen(); })); }, child: Text( 'Forgot Password?', style: TextStyle( color: Colors.white, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02, decoration: TextDecoration.underline), )), ) ], ), ), ), ), ), ), isLoading ? GeneralLoaderTransparent('') : SizedBox.shrink() ], ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/searchScreen.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/myAppBar.dart'; import 'package:coder_status/components/myTextFormFields.dart'; import 'package:coder_status/components/myUserTile.dart'; import 'package:coder_status/firebase_layer/search.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:rive/rive.dart'; class SearchScreen extends StatefulWidget { const SearchScreen({Key key}) : super(key: key); @override _SearchScreenState createState() => _SearchScreenState(); } class _SearchScreenState extends State<SearchScreen> { //To store the list of users queried from firestore by using search key var queryResultSet = []; //List of User Tiles to be displayed List<Widget> listOfUserTiles = []; //***************************************************************************/ //*********************INSTANT SEARCH ALGORITHM******************************/ //***************************************************************************/ void initateSearch(String searchedValue) async { //if search field is empty then clear the queryResultSet and tempSearchStore if (searchedValue.length == 0) { setState(() { queryResultSet = []; listOfUserTiles = []; }); } /*the searched string is changed to uppercase and all spaces are removed*/ var morphedValue = searchedValue.toUpperCase().replaceAll(' ', ''); /*when the user enters the first character queryResultSet gets populated by the document of users with matching search key as the entered charachter*/ if (queryResultSet.length == 0 && searchedValue.length == 1) { QuerySnapshot querySnapshot = await SearchDatabase().searchByKey(morphedValue); querySnapshot.docs.forEach((element) { queryResultSet.add(element.data()); }); } /*when the user enters more charachter then the document from queryResultSet whose name and username starts with capitalizedValue is parsed and a MyUserTile widget of the user is added to listOfUserTiles*/ else { setState(() { listOfUserTiles = []; queryResultSet.forEach((element) { if (element['name'] .toString() .toUpperCase() .replaceAll(' ', '') .startsWith(morphedValue) || element['codername'] .toString() .toUpperCase() .replaceAll(' ', '') .startsWith(morphedValue)) { listOfUserTiles.add(MyUserTile(element['id'], element['avatarurl'], element['name'], element['codername'])); } }); }); } } @override Widget build(BuildContext context) { return GestureDetector( onTap: () { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } }, child: Scaffold( appBar: PreferredSize( child: MyAppBar('Search'), preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.08), ), body: SafeArea( child: Container( width: double.infinity, height: double.infinity, child: Column( children: [ MyTextFormField(Icon(CupertinoIcons.search), 'Search', false, (val) { initateSearch(val); }, TextInputType.name, (val) {}), SizedBox( height: MediaQuery.of(context).size.height * 0.03, ), listOfUserTiles.length == 0 ? Flexible( child: Center( child: FittedBox( fit: BoxFit.scaleDown, child: Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Flexible( child: Container( height: MediaQuery.of(context).size.width * 0.9, width: MediaQuery.of(context).size.width * 0.9, child: RiveAnimation.asset( 'assets/search-user.riv'), ), ), Text( 'Enter Name or Username to search', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontWeight: FontWeight.bold), ), ], ), ), ), ) : Expanded(child: ListView(children: listOfUserTiles)) ], ), )), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/codechefRankingScreen.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/myRankingUserTile.dart'; import 'package:coder_status/components/rankingScreenSkeleton.dart'; import 'package:coder_status/firebase_layer/getUserInfo.dart'; import 'package:coder_status/functions/getRating.dart'; import 'package:flutter/material.dart'; import '../components/myAppBar.dart'; import '../components/myButtons.dart'; import '../components/topThreeRankingCard.dart'; class CodechefRankingScreen extends StatefulWidget { const CodechefRankingScreen({Key key}) : super(key: key); @override _CodechefRankingScreenState createState() => _CodechefRankingScreenState(); } class _CodechefRankingScreenState extends State<CodechefRankingScreen> { List<Widget> listOfUserTiles = []; bool isFirstTime = true; var listOfUserData = []; getPeersList() async { //initializing the lists empty listOfUserTiles = []; listOfUserData = []; //getting my own map data var myAvatarurl = await GetUserInfo.getUserAvatarUrl(); var myUserHandles = await GetUserInfo.getUserHandles(); //if I have that handle only then add me to ranking data if (myUserHandles[1] != "") { var myRating = await GetRating.getCodechefRating(myUserHandles[1]); //if I have rating other than 0 only then add me to ranking data if (myRating != '0') { listOfUserData.add({ 'avatarurl': myAvatarurl, 'userHandle': myUserHandles[1], 'rating': myRating }); } } //getting list of uids of my peers var peers = await GetUserInfo.getUserPeers(); //If I have peers only then proceed if (peers.length > 0) { //loop through all peer uids for (int i = 0; i < peers.length; i++) { //get document map of uid var peerDocument = await GetUserInfo.getUserDocument(peers[i]); //if the peer's document map has user Handle then then add it to ranking data try { if (peerDocument['codechef'] != '') { //fetch rating for the current peer var rating = await GetRating.getCodechefRating(peerDocument['codechef']); //if current peer has rating not equal to zero then add it to ranking data if (rating != '0') { //if initial list is not empty add to ranking data in descending sort if (listOfUserData.length > 0) { for (int j = 0; j < listOfUserData.length; j++) { if (double.parse(listOfUserData[j]['rating']) <= double.parse(rating)) { listOfUserData.insert(j, { 'avatarurl': peerDocument['avatarurl'], 'userHandle': peerDocument['codechef'], 'rating': rating }); break; } else { if (j == (listOfUserData.length - 1)) { listOfUserData.add({ 'avatarurl': peerDocument['avatarurl'], 'userHandle': peerDocument['codechef'], 'rating': rating }); break; } } } } else { //since initial list is empty listOfUserData.add({ 'avatarurl': peerDocument['avatarurl'], 'userHandle': peerDocument['codechef'], 'rating': rating }); } } } } catch (e) { continue; } } //converting ranking data into widgets } if (listOfUserData.length >= 3) { listOfUserTiles.add(TopThreeRankingCard( listOfUserData[0]['avatarurl'], listOfUserData[1]['avatarurl'], listOfUserData[2]['avatarurl'], listOfUserData[0]['userHandle'], listOfUserData[1]['userHandle'], listOfUserData[2]['userHandle'], listOfUserData[0]['rating'], listOfUserData[1]['rating'], listOfUserData[2]['rating'])); for (int j = 3; j < listOfUserData.length; j++) { listOfUserTiles.add(MyRankingUserTile( listOfUserData[j]['avatarurl'], listOfUserData[j]['userHandle'], listOfUserData[j]['rating'], (j + 1))); } } else { for (int j = 0; j < listOfUserData.length; j++) { listOfUserTiles.add(MyRankingUserTile( listOfUserData[j]['avatarurl'], listOfUserData[j]['userHandle'], listOfUserData[j]['rating'], (j + 1))); } } setState(() { isFirstTime = false; }); } Future futureFunction; @override void initState() { super.initState(); futureFunction = getPeersList(); } @override Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( child: MyAppBarWithBack('Codechef Ranking'), preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.08), ), body: isFirstTime ? FutureBuilder( future: futureFunction, builder: (context, snapshot) { return Center( child: RankingScreenSkeleton(), ); }, ) : listOfUserTiles.length == 0 ? Container( height: MediaQuery.of(context).size.height * 0.7, child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'You and your peers are not on Codechef', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.025), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Container( height: MediaQuery.of(context).size.height * 0.05, width: MediaQuery.of(context).size.width * 0.5, child: MyButton( ColorSchemeClass.primarygreen, 'Refresh', () { setState(() { futureFunction = getPeersList(); isFirstTime = true; }); }, Icons.refresh), ), ], ), ), ) : RefreshIndicator( backgroundColor: ColorSchemeClass.unactivatedblack, onRefresh: () async { await getPeersList(); return 0; }, child: ListView( children: listOfUserTiles, ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/viewAnotherUserScreen.dart
import 'package:coder_status/components/atcoderDialog.dart'; import 'package:coder_status/components/codechefDialog.dart'; import 'package:coder_status/components/codeforcesDialog.dart'; import 'package:coder_status/components/myButtons.dart'; import 'package:coder_status/components/myDividerWithTitle.dart'; import 'package:coder_status/components/spojDialog.dart'; import 'package:coder_status/components/urls.dart'; import 'package:coder_status/components/viewAnotherUserScreenSkeleton.dart'; import 'package:coder_status/screens/editProfileScreen.dart'; import 'package:coder_status/firebase_layer/getUserInfo.dart'; import 'package:coder_status/firebase_layer/setUserInfo.dart'; import 'package:coder_status/functions/getRating.dart'; import 'package:dotted_border/dotted_border.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:coder_status/components/colorscheme.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:coder_status/components/myRatingCard.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:rect_getter/rect_getter.dart'; import '../components/myAppBar.dart'; import '../components/myCircleAvatar.dart'; import 'myDashboardScreen.dart'; //ignore: must_be_immutable class ViewAnotherUserScreen extends StatefulWidget { String uid = ''; ViewAnotherUserScreen(String uid) { this.uid = uid; } @override _ViewAnotherUserScreenState createState() => _ViewAnotherUserScreenState(uid); } class _ViewAnotherUserScreenState extends State<ViewAnotherUserScreen> { String uid = ''; var globalKey1 = RectGetter.createGlobalKey(); var globalKey2 = RectGetter.createGlobalKey(); var globalKey3 = RectGetter.createGlobalKey(); var globalKey4 = RectGetter.createGlobalKey(); String name = 'name', codername = 'codername', avatarurl = Urls.avatar1url, bio = 'Hey there, I love Competitive Programming', myUid = ''; List<String> userhandles = ['', '', '', ''], userrating = ['0', '0', '0', '0']; _ViewAnotherUserScreenState(String uid) { this.uid = uid; } bool isFirstTimeUserData = true; bool isFirstTimeUserRatings = true; bool isPeered = false; bool isMe = false; bool isLoading = false; List<Widget> listOfRatingCards = []; addInPeers() async { setState(() { isLoading = true; }); var peers = await GetUserInfo.getUserPeers(); peers.add(uid); await SetUserInfo.updatePeers(peers); setState(() { isLoading = false; isPeered = true; }); } removeFromPeers() async { setState(() { isLoading = true; }); var peers = await GetUserInfo.getUserPeers(); int k = peers.indexOf(uid); var newPeers = []; for (int i = 0; i < peers.length; i++) { if (i != k) newPeers.add(peers[i]); } await SetUserInfo.updatePeers(newPeers); setState(() { isLoading = false; isPeered = false; }); } readyUserData() async { myUid = GetUserInfo.getUserUid(); final userDocument = await GetUserInfo.getUserDocument(uid); avatarurl = userDocument['avatarurl']; name = userDocument['name']; codername = userDocument['codername']; bio = userDocument['bio']; if (myUid == uid) { isMe = true; } else { var peers = await GetUserInfo.getUserPeers(); if (peers.contains(uid)) { isPeered = true; } else { isPeered = false; } } setState(() { isFirstTimeUserData = false; }); } readyUserRatings() async { final userDocument = await GetUserInfo.getUserDocument(uid); userhandles[0] = userDocument['codeforces']; userhandles[1] = userDocument['codechef']; userhandles[2] = userDocument['atcoder']; userhandles[3] = userDocument['spoj']; if (userhandles[0] != '') { userrating[0] = await GetRating.getCodeforcesRating(userhandles[0]); if (userrating[0] != '0') listOfRatingCards.add(RectGetter( key: globalKey1, child: GestureDetector( onTap: () { var rect = RectGetter.getRectFromKey(globalKey1); showCodeforcesDialog( this.context, rect, userhandles[0], userrating[0]); }, child: MyRatingCard(AssetImage('images/codeforcestile.png'), ColorSchemeClass.codeforcespurple, userrating[0] + ' pts'), ), )); } if (userhandles[1] != '') { userrating[1] = await GetRating.getCodechefRating(userhandles[1]); if (userrating[1] != '0') listOfRatingCards.add(RectGetter( key: globalKey2, child: GestureDetector( onTap: () { var rect = RectGetter.getRectFromKey(globalKey2); showCodechefDialog( this.context, rect, userhandles[1], userrating[1]); }, child: MyRatingCard(AssetImage('images/codecheftile.png'), ColorSchemeClass.codechefbrown, userrating[1] + ' pts'), ), )); } if (userhandles[2] != '') { userrating[2] = await GetRating.getAtcoderRating(userhandles[2]); if (userrating[2] != '0') listOfRatingCards.add(RectGetter( key: globalKey3, child: GestureDetector( onTap: () { var rect = RectGetter.getRectFromKey(globalKey3); showAtcoderDialog( this.context, rect, userhandles[2], userrating[2]); }, child: MyRatingCard(AssetImage('images/atcodertile.png'), ColorSchemeClass.atcodergrey, userrating[2] + ' pts'), ), )); } if (userhandles[3] != '') { userrating[3] = await GetRating.getSpojRating(userhandles[3]); if (userrating[3] != '0') listOfRatingCards.add(RectGetter( key: globalKey4, child: GestureDetector( onTap: () { var rect = RectGetter.getRectFromKey(globalKey4); showSpojDialog(this.context, rect, userhandles[3], userrating[3]); }, child: MyRatingCard(AssetImage('images/spojtile.png'), ColorSchemeClass.spojblue, userrating[3] + ' pts'), ), )); } setState(() { isFirstTimeUserRatings = false; }); } Future futureFunctionUserData; Future futureFunctionUserRatings; @override void initState() { super.initState(); futureFunctionUserData = readyUserData(); futureFunctionUserRatings = readyUserRatings(); } @override Widget build(BuildContext context) { return isFirstTimeUserData ? FutureBuilder( future: futureFunctionUserData, builder: (context, snapshot) { return ViewAnotherUserScreenSkeleton(); }, ) : Scaffold( appBar: PreferredSize( child: MyAppBarWithBack('User'), preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.08), ), body: SafeArea( child: SingleChildScrollView( child: Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.03), child: Column( children: [ Column(children: [ SizedBox( height: MediaQuery.of(context).size.height * 0.03, ), Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.02), height: MediaQuery.of(context).size.height * 0.17, width: MediaQuery.of(context).size.height * 0.17, child: MyCircleAvatar(Image.network(avatarurl))), SizedBox( width: MediaQuery.of(context).size.width * 0.15, ), Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( width: MediaQuery.of(context).size.width * 0.4, child: FittedBox( fit: BoxFit.scaleDown, child: Text( name, style: TextStyle( color: Colors.white, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.03), ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.007, ), Container( width: MediaQuery.of(context).size.width * 0.4, child: FittedBox( fit: BoxFit.scaleDown, child: Text( '@' + codername, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.02), ), ), ), ], ) ], ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), isMe ? MyOutlineButton( ColorSchemeClass.lightgrey, 'Edit Profile', () { Navigator.push(context, MaterialPageRoute(builder: (context) { return EditProfileScreen(); })); }, FontAwesomeIcons.solidEdit) : isLoading ? Container( width: double.infinity, height: MediaQuery.of(context).size.height * 0.078, child: Center( child: CircularProgressIndicator(), ), ) : isPeered ? MyOutlineButton( ColorSchemeClass.lightgrey, 'Remove from Peers', () { removeFromPeers(); }, FontAwesomeIcons.minusCircle) : MyButton(ColorSchemeClass.primarygreen, 'Add as a Peer', () { addInPeers(); }, FontAwesomeIcons.plusCircle), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), MyMidDividerWithTitle('Bio'), SizedBox( height: MediaQuery.of(context).size.height * 0.015, ), Text( bio, textAlign: TextAlign.center, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02), ), SizedBox( height: MediaQuery.of(context).size.height * 0.015, ), MyMidDividerWithTitle('Ratings'), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), isFirstTimeUserRatings ? FutureBuilder( future: futureFunctionUserRatings, builder: (context, snapshot) { return Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: [ RantingTileSkeleton(), RantingTileSkeleton(), ]), Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: [ RantingTileSkeleton(), RantingTileSkeleton(), ]) ], ); }) : listOfRatingCards.length == 0 ? Container( height: MediaQuery.of(context).size.height * 0.3, child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: [ DottedBorder( strokeWidth: 1, dashPattern: [5, 5], color: ColorSchemeClass.lightgrey, child: Container( padding: EdgeInsets.all( MediaQuery.of(context) .size .width * 0.05), child: Text( 'NO RATINGS', textAlign: TextAlign.center, style: TextStyle( color: ColorSchemeClass .lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.02), ), ), ), SizedBox( height: MediaQuery.of(context) .size .height * 0.04, ), Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: [ Text( 'Go to ', style: TextStyle( color: ColorSchemeClass .lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.02), ), Column(children: [ Icon( Icons.settings, color: ColorSchemeClass .primarygreen, size: MediaQuery.of(context) .size .width * 0.08, ), Text( 'Settings', style: TextStyle( color: ColorSchemeClass .primarygreen, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.016), ), ]), Text( ' to add User Handles', style: TextStyle( color: ColorSchemeClass .lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context) .size .height * 0.02), ), ], ), ], ), ) : listOfRatingCards.length == 1 || listOfRatingCards.length == 2 ? Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: listOfRatingCards) ], ) : Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: listOfRatingCards .sublist(0, 2)), Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: listOfRatingCards.sublist(2)) ], ), ]) ], ), ), ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/getStartedScreen.dart
import 'dart:async'; import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/myButtons.dart'; import 'package:coder_status/screens/signInScreen.dart'; import 'package:coder_status/screens/signUpScreen.dart'; import 'package:flutter/material.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import 'package:rive/rive.dart'; import '../components/noInternet.dart'; class GetStartedScreen extends StatefulWidget { const GetStartedScreen({Key key}) : super(key: key); @override _GetStartedScreenState createState() => _GetStartedScreenState(); } class _GetStartedScreenState extends State<GetStartedScreen> { StreamSubscription subscription; @override initState() { super.initState(); subscription = InternetConnectionChecker().onStatusChange.listen((status) { final hasInternet = status == InternetConnectionStatus.connected; if (!hasInternet) noInternet(this.context); }); } @override void dispose() { subscription.cancel(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( body: Stack( children: [ Container( height: double.infinity, width: double.infinity, child: RiveAnimation.asset( 'assets/boy-scene.riv', fit: BoxFit.fitHeight, ), ), Container( height: double.infinity, width: double.infinity, child: Column( mainAxisAlignment: MainAxisAlignment.end, children: [ Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.02), width: double.infinity, color: ColorSchemeClass.dark.withOpacity(0.5), child: Column( children: [ Hero( tag: 'appIcon', child: Image( width: MediaQuery.of(context).size.width * 0.2, image: AssetImage('images/appiconnoback.png'), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Text( 'Spark up the Competition among your Competitive Programming peers', textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontSize: MediaQuery.of(context).size.height * 0.05, fontFamily: 'headline', ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.03, ), MyButton(ColorSchemeClass.primarygreen, 'Get Started', () { Navigator.push(context, MaterialPageRoute(builder: (context) { return SignUpScreen(); })); }), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return SignInScreen(); })); }, child: Text( 'Already have an account? Log in', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02, decoration: TextDecoration.underline), )), ], ), ) ], ), ), ], ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/atcoderRankingScreen.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/myRankingUserTile.dart'; import 'package:coder_status/components/rankingScreenSkeleton.dart'; import 'package:coder_status/firebase_layer/getUserInfo.dart'; import 'package:coder_status/functions/getRating.dart'; import 'package:flutter/material.dart'; import '../components/myAppBar.dart'; import '../components/myButtons.dart'; import '../components/topThreeRankingCard.dart'; class AtcoderRankingScreen extends StatefulWidget { const AtcoderRankingScreen({Key key}) : super(key: key); @override _AtcoderRankingScreenState createState() => _AtcoderRankingScreenState(); } class _AtcoderRankingScreenState extends State<AtcoderRankingScreen> { List<Widget> listOfUserTiles = []; bool isFirstTime = true; var listOfUserData = []; getPeersList() async { //initializing the lists empty listOfUserTiles = []; listOfUserData = []; //getting my own map data var myAvatarurl = await GetUserInfo.getUserAvatarUrl(); var myUserHandles = await GetUserInfo.getUserHandles(); //if I have that handle only then add me to ranking data if (myUserHandles[2] != "") { var myRating = await GetRating.getAtcoderRating(myUserHandles[2]); //if I have rating other than 0 only then add me to ranking data if (myRating != '0') { listOfUserData.add({ 'avatarurl': myAvatarurl, 'userHandle': myUserHandles[2], 'rating': myRating }); } } //getting list of uids of my peers var peers = await GetUserInfo.getUserPeers(); //If I have peers only then proceed if (peers.length > 0) { //loop through all peer uids for (int i = 0; i < peers.length; i++) { //get document map of uid var peerDocument = await GetUserInfo.getUserDocument(peers[i]); //if the peer's document map has user Handle then then add it to ranking data try { if (peerDocument['atcoder'] != '') { //fetch rating for the current peer var rating = await GetRating.getAtcoderRating(peerDocument['atcoder']); //if current peer has rating not equal to zero then add it to ranking data if (rating != '0') { //if initial list is not empty add to ranking data in descending sort if (listOfUserData.length > 0) { for (int j = 0; j < listOfUserData.length; j++) { if (double.parse(listOfUserData[j]['rating']) <= double.parse(rating)) { listOfUserData.insert(j, { 'avatarurl': peerDocument['avatarurl'], 'userHandle': peerDocument['atcoder'], 'rating': rating }); break; } else { if (j == (listOfUserData.length - 1)) { listOfUserData.add({ 'avatarurl': peerDocument['avatarurl'], 'userHandle': peerDocument['atcoder'], 'rating': rating }); break; } } } } else { //since initial list is empty listOfUserData.add({ 'avatarurl': peerDocument['avatarurl'], 'userHandle': peerDocument['atcoder'], 'rating': rating }); } } } } catch (e) { continue; } } //converting ranking data into widgets } if (listOfUserData.length >= 3) { listOfUserTiles.add(TopThreeRankingCard( listOfUserData[0]['avatarurl'], listOfUserData[1]['avatarurl'], listOfUserData[2]['avatarurl'], listOfUserData[0]['userHandle'], listOfUserData[1]['userHandle'], listOfUserData[2]['userHandle'], listOfUserData[0]['rating'], listOfUserData[1]['rating'], listOfUserData[2]['rating'])); for (int j = 3; j < listOfUserData.length; j++) { listOfUserTiles.add(MyRankingUserTile( listOfUserData[j]['avatarurl'], listOfUserData[j]['userHandle'], listOfUserData[j]['rating'], (j + 1))); } } else { for (int j = 0; j < listOfUserData.length; j++) { listOfUserTiles.add(MyRankingUserTile( listOfUserData[j]['avatarurl'], listOfUserData[j]['userHandle'], listOfUserData[j]['rating'], (j + 1))); } } setState(() { isFirstTime = false; }); } Future futureFunction; @override void initState() { super.initState(); futureFunction = getPeersList(); } @override Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( child: MyAppBarWithBack('Atcoder Ranking'), preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.08), ), body: isFirstTime ? FutureBuilder( future: futureFunction, builder: (context, snapshot) { return Center( child: RankingScreenSkeleton(), ); }, ) : listOfUserTiles.length == 0 ? Container( height: MediaQuery.of(context).size.height * 0.7, child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'You and your peers are not on Atcoder', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.025), ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Container( height: MediaQuery.of(context).size.height * 0.05, width: MediaQuery.of(context).size.width * 0.5, child: MyButton( ColorSchemeClass.primarygreen, 'Refresh', () { setState(() { futureFunction = getPeersList(); isFirstTime = true; }); }, Icons.refresh), ) ], ), ), ) : RefreshIndicator( backgroundColor: ColorSchemeClass.unactivatedblack, onRefresh: () async { await getPeersList(); return 0; }, child: ListView( children: listOfUserTiles, ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/editUserHandlesScreen.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/confirmationDialog.dart'; import 'package:coder_status/components/generalLoader.dart'; import 'package:coder_status/components/myTextFormFields.dart'; import 'package:coder_status/firebase_layer/getUserInfo.dart'; import 'package:coder_status/firebase_layer/setUserInfo.dart'; import 'package:flutter/material.dart'; import 'package:flutter_phoenix/flutter_phoenix.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import '../components/myAppBar.dart'; class EditUserHandlesScreen extends StatefulWidget { @override _EditUserHandlesScreenState createState() => _EditUserHandlesScreenState(); } class _EditUserHandlesScreenState extends State<EditUserHandlesScreen> { TextEditingController codeforcesEditingController; TextEditingController codechefEditingController; TextEditingController atcoderEditingController; TextEditingController spojEditingController; final _formkey = GlobalKey<FormState>(); bool isLoading = false; bool isFirstTime = true; readyUserData() async { final userHandles = await GetUserInfo.getUserHandles(); codeforcesEditingController = TextEditingController(text: userHandles[0]); codechefEditingController = TextEditingController(text: userHandles[1]); atcoderEditingController = TextEditingController(text: userHandles[2]); spojEditingController = TextEditingController(text: userHandles[3]); setState(() { isFirstTime = false; }); } void _submit() async { if (_formkey.currentState.validate()) { _formkey.currentState.save(); setState(() { isLoading = true; }); await SetUserInfo.updateHandles( codeforcesEditingController.text.trim(), codechefEditingController.text.trim(), atcoderEditingController.text.trim(), spojEditingController.text.trim()); Phoenix.rebirth(context); } } Future futureFunction; @override void initState() { super.initState(); futureFunction = readyUserData(); } @override Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.08), child: MyAppBarWithBackAndDone('Edit Profile', () { showConfirmationDialog(this.context, 'EDIT USER HANDLES', 'Do you want to save changes to the User Handles?', () { _submit(); }, true, FontAwesomeIcons.thLarge); }), ), backgroundColor: ColorSchemeClass.dark, body: isFirstTime ? FutureBuilder( future: futureFunction, builder: (context, snapshot) { return GeneralLoader(''); }, ) : isLoading ? Center( child: GeneralLoader(''), ) : GestureDetector( onTap: () { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } }, child: Scaffold( backgroundColor: ColorSchemeClass.dark, body: SafeArea( child: Container( width: double.infinity, height: double.infinity, padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.015), child: SingleChildScrollView( child: Form( key: _formkey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( height: MediaQuery.of(context).size.height * 0.1, ), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Text( '*If you don\'t want to add a particular platform you can leave that field empty.', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02), textAlign: TextAlign.center, ), SizedBox( height: MediaQuery.of(context).size.height * 0.02), Container( width: double.infinity, height: MediaQuery.of(context).size.height * 0.1, child: Row( children: [ Image( image: AssetImage( 'images/codeforceswhitelogo.png'), width: MediaQuery.of(context) .size .width * 0.15), Flexible( child: MyTextFormField( Icon(Icons.alternate_email), 'codeforces_handle', false, (val) {}, TextInputType.name, (val) => val .trim() .toString() .contains(' ') ? 'User handle should\'nt contain spaces' : null, codeforcesEditingController), ) ], )), Container( width: double.infinity, height: MediaQuery.of(context).size.height * 0.1, child: Row( children: [ Image( image: AssetImage( 'images/codechefwhitelogo.png'), width: MediaQuery.of(context) .size .width * 0.15), Flexible( child: MyTextFormField( Icon(Icons.alternate_email), 'codechef_handle', false, (val) {}, TextInputType.name, (val) => val .trim() .toString() .contains(' ') ? 'User handle should\'nt contain spaces' : null, codechefEditingController), ) ], )), Container( width: double.infinity, height: MediaQuery.of(context).size.height * 0.1, child: Row( children: [ Image( image: AssetImage( 'images/atcoderwhitelogo.png'), width: MediaQuery.of(context) .size .width * 0.15), Flexible( child: MyTextFormField( Icon(Icons.alternate_email), 'atcoder_handle', false, (val) {}, TextInputType.name, (val) => val .trim() .toString() .contains(' ') ? 'User handle should\'nt contain spaces' : null, atcoderEditingController), ) ], )), Container( width: double.infinity, height: MediaQuery.of(context).size.height * 0.1, child: Row( children: [ Image( image: AssetImage( 'images/spojwhitelogo.png'), width: MediaQuery.of(context) .size .width * 0.15, ), Flexible( child: MyTextFormField( Icon(Icons.alternate_email), 'spoj_handle', false, (val) {}, TextInputType.name, (val) => val .trim() .toString() .contains(' ') ? 'User handle should\'nt contain spaces' : null, spojEditingController), ) ], )), ], ), ), ), ))), )); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/signInScreen.dart
import 'dart:async'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:coder_status/components/generalLoader.dart'; import 'package:coder_status/screens/registerCodernameScreen.dart'; import 'package:coder_status/screens/signInEmailScreen.dart'; import 'package:coder_status/screens/signUpScreen.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import 'package:provider/provider.dart'; import '../components/colorscheme.dart'; import '../components/showAnimatedToast.dart'; import '../firebase_layer/googleSignInProvider.dart'; import '../home.dart'; import '../components/noInternet.dart'; class SignInScreen extends StatefulWidget { @override _SignInScreenState createState() => _SignInScreenState(); } class _SignInScreenState extends State<SignInScreen> { bool isLoading = false; StreamSubscription subscription; @override initState() { super.initState(); subscription = InternetConnectionChecker().onStatusChange.listen((status) { final hasInternet = status == InternetConnectionStatus.connected; if (!hasInternet) noInternet(this.context); }); } @override void dispose() { subscription.cancel(); super.dispose(); } @override Widget build(BuildContext context) { return Stack( children: [ Scaffold( body: SafeArea( child: Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.04), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Flexible( child: Hero( tag: 'appIcon', child: Image( width: MediaQuery.of(context).size.width * 0.5, image: AssetImage('images/appiconnoback.png'), ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.01, ), RichText( text: TextSpan( style: TextStyle( color: Colors.white, fontFamily: 'headline', fontSize: MediaQuery.of(context).size.height * 0.06), children: [ TextSpan( text: 'CODER', ), TextSpan( text: ' STATUS', style: TextStyle( color: ColorSchemeClass.primarygreen)) ]), ), SizedBox( height: MediaQuery.of(context).size.height * 0.1, ), GestureDetector( onTap: () async { final provider = Provider.of<GoogleSigInProvider>(context, listen: false); setState(() { isLoading = true; }); final user = await provider.googleLogin(); if (user == null) { setState(() { isLoading = false; }); showAnimatedToast( this.context, 'Something went wrong', false); } else { bool flag = false; try { await FirebaseFirestore.instance .collection('users') .doc(user.uid) .get() .then((doc) { flag = doc.exists; }); } catch (e) { flag = false; } if (flag) { Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) { return Home(); }), ModalRoute.withName('/home')); } else { Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) { return Registercodernamescreen( user.displayName.toString().trim()); }), ModalRoute.withName('/registerCodername')); } } }, child: Container( width: double.infinity, height: MediaQuery.of(context).size.height * 0.07, padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.15, vertical: MediaQuery.of(context).size.width * 0.01), decoration: BoxDecoration( color: ColorSchemeClass.dangerred, borderRadius: BorderRadius.circular(5)), child: FittedBox( fit: BoxFit.scaleDown, child: Row( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ FaIcon( FontAwesomeIcons.google, color: Colors.white, ), SizedBox( width: MediaQuery.of(context).size.width * 0.08, ), Text( 'Sign In With Google', style: TextStyle( color: Colors.white, fontSize: MediaQuery.of(context).size.width * 0.055, fontFamily: 'young', fontWeight: FontWeight.bold), ) ], ), ), ), ), SizedBox( height: MediaQuery.of(context).size.width * 0.055, ), GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return SignInEmailScreen(); })); }, child: Container( width: double.infinity, height: MediaQuery.of(context).size.height * 0.07, padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.15, vertical: MediaQuery.of(context).size.width * 0.01), decoration: BoxDecoration( color: ColorSchemeClass.primarygreen, borderRadius: BorderRadius.circular(5)), child: FittedBox( fit: BoxFit.scaleDown, child: Row( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ FaIcon( FontAwesomeIcons.solidEnvelope, color: Colors.white, ), SizedBox( width: MediaQuery.of(context).size.width * 0.08, ), Text( 'Sign In With Email', style: TextStyle( color: Colors.white, fontSize: MediaQuery.of(context).size.width * 0.055, fontFamily: 'young', fontWeight: FontWeight.bold), ), ], ), ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.06, ), Flexible( child: GestureDetector( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return SignUpScreen(); })); }, child: Text( 'Don\'t Have An Account?Create Account', style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.02, decoration: TextDecoration.underline), )), ), ], ), ), ), ), isLoading ? GeneralLoaderTransparent('') : SizedBox.shrink() ], ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/editProfileScreen.dart
import 'dart:io'; import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/generalLoader.dart'; import 'package:coder_status/components/myAvatarSelection.dart'; import 'package:coder_status/components/myCircleAvatar.dart'; import 'package:coder_status/components/myDividerWithTitle.dart'; import 'package:coder_status/components/urls.dart'; import 'package:coder_status/firebase_layer/getUserInfo.dart'; import 'package:coder_status/firebase_layer/setUserInfo.dart'; import 'package:coder_status/firebase_layer/uploadAvatar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_phoenix/flutter_phoenix.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import '../components/confirmationDialog.dart'; import '../components/myAppBar.dart'; import '../components/myTextFormFields.dart'; import '../functions/pickImageAndCrop.dart' as pickImageAndCrop; class EditProfileScreen extends StatefulWidget { const EditProfileScreen({Key key}) : super(key: key); @override _EditProfileScreenState createState() => _EditProfileScreenState(); } class _EditProfileScreenState extends State<EditProfileScreen> { String urltobeset = Urls.avatar1url; Image avatarshowimage = Image(image: NetworkImage(Urls.avatar1url)); TextEditingController nameEditingController; TextEditingController codernameEditingController; TextEditingController bioEditingController; File imagetobeuploaded; bool isLoading = false; bool isFirstTime = true; readyUserData() async { urltobeset = await GetUserInfo.getUserAvatarUrl(); avatarshowimage = Image( image: NetworkImage(urltobeset), ); final name = await GetUserInfo.getUserName(); nameEditingController = TextEditingController(text: name); final codername = await GetUserInfo.getUserCoderName(); codernameEditingController = TextEditingController(text: codername); final bio = await GetUserInfo.getUserBio(); bioEditingController = TextEditingController(text: bio); setState(() { isFirstTime = false; }); } Future<String> generateUrl(File imagefile) async { final url = await UploadUserAvatar.uploadUserAvatar(imagefile); return url; } pick() async { urltobeset = null; final pickedfile = await pickImageAndCrop.pickimage(); imagetobeuploaded = pickedfile; setState(() { avatarshowimage = Image.file(pickedfile); }); return; } List<bool> _selections = [ false, true, false, false, false, false, false, false ]; List<Widget> _avatarbuttons = [ MyAvatarSelection(Image(image: AssetImage('images/avatar0.jpg')), false), MyAvatarSelection(Image(image: AssetImage('images/avatar1.jpg')), true), MyAvatarSelection(Image(image: AssetImage('images/avatar2.jpg')), false), MyAvatarSelection(Image(image: AssetImage('images/avatar3.jpg')), false), MyAvatarSelection(Image(image: AssetImage('images/avatar4.jpg')), false), MyAvatarSelection(Image(image: AssetImage('images/avatar5.jpg')), false), MyAvatarSelection(Image(image: AssetImage('images/avatar6.jpg')), false), MyAvatarSelection(Image(image: AssetImage('images/avatar7.jpg')), false), ]; final _formkey = GlobalKey<FormState>(); _updateProfile() async { if (_formkey.currentState.validate()) { _formkey.currentState.save(); setState(() { isLoading = true; }); if (imagetobeuploaded != null) { urltobeset = await generateUrl(imagetobeuploaded); } await SetUserInfo.updateAvatar(urltobeset); await SetUserInfo.updateName(nameEditingController.text.trim()); await SetUserInfo.updateCodername(codernameEditingController.text.trim()); await SetUserInfo.updateBio(bioEditingController.text.trim()); Phoenix.rebirth(context); } } Future futureFunction; @override void initState() { super.initState(); futureFunction = readyUserData(); } @override Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.08), child: MyAppBarWithBackAndDone('Edit Profile', () { showConfirmationDialog(this.context, 'EDIT PROFILE', 'Do you want to save changes to the User Handles?', () { _updateProfile(); }, true, FontAwesomeIcons.solidEdit); }), ), backgroundColor: ColorSchemeClass.dark, body: isFirstTime ? FutureBuilder( future: futureFunction, builder: (context, snapshot) { return GeneralLoader(''); }, ) : isLoading ? GeneralLoader('') : GestureDetector( onTap: () { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } }, child: SafeArea( child: Padding( padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.04, ), child: SingleChildScrollView( child: Container( child: Form( key: _formkey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), MyDividerWithTitle('Avatar'), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Container( height: MediaQuery.of(context).size.height * 0.27, width: MediaQuery.of(context).size.height * 0.27, child: MyCircleAvatar(avatarshowimage)), SizedBox( height: MediaQuery.of(context).size.height * 0.028), SingleChildScrollView( scrollDirection: Axis.horizontal, child: ToggleButtons( isSelected: _selections, children: _avatarbuttons, onPressed: (int index) { setState(() { for (int i = 0; i < 8; i++) { _selections[i] = false; } _avatarbuttons[0] = MyAvatarSelection( Image( image: AssetImage( 'images/avatar0.jpg')), false); _avatarbuttons[1] = MyAvatarSelection( Image( image: AssetImage( 'images/avatar1.jpg')), false); _avatarbuttons[2] = MyAvatarSelection( Image( image: AssetImage( 'images/avatar2.jpg')), false); _avatarbuttons[3] = MyAvatarSelection( Image( image: AssetImage( 'images/avatar3.jpg')), false); _avatarbuttons[4] = MyAvatarSelection( Image( image: AssetImage( 'images/avatar4.jpg')), false); _avatarbuttons[5] = MyAvatarSelection( Image( image: AssetImage( 'images/avatar5.jpg')), false); _avatarbuttons[6] = MyAvatarSelection( Image( image: AssetImage( 'images/avatar6.jpg')), false); _avatarbuttons[7] = MyAvatarSelection( Image( image: AssetImage( 'images/avatar7.jpg')), false); _selections[index] = true; if (index > 0) { imagetobeuploaded = null; switch (index) { case 1: { urltobeset = Urls.avatar1url; } break; case 2: { urltobeset = Urls.avatar2url; } break; case 3: { urltobeset = Urls.avatar3url; } break; case 4: { urltobeset = Urls.avatar4url; } break; case 5: { urltobeset = Urls.avatar5url; } break; case 6: { urltobeset = Urls.avatar6url; } break; case 7: { urltobeset = Urls.avatar7url; } break; } avatarshowimage = Image( image: AssetImage( 'images/avatar$index.jpg'), ); } else { pick(); } _avatarbuttons[index] = MyAvatarSelection( Image( image: AssetImage( 'images/avatar$index.jpg')), true); }); }, renderBorder: false, fillColor: Colors.transparent, ), ), Divider( color: ColorSchemeClass.darkgrey, ), SizedBox( height: MediaQuery.of(context).size.height * 0.028), MyDividerWithTitle('Name'), SizedBox( height: MediaQuery.of(context).size.height * 0.028), MyTextFormField( Icon(Icons.person), 'Name', false, (val) {}, TextInputType.name, (val) => val.toString().trim().length < 5 ? 'Name is too short' : null, nameEditingController), SizedBox( height: MediaQuery.of(context).size.height * 0.028), Divider( color: ColorSchemeClass.darkgrey, ), SizedBox( height: MediaQuery.of(context).size.height * 0.028), MyDividerWithTitle('Codername'), SizedBox( height: MediaQuery.of(context).size.height * 0.028), MyTextFormField( Icon(Icons.alternate_email), 'Codername', false, (val) {}, TextInputType.name, (val) => (val .toString() .trim() .contains(' ') || val.toString().trim().length < 4) ? 'Codername can only be consist a single word' : null, codernameEditingController), SizedBox( height: MediaQuery.of(context).size.height * 0.028), Divider( color: ColorSchemeClass.darkgrey, ), SizedBox( height: MediaQuery.of(context).size.height * 0.028), MyDividerWithTitle('Bio'), SizedBox( height: MediaQuery.of(context).size.height * 0.028), MyPassageTextEormField( 'Bio', (val) {}, (val) => val.toString().trim().length > 100 ? 'Bio should be less than 100 charachters' : null, bioEditingController), SizedBox( height: MediaQuery.of(context).size.height * 0.028), Divider( color: ColorSchemeClass.darkgrey, ), SizedBox( height: MediaQuery.of(context).size.height * 0.02), ], ), ), ), ), ), ), )); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/verifyEmailScreen.dart
import 'dart:async'; import 'package:argon_buttons_flutter/argon_buttons_flutter.dart'; import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/firebase_layer/emailVerification.dart'; import 'package:coder_status/firebase_layer/getUserInfo.dart'; import 'package:coder_status/screens/registerNameScreen.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import '../components/noInternet.dart'; void main() { runApp(MaterialApp( home: VerifyEmailScreen(), )); } class VerifyEmailScreen extends StatefulWidget { @override _VerifyEmailScreenState createState() => _VerifyEmailScreenState(); } class _VerifyEmailScreenState extends State<VerifyEmailScreen> { Timer timer; StreamSubscription subscription; @override void dispose() { subscription.cancel(); super.dispose(); } void _submit() async { await sendVerificationEmail(GetUserInfo.getUserEmail()); } @override void initState() { subscription = InternetConnectionChecker().onStatusChange.listen((status) { final hasInternet = status == InternetConnectionStatus.connected; if (!hasInternet) noInternet(this.context); }); timer = Timer.periodic(Duration(seconds: 3), (timer) async { final flag = await checkEmailVerified(); if (flag) { timer.cancel(); Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) { return Registernamescreen(); }), ModalRoute.withName('/registerName')); } }); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: ColorSchemeClass.dark, body: SafeArea( child: Container( padding: EdgeInsets.all(16), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Flexible( child: Hero( tag: 'splashscreenImage', child: Image( width: 300, image: AssetImage('images/appiconnoback.png'), ), ), ), Flexible( child: SizedBox( height: MediaQuery.of(context).size.height * 0.025, ), ), Flexible( child: Text('Check your inbox for the verification Email', style: TextStyle( color: ColorSchemeClass.lightgrey, fontSize: MediaQuery.of(context).size.height * 0.028, fontFamily: 'young'), textAlign: TextAlign.center)), SizedBox( height: MediaQuery.of(context).size.height * 0.1, ), CircularProgressIndicator(), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Flexible( child: Text('Waiting for email to be verified', style: TextStyle( color: ColorSchemeClass.darkgrey, fontSize: MediaQuery.of(context).size.height * 0.022, fontFamily: 'young'), textAlign: TextAlign.center)), SizedBox( height: MediaQuery.of(context).size.height * 0.04, ), ArgonTimerButton( initialTimer: 90, // Optional height: 50, width: MediaQuery.of(context).size.width * 0.7, minWidth: MediaQuery.of(context).size.width * 0.7, color: Colors.transparent, borderSide: BorderSide(color: ColorSchemeClass.lightgrey, width: 2), borderRadius: 5.0, child: Text( 'Resend Verification Email', textAlign: TextAlign.center, style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.025), ), loader: (timeLeft) { return Text( "Resend Verification Email | $timeLeft", style: TextStyle( color: ColorSchemeClass.lightgrey, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.025, ), ); }, onTap: (startTimer, btnState) { if (btnState == ButtonState.Idle) { startTimer(90); _submit(); } }, ) ], ), ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/aboutDeveloperScreen.dart
import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/myAppBar.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:flutter/services.dart'; class AboutDeveloperScreen extends StatefulWidget { @override _AboutDeveloperScreenState createState() => _AboutDeveloperScreenState(); } class _AboutDeveloperScreenState extends State<AboutDeveloperScreen> { @override Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.08), child: MyAppBarWithBack('About Developer'), ), body: Container( width: double.infinity, height: double.infinity, padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.04), child: Column( children: [ CircleAvatar( backgroundImage: AssetImage('images/MyAvatar.jpg'), radius: MediaQuery.of(context).size.height * 0.1, ), SizedBox( height: MediaQuery.of(context).size.height * 0.03, ), RichText( textAlign: TextAlign.center, text: TextSpan( style: TextStyle( fontFamily: 'young', color: ColorSchemeClass.lightgrey, fontSize: MediaQuery.of(context).size.height * 0.03), children: [ TextSpan(text: 'Hey there, I\'m'), TextSpan( text: '\nYuvraj Singh', style: TextStyle( color: ColorSchemeClass.primarygreen, fontFamily: 'headline', fontSize: MediaQuery.of(context).size.height * 0.05)), TextSpan( text: '\n\nI\'m a Flutter Developer, a newbie\nat Competitive Programming\nand I also draw vector Illustrations as a hobby', style: TextStyle( color: ColorSchemeClass.lightgrey.withOpacity(0.8), fontSize: MediaQuery.of(context).size.height * 0.018)), ])), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.02), width: double.infinity, decoration: BoxDecoration( color: ColorSchemeClass.unactivatedblack, borderRadius: BorderRadius.circular(20)), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.link, color: ColorSchemeClass.primarygreen, ), SizedBox( width: MediaQuery.of(context).size.width * 0.02, ), Text( 'Connect With Me', style: TextStyle( fontFamily: 'young', fontWeight: FontWeight.bold, color: ColorSchemeClass.primarygreen, fontSize: MediaQuery.of(context).size.height * 0.03), ), ], ), SizedBox( height: MediaQuery.of(context).size.height * 0.04, ), Container( width: MediaQuery.of(context).size.height * 0.25, height: MediaQuery.of(context).size.height * 0.15, child: GridView.count( crossAxisSpacing: MediaQuery.of(context).size.height * 0.05, mainAxisSpacing: MediaQuery.of(context).size.height * 0.03, crossAxisCount: 3, children: [ GestureDetector( onTap: () async { const url = 'https://github.com/curiousyuvi'; await launch(url); }, child: Container( width: MediaQuery.of(context).size.height * 0.07, height: MediaQuery.of(context).size.height * 0.07, child: FittedBox( fit: BoxFit.contain, child: FaIcon( FontAwesomeIcons.github, color: ColorSchemeClass.primarygreen, size: MediaQuery.of(context).size.height * 0.043, ), )), ), GestureDetector( onTap: () async { const url = 'https://www.instagram.com/curiousyuvi/'; await launch(url); }, child: Container( width: MediaQuery.of(context).size.height * 0.07, height: MediaQuery.of(context).size.height * 0.07, child: FittedBox( fit: BoxFit.contain, child: FaIcon( FontAwesomeIcons.instagram, color: ColorSchemeClass.primarygreen, size: MediaQuery.of(context).size.height * 0.043, ), )), ), GestureDetector( onTap: () async { const url = 'https://www.linkedin.com/in/yuvraj-singh-b85ab71b9/'; await launch(url); }, child: Container( width: MediaQuery.of(context).size.height * 0.07, height: MediaQuery.of(context).size.height * 0.07, child: FittedBox( fit: BoxFit.contain, child: FaIcon( FontAwesomeIcons.linkedin, color: ColorSchemeClass.primarygreen, size: MediaQuery.of(context).size.height * 0.043, ), )), ), GestureDetector( onTap: () async { const url = 'https://twitter.com/curiousyuvi007'; await launch(url); }, child: Container( width: MediaQuery.of(context).size.height * 0.07, height: MediaQuery.of(context).size.height * 0.07, child: FittedBox( fit: BoxFit.contain, child: FaIcon( FontAwesomeIcons.twitter, color: ColorSchemeClass.primarygreen, size: MediaQuery.of(context).size.height * 0.043, ), )), ), GestureDetector( onTap: () async { const url = 'https://www.facebook.com/profile.php?id=100067497900821'; await launch(url); }, child: Container( width: MediaQuery.of(context).size.height * 0.07, height: MediaQuery.of(context).size.height * 0.07, child: FittedBox( fit: BoxFit.contain, child: FaIcon( FontAwesomeIcons.facebook, color: ColorSchemeClass.primarygreen, size: MediaQuery.of(context).size.height * 0.043, ), )), ), GestureDetector( onTap: () { Clipboard.setData( ClipboardData(text: '[email protected]')); ScaffoldMessenger.of(context).showSnackBar(SnackBar( backgroundColor: ColorSchemeClass.primarygreen, content: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( FontAwesomeIcons.check, color: Colors.white, ), SizedBox( width: MediaQuery.of(context).size.width * 0.04, ), Text( 'Email copied to clipboard', textAlign: TextAlign.center, style: TextStyle( fontFamily: 'young', fontWeight: FontWeight.bold, color: Colors.white, fontSize: MediaQuery.of(context) .size .height * 0.025), ), ], ))); }, child: Container( width: MediaQuery.of(context).size.height * 0.07, height: MediaQuery.of(context).size.height * 0.07, child: FittedBox( fit: BoxFit.contain, child: Icon( Icons.mail, color: ColorSchemeClass.primarygreen, size: MediaQuery.of(context).size.height * 0.043, ), )), ), ], ), ) ], ), ) ], ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/registerAvatarScreen.dart
import 'dart:async'; import 'dart:io'; import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/urls.dart'; import 'package:coder_status/firebase_layer/uploadAvatar.dart'; import 'package:coder_status/screens/registerBioScreen.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import '../components/generalLoader.dart'; import '../components/myAvatarSelection.dart'; import '../components/myButtons.dart'; import '../functions/pickImageAndCrop.dart' as pickImageAndCrop; import '../components/myCircleAvatar.dart'; import '../components/noInternet.dart'; class Registeravatarscreen extends StatefulWidget { Registeravatarscreen(String name, String codername) { _RegisteravatarscreenState.name = name; _RegisteravatarscreenState.codername = codername; } @override _RegisteravatarscreenState createState() => _RegisteravatarscreenState(); } class _RegisteravatarscreenState extends State<Registeravatarscreen> { static String name = ''; static String codername = ''; Image avatarshowimage = Image(image: NetworkImage(Urls.avatar1url)); File imagetobeuploaded; String urltobeset = Urls.avatar1url; bool isLoading = false; StreamSubscription subscription; @override initState() { super.initState(); subscription = InternetConnectionChecker().onStatusChange.listen((status) { final hasInternet = status == InternetConnectionStatus.connected; if (!hasInternet) noInternet(this.context); }); if (FirebaseAuth.instance.currentUser.photoURL != null) { urltobeset = FirebaseAuth.instance.currentUser.photoURL; avatarshowimage = Image(image: NetworkImage(urltobeset)); } } @override void dispose() { subscription.cancel(); super.dispose(); } Future<String> generateUrl(File imagefile) async { final url = await UploadUserAvatar.uploadUserAvatar(imagefile); return url; } pick() async { urltobeset = null; final pickedfile = await pickImageAndCrop.pickimage(); imagetobeuploaded = pickedfile; setState(() { avatarshowimage = Image.file(pickedfile); }); return; } List<bool> _selections = [ false, true, false, false, false, false, false, false ]; List<Widget> _avatarbuttons = [ MyAvatarSelection(Image(image: AssetImage('images/avatar0.jpg')), false), MyAvatarSelection(Image(image: AssetImage('images/avatar1.jpg')), true), MyAvatarSelection(Image(image: AssetImage('images/avatar2.jpg')), false), MyAvatarSelection(Image(image: AssetImage('images/avatar3.jpg')), false), MyAvatarSelection(Image(image: AssetImage('images/avatar4.jpg')), false), MyAvatarSelection(Image(image: AssetImage('images/avatar5.jpg')), false), MyAvatarSelection(Image(image: AssetImage('images/avatar6.jpg')), false), MyAvatarSelection(Image(image: AssetImage('images/avatar7.jpg')), false), ]; @override Widget build(BuildContext context) { return isLoading ? Scaffold( body: GeneralLoader(''), ) : Scaffold( body: Center( child: SafeArea( child: Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.02), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ Flexible( child: Padding( padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.04), child: Image( image: AssetImage('images/appiconnoback.png'), height: MediaQuery.of(context).size.height * 0.08, ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.028), Flexible( child: Text( 'Select an Avatar', style: TextStyle( color: Colors.white, fontFamily: 'young', fontSize: MediaQuery.of(context).size.height * 0.035), )), SizedBox( height: MediaQuery.of(context).size.height * 0.028), Container( height: MediaQuery.of(context).size.height * 0.27, width: MediaQuery.of(context).size.height * 0.27, child: MyCircleAvatar(avatarshowimage)), SizedBox( height: MediaQuery.of(context).size.height * 0.028), Flexible( child: SingleChildScrollView( scrollDirection: Axis.horizontal, child: ToggleButtons( isSelected: _selections, children: _avatarbuttons, onPressed: (int index) { setState(() { for (int i = 0; i < 8; i++) { _selections[i] = false; } _avatarbuttons[0] = MyAvatarSelection( Image( image: AssetImage('images/avatar0.jpg')), false); _avatarbuttons[1] = MyAvatarSelection( Image( image: AssetImage('images/avatar1.jpg')), false); _avatarbuttons[2] = MyAvatarSelection( Image( image: AssetImage('images/avatar2.jpg')), false); _avatarbuttons[3] = MyAvatarSelection( Image( image: AssetImage('images/avatar3.jpg')), false); _avatarbuttons[4] = MyAvatarSelection( Image( image: AssetImage('images/avatar4.jpg')), false); _avatarbuttons[5] = MyAvatarSelection( Image( image: AssetImage('images/avatar5.jpg')), false); _avatarbuttons[6] = MyAvatarSelection( Image( image: AssetImage('images/avatar6.jpg')), false); _avatarbuttons[7] = MyAvatarSelection( Image( image: AssetImage('images/avatar7.jpg')), false); _selections[index] = true; if (index > 0) { imagetobeuploaded = null; switch (index) { case 1: { urltobeset = Urls.avatar1url; } break; case 2: { urltobeset = Urls.avatar2url; } break; case 3: { urltobeset = Urls.avatar3url; } break; case 4: { urltobeset = Urls.avatar4url; } break; case 5: { urltobeset = Urls.avatar5url; } break; case 6: { urltobeset = Urls.avatar6url; } break; case 7: { urltobeset = Urls.avatar7url; } break; } avatarshowimage = Image( image: AssetImage('images/avatar$index.jpg'), ); } else { pick(); } _avatarbuttons[index] = MyAvatarSelection( Image( image: AssetImage( 'images/avatar$index.jpg')), true); }); }, renderBorder: false, fillColor: Colors.transparent, ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.042, ), Flexible( child: Row( children: [ Flexible( child: Container( child: MyOutlineButton( ColorSchemeClass.lightgrey, 'Skip', () { urltobeset = FirebaseAuth .instance.currentUser.photoURL == null ? Urls.avatar1url : FirebaseAuth.instance.currentUser.photoURL; Navigator.push(context, MaterialPageRoute(builder: (context) { return Registerbioscreen( name, codername, urltobeset); })); }), )), Flexible( child: Container( child: MyButton( ColorSchemeClass.primarygreen, 'Add Avatar', () async { if (imagetobeuploaded != null) { setState(() { isLoading = true; }); urltobeset = await generateUrl(imagetobeuploaded); setState(() { isLoading = false; }); Navigator.push(context, MaterialPageRoute(builder: (context) { return Registerbioscreen( name, codername, urltobeset); })); } else { Navigator.push(context, MaterialPageRoute(builder: (context) { return Registerbioscreen( name, codername, urltobeset); })); } }), )) ], )) ], ), ), ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/forgotPasswordscreen.dart
import 'dart:async'; import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/showAnimatedToast.dart'; import 'package:coder_status/firebase_layer/resetPassword.dart'; import 'package:coder_status/screens/signInEmailScreen.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import '../components/myTextFormFields.dart'; import '../components/myButtons.dart'; import '../components/noInternet.dart'; void main() => runApp( MaterialApp( home: Forgotpasswordscreen(), ), ); class Forgotpasswordscreen extends StatefulWidget { const Forgotpasswordscreen({Key key}) : super(key: key); @override _ForgotpasswordscreenState createState() => _ForgotpasswordscreenState(); } class _ForgotpasswordscreenState extends State<Forgotpasswordscreen> { //Form State final _formkey = GlobalKey<FormState>(); String emailid = ''; StreamSubscription subscription; @override initState() { super.initState(); subscription = InternetConnectionChecker().onStatusChange.listen((status) { final hasInternet = status == InternetConnectionStatus.connected; if (!hasInternet) noInternet(this.context); }); } @override void dispose() { subscription.cancel(); super.dispose(); } void _submit() { if (_formkey.currentState.validate()) { _formkey.currentState.save(); resetpassword(emailid); showAnimatedToast(this.context, 'A paaswod reset link was succesfully sent to your email.', true); Navigator.push(context, MaterialPageRoute(builder: (context) { return SignInEmailScreen(); })); } } @override Widget build(BuildContext context) { return GestureDetector( onTap: () { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } }, child: Scaffold( backgroundColor: ColorSchemeClass.dark, body: SafeArea( child: Container( padding: EdgeInsets.all(16), child: Form( key: _formkey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Flexible( child: Hero( tag: 'splashscreenImage', child: Image( image: AssetImage('images/appiconnoback.png'), ), ), ), SizedBox( height: 50, ), Flexible( child: Text( 'Enter Email Id', style: TextStyle( color: Colors.white, fontSize: 25, fontFamily: 'young'), )), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Flexible( child: Text( 'A passowrd reset link will be sent to your given Email', style: TextStyle( color: ColorSchemeClass.darkgrey, fontSize: 15, fontFamily: 'young'), textAlign: TextAlign.center)), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), MyTextFormField(Icon(Icons.email), 'Email Id', false, (val) { emailid = val; }, TextInputType.emailAddress, (val) => !val.contains('@') ? 'Please enter a valid email' : null), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), MyButton( ColorSchemeClass.primarygreen, 'Send Request', _submit), ], ), ), ), ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/registerPasswordScreen.dart
import 'dart:async'; import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/components/showAnimatedToast.dart'; import 'package:coder_status/firebase_layer/emailVerification.dart'; import 'package:coder_status/screens/signInEmailScreen.dart'; import 'package:coder_status/screens/verifyEmailScreen.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import '../components/generalLoader.dart'; import '../components/myTextFormFields.dart'; import '../components/myButtons.dart'; import 'package:coder_status/firebase_layer/createuser.dart'; import '../components/noInternet.dart'; void main() => runApp( MaterialApp( home: RegisterPasswordScreen('example@email'), ), ); class RegisterPasswordScreen extends StatefulWidget { RegisterPasswordScreen(String emailid) { _RegisterPasswordScreenState.emailid = emailid; } @override _RegisterPasswordScreenState createState() => _RegisterPasswordScreenState(); } class _RegisterPasswordScreenState extends State<RegisterPasswordScreen> { static String emailid = ''; String password = ''; bool isloading = false; StreamSubscription subscription; @override initState() { super.initState(); subscription = InternetConnectionChecker().onStatusChange.listen((status) { final hasInternet = status == InternetConnectionStatus.connected; if (!hasInternet) noInternet(this.context); }); } @override void dispose() { subscription.cancel(); super.dispose(); } final _formkey = GlobalKey<FormState>(); void _submit() { if (_formkey.currentState.validate()) { _formkey.currentState.save(); setState(() { isloading = true; }); createAccount(emailid, password).then((user) { if (user != null) { sendVerificationEmail(emailid); showAnimatedToast( this.context, 'Verification mail sent to your Email', true); Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) { return VerifyEmailScreen(); }), ModalRoute.withName('/emailVerify')); } else { setState(() { isloading = false; }); showAnimatedToast( this.context, 'Email already exists, head to sign in', false); Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) { return SignInEmailScreen(); }), ModalRoute.withName('/signin')); } }); } } @override Widget build(BuildContext context) { return isloading ? Scaffold( body: GeneralLoader(''), ) : GestureDetector( onTap: () { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } }, child: Scaffold( backgroundColor: ColorSchemeClass.dark, body: SafeArea( child: Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.01), child: Form( key: _formkey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ MediaQuery.of(context).viewInsets.bottom == 0 ? Flexible( child: Hero( tag: 'appIcon', child: Image( width: MediaQuery.of(context).size.width * 0.5, image: AssetImage('images/appiconnoback.png'), ), ), ) : SizedBox.shrink(), SizedBox( height: MediaQuery.of(context).size.height * 0.05, ), MediaQuery.of(context).viewInsets.bottom == 0 ? Flexible( child: Padding( padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.02), child: Text( 'Choose Password', style: TextStyle( color: Colors.white, fontSize: MediaQuery.of(context).size.height * 0.035, fontFamily: 'young'), ), )) : SizedBox.shrink(), Flexible( child: Padding( padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.02), child: Text( 'Use a combination of letters, digits and special characters', style: TextStyle( color: ColorSchemeClass.darkgrey, fontSize: MediaQuery.of(context).size.height * 0.02, fontFamily: 'young'), textAlign: TextAlign.center), )), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), MyTextFormField( Icon(FontAwesomeIcons.key), 'password', true, (val) { setState(() { password = val; }); }, TextInputType.visiblePassword, (val) => val.trim().length < 6 ? 'Password must contain atleast 6 characters' : null), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), MyTextFormField( Icon(FontAwesomeIcons.key), 'confirm password', true, (val) {}, TextInputType.visiblePassword, (val) => val != password ? 'Password doesn\'t match' : null), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Container( padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.03, vertical: MediaQuery.of(context).size.height * 0.01), height: MediaQuery.of(context).size.height * 0.09, child: MyButton( ColorSchemeClass.primarygreen, 'Next', _submit), ), ], ), ), ), ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/screens/registerNameScreen.dart
import 'dart:async'; import 'package:coder_status/components/colorscheme.dart'; import 'package:coder_status/screens/registerCodernameScreen.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import '../components/myTextFormFields.dart'; import '../components/myButtons.dart'; import '../components/noInternet.dart'; void main() => runApp( MaterialApp( home: Registernamescreen(), ), ); class Registernamescreen extends StatefulWidget { const Registernamescreen({Key key}) : super(key: key); @override _RegisternamescreenState createState() => _RegisternamescreenState(); } class _RegisternamescreenState extends State<Registernamescreen> { static String name = ''; final _formkey = GlobalKey<FormState>(); StreamSubscription subscription; @override initState() { super.initState(); subscription = InternetConnectionChecker().onStatusChange.listen((status) { final hasInternet = status == InternetConnectionStatus.connected; if (!hasInternet) noInternet(this.context); }); } @override void dispose() { subscription.cancel(); super.dispose(); } void _submit() { if (_formkey.currentState.validate()) { _formkey.currentState.save(); Navigator.push(context, MaterialPageRoute(builder: (context) { return Registercodernamescreen(name); })); } } @override Widget build(BuildContext context) { return GestureDetector( onTap: () { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } }, child: Scaffold( backgroundColor: ColorSchemeClass.dark, body: SafeArea( child: Container( padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.04), child: Form( key: _formkey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Flexible( child: Hero( tag: 'appIcon', child: Image( width: MediaQuery.of(context).size.width * 0.45, image: AssetImage('images/appiconnoback.png'), ), ), ), SizedBox( height: MediaQuery.of(context).size.height * 0.05, ), Flexible( child: Padding( padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.02), child: Text( 'Enter Your Full Name', style: TextStyle( color: Colors.white, fontSize: MediaQuery.of(context).size.height * 0.033, fontFamily: 'young'), ), )), Flexible( child: Padding( padding: EdgeInsets.all( MediaQuery.of(context).size.width * 0.02), child: Text( '*Example: Light Yagami', style: TextStyle( color: ColorSchemeClass.darkgrey, fontSize: MediaQuery.of(context).size.height * 0.023, fontFamily: 'young'), textAlign: TextAlign.center, ), )), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), MyTextFormField( Icon(FontAwesomeIcons.solidUser), 'Full Name', false, (val) { name = val.toString().trim(); }, TextInputType.name, (val) => val.toString().trim().length < 5 ? 'Name is too short' : null), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), Container( padding: EdgeInsets.symmetric( horizontal: MediaQuery.of(context).size.width * 0.03, vertical: MediaQuery.of(context).size.height * 0.01), height: MediaQuery.of(context).size.height * 0.09, child: MyButton( ColorSchemeClass.primarygreen, 'Next', _submit), ), ], ), ), ), ), ), ); } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/functions/getRating.dart
import 'package:html/parser.dart' as parser; import 'package:http/http.dart' as http; //***************************************************************************/ //*********************WEB SCRAPING******************************/ //***************************************************************************/ class GetRating { static Future<String> getCodeforcesRating(String userhandle) async { if (userhandle == '') return '0'; final response = await http.Client() .get(Uri.parse('https://codeforces.com/profile/$userhandle')); if (response.statusCode == 200) { var document = parser.parse(response.body); try { var rating = document .getElementsByClassName('info')[0] .children[1] .children[0] .children[1]; return rating.text.trim(); } catch (e) { return '0'; } } else { return '0'; } } static Future<String> getCodechefRating(String userhandle) async { if (userhandle == '') return '0'; final response = await http.Client() .get(Uri.parse('https://www.codechef.com/users/$userhandle')); if (response.statusCode == 200) { var document = parser.parse(response.body); try { var rating = document .getElementsByClassName('rating-header text-center')[0] .children[0]; return rating.text.trim(); } catch (e) { return '0'; } } else { return '0'; } } static Future<String> getAtcoderRating(String userhandle) async { if (userhandle == '') return '0'; final response = await http.Client() .get(Uri.parse('https://atcoder.jp/users/$userhandle')); if (response.statusCode == 200) { var document = parser.parse(response.body); try { var ratingElement = document .getElementsByClassName('col-md-9 col-sm-12')[0] .children[2] .children[0] .children[1] .children[1]; final rating = ratingElement.text.trim(); if (rating.contains('Provisional')) { return rating.substring(0, 5).trim(); } return rating; } catch (e) { return '0'; } } else { return '0'; } } static Future<String> getSpojRating(String userhandle) async { if (userhandle == '') return '0'; final response = await http.Client() .get(Uri.parse('https://www.spoj.com/users/$userhandle/')); if (response.statusCode == 200) { var document = parser.parse(response.body); try { var rating = document.getElementsByClassName('col-md-3')[0].children[5]; String temp = rating.text.trim(); int s = temp.indexOf('(') + 1; int l = temp.length - 8; return temp.substring(s, l); } catch (e) { return '0'; } } else { return '0'; } } }
0
mirrored_repositories/coder_status/lib
mirrored_repositories/coder_status/lib/functions/pickImageAndCrop.dart
import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:image_cropper/image_cropper.dart'; import 'package:image_picker/image_picker.dart'; final picker = ImagePicker(); Image avatarimage = Image(image: AssetImage('images/avatar1.jpg')); Future<File> cropSquareImage(File imageFile) async { return await ImageCropper.cropImage( sourcePath: imageFile.path, aspectRatio: CropAspectRatio(ratioX: 1, ratioY: 1), aspectRatioPresets: [CropAspectRatioPreset.square]); } Future<File> pickimage() async { final pickedfile = await picker.getImage(source: ImageSource.gallery); if (pickedfile == null) return null; final croppedfile = await cropSquareImage(File(pickedfile.path)); if (croppedfile != null) return croppedfile; else return null; }
0
mirrored_repositories/coder_status
mirrored_repositories/coder_status/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:coder_status/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/spotifyClone
mirrored_repositories/spotifyClone/lib/now_playing_bar.dart
import 'package:flutter/material.dart'; class NowPlayingBar extends StatelessWidget { const NowPlayingBar({super.key}); @override Widget build(BuildContext context) { return Container( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), color: Colors.black, child: Row( children: [ // Album Artwork Container( height: 50, width: 50, decoration: BoxDecoration( image: const DecorationImage( image: AssetImage('assets/images/artist/theUnstoppables_album.png'), // Replace with actual asset path fit: BoxFit.cover, ), borderRadius: BorderRadius.circular(8), ), ), const SizedBox(width: 12), // Song Details const Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Kashmakash', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), ), SizedBox(height: 4), Text( 'The Unstoppables', style: TextStyle(color: Colors.grey), ), ], ), ), // Playback Controls Row( children: [ IconButton( icon: const Icon(Icons.skip_previous, color: Colors.white), onPressed: () { // Handle skip previous action }, ), IconButton( icon: const Icon(Icons.play_arrow, color: Colors.white, size: 32), onPressed: () { // Handle play/pause action }, ), IconButton( icon: const Icon(Icons.skip_next, color: Colors.white), onPressed: () { // Handle skip next action }, ), ], ), ], ), ); } }
0
mirrored_repositories/spotifyClone
mirrored_repositories/spotifyClone/lib/now_playing_screen.dart
import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:spotifyclone/strings.dart'; class NowPlayingScreen extends StatefulWidget { const NowPlayingScreen({super.key}); @override State<NowPlayingScreen> createState() => _NowPlayingScreenState(); } class _NowPlayingScreenState extends State<NowPlayingScreen> { @override void initState() { super.initState(); } @override void dispose() { super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, body: Stack( children: [ Image.asset( 'assets/images/artist/cardib_image.jpg', // Replace with the path to your background image fit: BoxFit.cover, width: double.infinity, height: double.infinity, ), // Apply the blur effect using BackdropFilter BackdropFilter( filter: ImageFilter.blur(sigmaX: 6, sigmaY: 6), // Adjust the blur intensity child: Container( color: Colors.transparent, ), ), Scaffold( backgroundColor: Colors.transparent, appBar: AppBar( backgroundColor: Colors.transparent, title: Center( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ ColorFiltered( colorFilter: const ColorFilter.mode( Colors.white, // Set your desired tint color BlendMode.srcIn, ), child: Image.asset( Strings.spotifyIcon, // Replace with the path to your image asset width: 30.0, // Set the same width as the container height: 30.0, // Set the same height as the container ), ), const SizedBox(width: 8), // Add some spacing between image and text const Column( children: [ Text( 'PLAYING FROM ARTIST', style: TextStyle( fontSize: 16, fontWeight: FontWeight.normal, color: Colors.white ), ), Text( 'Cardi B', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, color: Colors.white ), ), ], ), ], ), ), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Card( margin: const EdgeInsets.all(16.0), color: Colors.transparent, child: Padding( padding: const EdgeInsets.all(16.0), child: Column( children: [ Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.0), // Adjust the radius as needed border: Border.all( color: Colors.green, // Specify the border color width: 4.0, // Specify the border width ), ), child: Image.asset( 'assets/images/artist/cardib_song_image.jpg', fit: BoxFit.cover, ), ), const SizedBox( height: 10, ), SizedBox( height: 20, child: Slider( value: 20.0, min: 0, max: 100, onChanged: (value) { setState(() { }); }, ), ), const Padding( padding: EdgeInsets.fromLTRB(0, 0, 16, 0), child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Text( '01:26', style: TextStyle( fontSize: 16, fontWeight: FontWeight.w900 ), ), ], ), ), const Row( mainAxisAlignment: MainAxisAlignment.center, children: [ IconButton( onPressed: null, icon: Icon( Icons.skip_previous_sharp, color: Colors.black, ), iconSize: 60.0, ), IconButton( onPressed: null, icon: Icon( Icons.play_arrow, color: Colors.pink, ), iconSize: 60.0, ), IconButton( onPressed: null, icon: Icon( Icons.skip_next_sharp, color: Colors.black), iconSize: 60.0, ), ], ), ], ) ), ), ], ), ), ) ], ) ); } }
0
mirrored_repositories/spotifyClone
mirrored_repositories/spotifyClone/lib/main.dart
import 'package:flutter/material.dart'; import 'package:spotifyclone/now_playing_bar.dart'; import 'package:spotifyclone/now_playing_screen.dart'; import 'package:spotifyclone/strings.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: Strings.appName, theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), home: const NowPlayingScreen(), //Change here if you want to show another screen ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key}); @override State<MyHomePage> createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, appBar: AppBar( backgroundColor: Colors.green, title: Center( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( Strings.spotifyIcon, // Replace with your image asset height: 30, width: 30,// Adjust the height as needed ), const SizedBox(width: 8), // Add some spacing between image and text const Text( Strings.appBarTitle, style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, ), ), ], ), ), ), body: //Center( //child: Stack( children: [ Column( children: <Widget>[ Row( children: [ //User Profile photo const Padding( padding: EdgeInsets.all(16), child: CircleAvatar( backgroundImage: AssetImage(Strings.spotifyAccountProfilePhoto), // Replace 'image_name.png' with the actual file name of your image in the assets folder radius: 20, // You can adjust the radius as needed ), ), //All music feed view SizedBox( width: 70, child: Card( color: Colors.green, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20.0), // Adjust the value as needed ), child: const Center( child: Padding( padding: EdgeInsets.all(16), child: Text( Strings.headerNavigationText1, style: TextStyle(color: Colors.black), ), ), ) ), ), //Music feed view Card( color: Colors.black12, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20.0), // Adjust the value as needed side: const BorderSide( color: Colors.white, // Set the color of the border width: 2.0, // Set the width of the border ), ), child: const Padding( padding: EdgeInsets.all(16), child: Text( Strings.headerNavigationText2, style: TextStyle(color: Colors.white), ), ), ), //Podcast feed view Card( color: Colors.black12, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20.0), // Adjust the value as needed side: const BorderSide( color: Colors.white, // Set the color of the border width: 2.0, // Set the width of the border ), ), child: const Padding( padding: EdgeInsets.all(16), child: Text( Strings.headerNavigationText3, style: TextStyle(color: Colors.white), ), ), ), ], ), //Show all music feed Expanded( child: GridView.builder( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, // Number of columns in the grid ), itemCount: 4, // Number of items in the grid // Inside GridView.builder itemBuilder: (BuildContext context, int index) { return Card( child: Stack( children: [ //Image at the start Positioned.fill( child: Image.asset( getImageAssetPath(index), fit: BoxFit.cover, ), ), // Glass effect overlay Positioned.fill( child: Container( decoration: BoxDecoration( color: Colors.black.withOpacity(0.3), ), ), ), // Text at the center Center( child: Text( getCardText(index), style: const TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 30, ), ), ), ], ), ); }, ), ), ], ), // Now Playing bar view const Positioned( bottom: 0, left: 0, right: 0, child: NowPlayingBar() ), ], ), bottomNavigationBar: BottomNavigationBar( selectedItemColor: Colors.white, unselectedItemColor: Colors.white, backgroundColor: Colors.black26, type: BottomNavigationBarType.fixed, items: [ //Home button const BottomNavigationBarItem( icon: Icon(Icons.home_filled), label: Strings.bottomNavigationText1, ), //Search button const BottomNavigationBarItem( icon: Icon(Icons.search), label: Strings.bottomNavigationText2, ), //Your library button const BottomNavigationBarItem( icon: Icon(Icons.my_library_music), label: Strings.bottomNavigationText3, ), //Purchase premium button BottomNavigationBarItem( icon: SizedBox( width: 24.0, // Set your desired width height: 24.0, // Set your desired height child: ColorFiltered( colorFilter: const ColorFilter.mode( Colors.white, // Set your desired tint color BlendMode.srcIn, ), child: Image.asset( Strings.spotifyIcon, // Replace with the path to your image asset width: 24.0, // Set the same width as the container height: 24.0, // Set the same height as the container ), ), ), label: Strings.bottomNavigationText4, ) ], ), //),// This trailing comma makes auto-formatting nicer for build methods. ); } String getImageAssetPath(int index) { // Replace the following logic with your own way of getting asset paths based on the index // For example, you might have a list of asset paths and use index to access the corresponding path. List<String> assetPaths = [ 'assets/images/artist/ariana_album.png', 'assets/images/artist/avicii_album.png', 'assets/images/artist/cardib_album.png', 'assets/images/artist/shawn_album.png', ]; return assetPaths[index]; } String getCardText(int index) { // Replace the following logic with your own way of getting text based on the index // For example, you might have a list of texts and use index to access the corresponding text. List<String> cardTexts = [ 'Ariana', 'Avicii', 'Cardi B', 'Shawn', ]; return cardTexts[index]; } }
0
mirrored_repositories/spotifyClone
mirrored_repositories/spotifyClone/lib/strings.dart
class Strings { static const String appName = 'Spotify clone'; static const String mainScreenMsg = 'You have pushed the button this many times:'; static const String mainScreenFabButtonTooltip = 'Increment'; static const String spotifyIcon = 'assets/icons/spotify.png'; static const String appBarTitle = 'Spotify'; static const String spotifyAccountProfilePhoto = 'assets/images/profilePhoto/akshay.jpg'; static const String headerNavigationText1 = 'All'; static const String headerNavigationText2 = 'Music'; static const String headerNavigationText3 = 'Podcast'; static const String bottomNavigationText1 = 'Home'; static const String bottomNavigationText2 = 'Search'; static const String bottomNavigationText3 = 'Your Library'; static const String bottomNavigationText4 = 'Premium'; }
0
mirrored_repositories/spotifyClone
mirrored_repositories/spotifyClone/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:spotifyclone/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/scanpay
mirrored_repositories/scanpay/lib/check.dart
import 'package:flutter/material.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:retail/screens/home_page.dart'; import 'package:retail/screens/login_page.dart'; class Check extends StatelessWidget { @override Widget build(BuildContext context) { return FutureBuilder<FirebaseUser>( future: FirebaseAuth.instance.currentUser(), builder: (BuildContext context, AsyncSnapshot<FirebaseUser> snapshot) { if (snapshot.hasData) { // ignore: unused_local_variable FirebaseUser user = snapshot.data; // this is your user instance /// is because there is user already logged return HomePage(); } /// other way there is no user logged. return LoginPage(); }); } }
0
mirrored_repositories/scanpay
mirrored_repositories/scanpay/lib/main.dart
import 'package:flutter/material.dart'; import 'package:retail/screens/Cart.dart'; import 'package:retail/check.dart'; import 'package:retail/screens/PurchaseHistory.dart'; import 'package:retail/screens/signup.dart'; import 'package:retail/screens/splashscreen.dart'; import 'screens/login_page.dart'; import 'screens/home_page.dart'; void main() => runApp( MyApp(), ); class MyApp extends StatefulWidget { @override _MyAppState createState() => new _MyAppState(); } class _MyAppState extends State<MyApp> { final routes = <String, WidgetBuilder>{ '/check': (BuildContext context) => new Check(), '/homepage': (BuildContext context) => new HomePage(), '/loginpage': (BuildContext context) => new LoginPage(), '/signup': (BuildContext context) => new Signup(), '/cartpage': (BuildContext context) => new Cart(), '/purchasehistory': (BuildContext context) => new PurchaseHistory(), }; @override Widget build(BuildContext context) { return MaterialApp( title: 'RetailApp', debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.lightBlue, fontFamily: 'Nunito', ), home: SplashScreen(), routes: routes, ); } }
0
mirrored_repositories/scanpay/lib
mirrored_repositories/scanpay/lib/add_pro/ModelClass.dart
class Model { String barcode,name,netweight,price,key; Model({this.barcode,this.name,this.netweight,this.price,this.key}); }
0
mirrored_repositories/scanpay/lib
mirrored_repositories/scanpay/lib/add_pro/add_product.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:retail/services/product_crud.dart'; import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart'; class AddProduct extends StatefulWidget { @override _AddProductState createState() => _AddProductState(); } class _AddProductState extends State<AddProduct> { String barcode; String name; String price; String netweight; String imageUrl; String producttype; String _scanBarcode; startBarcodeScanStream() async { FlutterBarcodeScanner.getBarcodeStreamReceiver( "#ff6666", "Cancel", true, ScanMode.BARCODE) .listen((barcode) => print(barcode)); } Future<void> scanQR() async { String barcodeScanRes; // Platform messages may fail, so we use a try/catch PlatformException. try { barcodeScanRes = await FlutterBarcodeScanner.scanBarcode( "#ff6666", "Cancel", true, ScanMode.QR); print(barcodeScanRes); } on PlatformException { barcodeScanRes = 'Failed to get platform version.'; } // If the widget was removed from the tree while the asynchronous platform // message was in flight, we want to discard the reply rather than calling // setState to update our non-existent appearance. if (!mounted) return; setState(() { _scanBarcode = barcodeScanRes; }); } // Platform messages are asynchronous, so we initialize in an async method. Future<void> scanBarcodeNormal() async { String barcodeScanRes; // Platform messages may fail, so we use a try/catch PlatformException. try { barcodeScanRes = await FlutterBarcodeScanner.scanBarcode( "#ff6666", "Cancel", true, ScanMode.BARCODE); print(barcodeScanRes); } on PlatformException { barcodeScanRes = 'Failed to get platform version.'; } // If the widget was removed from the tree while the asynchronous platform // message was in flight, we want to discard the reply rather than calling // setState to update our non-existent appearance. if (!mounted) return; setState(() { _scanBarcode = barcodeScanRes; }); } @override Widget build(BuildContext context) { crudProduct crudObj = new crudProduct(); return Scaffold( floatingActionButton: floatingBar(), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, resizeToAvoidBottomPadding: false, backgroundColor: Colors.grey.shade100, body: Builder( builder: (context) => SingleChildScrollView( child: Column( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ SizedBox(height: 70.0), Container( color: Colors.white10, width: 400, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( 'AddDetails', style: TextStyle( color: Colors.blueGrey, fontFamily: 'Raleway', fontWeight: FontWeight.bold, fontSize: 45), ), ], ), ), SizedBox(height: 60), Container( width: 350, child: TextField( keyboardType: TextInputType.url, style: TextStyle(fontFamily: 'Raleway', color: Colors.black), decoration: InputDecoration( labelText: "Image Url", labelStyle: TextStyle(fontWeight: FontWeight.w200, fontSize: 20), border: OutlineInputBorder(), ), onChanged: (value) { this.imageUrl = value; }, ), ), SizedBox(height: 20), Container( width: 350, child: TextField( keyboardType: TextInputType.number, style: TextStyle(fontFamily: 'Raleway', color: Colors.black), decoration: InputDecoration( labelText: "Net Weight", labelStyle: TextStyle(fontWeight: FontWeight.w200, fontSize: 20), border: OutlineInputBorder(), ), onChanged: (value) { this.netweight = value; }, ), ), SizedBox(height: 20), Container( height: 40, width: 350, child: Text( 'Barcode $_scanBarcode', style: TextStyle(fontSize: 20), ), decoration: BoxDecoration( border: Border.all(), borderRadius: BorderRadius.vertical(), shape: BoxShape.rectangle, ), ), SizedBox( height: 20, ), Container( width: 350, child: TextField( keyboardType: TextInputType.text, maxLength: 15, style: TextStyle(fontFamily: 'Raleway', color: Colors.black), decoration: InputDecoration( labelText: "Name", labelStyle: TextStyle(fontWeight: FontWeight.w200, fontSize: 20), border: OutlineInputBorder(), ), onChanged: (value) { this.name = value; }, ), ), Container( width: 350, child: TextField( keyboardType: TextInputType.text, maxLength: 15, style: TextStyle(fontFamily: 'Raleway', color: Colors.black), decoration: InputDecoration( labelText: "Product Type", labelStyle: TextStyle(fontWeight: FontWeight.w200, fontSize: 20), border: OutlineInputBorder(), ), onChanged: (value) { this.producttype = value; }, ), ), Container( width: 350, child: TextField( keyboardType: TextInputType.number, maxLength: 5, style: TextStyle(fontFamily: 'Raleway', color: Colors.black), decoration: InputDecoration( labelText: "Price", labelStyle: TextStyle(fontWeight: FontWeight.w200, fontSize: 20), border: OutlineInputBorder(), ), onChanged: (value) { this.price = value; }, ), ), SizedBox(height: 10), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ RaisedButton( onPressed: () { Map<String, dynamic> products = { 'barcode': '$_scanBarcode', 'img': this.imageUrl, 'name': this.name, 'netweight': this.netweight, 'price': this.price, 'producttype':this.producttype, }; crudObj.addData(products).then((result) { dialogTrigger(context); }).catchError((e) { print(e); }); }, elevation: 4.0, splashColor: Colors.yellow, child: Text( 'Submit', style: TextStyle(color: Colors.black, fontSize: 18.0), ), ), RaisedButton( color: Colors.red.shade400, onPressed: () { Navigator.of(context).pop(); FirebaseAuth.instance.signOut().then((value) { Navigator.of(context) .pushReplacementNamed('\loginpage'); }).catchError((e) { print(e); }); }, elevation: 4.0, splashColor: Colors.yellow, child: Text( 'Back', style: TextStyle(color: Colors.black, fontSize: 18.0), ), ) ], ) ], ), ), ), ); } Widget floatingBar() => Ink( decoration: ShapeDecoration( shape: StadiumBorder(), ), child: FloatingActionButton.extended( onPressed: () => scanBarcodeNormal(), backgroundColor: Colors.black, icon: Icon( FontAwesomeIcons.barcode, color: Colors.white, ), label: Text( "SCAN", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), ), ), ); } Future<bool> dialogTrigger(BuildContext context) async { return showDialog( context: context, barrierDismissible: false, builder: (BuildContext context) { return AlertDialog( title: Text('Job done', style: TextStyle(fontSize: 22.0)), content: Text( 'Added Successfully', style: TextStyle(fontSize: 20.0), ), actions: <Widget>[ FlatButton( child: Text( 'Alright', style: TextStyle(fontSize: 18), ), onPressed: () { Navigator.of(context).pop(); }, ) ], ); }); }
0
mirrored_repositories/scanpay/lib
mirrored_repositories/scanpay/lib/services/product_crud.dart
import 'package:cloud_firestore/cloud_firestore.dart'; // ignore: camel_case_types class crudProduct { Future<void> addData(products) async { Firestore.instance.collection('products').add(products).catchError((e) { print(e); }); } }
0
mirrored_repositories/scanpay/lib
mirrored_repositories/scanpay/lib/services/crud.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; // ignore: camel_case_types class crudMethods { bool isLoggedIn() { if (FirebaseAuth.instance.currentUser() != null) { return true; } else { return false; } } Future<String> getCurrentUID() async { return (await FirebaseAuth.instance.currentUser()).uid; } Future<void> addData(cartData) async { if (isLoggedIn()) { Firestore.instance.collection('CartData').add(cartData).catchError((e) { print(e); }); } else { print('You need to logged in'); } } // ignore: missing_return Future<void> deleteData(docID) { Firestore.instance .collection('CartData') .document(docID) .delete() .catchError((e) { print(e); }); } }
0
mirrored_repositories/scanpay/lib
mirrored_repositories/scanpay/lib/services/AuthUtil.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; class AuthUtil { static Future resetpassword(String email) async { await FirebaseAuth.instance.sendPasswordResetEmail(email: email); } static Future<AuthResult> signInUser( username, password, ) { return FirebaseAuth.instance .signInWithEmailAndPassword(email: username, password: password) .then((value) { return value; }); } static Future<AuthResult> registerUser( username, password, ) { return FirebaseAuth.instance .createUserWithEmailAndPassword(email: username, password: password) .then((value) { return value; }); } static Future<FirebaseUser> getCurrentUser() async { final user = await FirebaseAuth.instance.currentUser(); return user; } static Future<bool> signOutCurrentUser() async { await FirebaseAuth.instance.signOut(); return true; } static Future<DocumentSnapshot> getCurrentUserFromFS( FirebaseUser user) async { try { if (user != null) { print("user id is ${user.uid}"); return Firestore.instance.collection('users').document(user.uid).get(); // .then((ds) { // print("got user from fs ${ds["email"]}"); // return ds; // }); } else { print("user is null"); return null; } } catch (e) { print(e); return null; } } }
0
mirrored_repositories/scanpay/lib
mirrored_repositories/scanpay/lib/screens/home_page.dart
import 'dart:async'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/services.dart'; import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:retail/screens/PurchaseHistory.dart'; class HomePage extends StatefulWidget { HomePage({Key key, this.title}) : super(key: key); final String title; @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { FirebaseUser user; Future<void> getUserData() async { FirebaseUser userData = await FirebaseAuth.instance.currentUser(); setState(() { user = userData; print(userData.uid); }); } Future<void> getUser() async { DocumentSnapshot cn = await Firestore.instance .collection('users') .document('${user.uid}') .get(); return cn; } @override void initState() { super.initState(); getUserData(); getUser(); } startBarcodeScanStream() async { FlutterBarcodeScanner.getBarcodeStreamReceiver( "#ff6666", "Cancel", true, ScanMode.BARCODE) .listen((barcode) => print(barcode)); } Future<void> scanQR() async { String barcodeScanRes; // Platform messages may fail, so we use a try/catch PlatformException. try { barcodeScanRes = await FlutterBarcodeScanner.scanBarcode( "#ff6666", "Cancel", true, ScanMode.QR); print(barcodeScanRes); } on PlatformException { barcodeScanRes = 'Failed to get platform version.'; } // If the widget was removed from the tree while the asynchronous platform // message was in flight, we want to discard the reply rather than calling // setState to update our non-existent appearance. if (!mounted) return; } // Platform messages are asynchronous, so we initialize in an async method. Future<void> scanBarcodeNormal() async { String barcodeScanRes; // Platform messages may fail, so we use a try/catch PlatformException. try { barcodeScanRes = await FlutterBarcodeScanner.scanBarcode( "#ff6666", "Cancel", true, ScanMode.BARCODE); print(barcodeScanRes); } on PlatformException { barcodeScanRes = 'Failed to get platform version.'; } // If the widget was removed from the tree while the asynchronous platform // message was in flight, we want to discard the reply rather than calling // setState to update our non-existent appearance. if (!mounted) return; if (barcodeScanRes != '-1' || null) { return showDialog( context: context, builder: (context) { return StreamBuilder( stream: Firestore.instance .collection("products") .where("barcode", isEqualTo: '$barcodeScanRes') .snapshots(), builder: (context, snapshot) { if (!snapshot.hasData) { return Dialog( child: Container( height: 300, child: Text('Product Not Found'), ), ); } else { return Dialog( child: Container( height: 350, child: Column(children: [ Container( height: 350, width: 165, child: ListView.builder( scrollDirection: Axis.horizontal, itemCount: snapshot.data.documents.length, itemBuilder: (context, index) { DocumentSnapshot products = snapshot.data.documents[index]; return ScanCard(products: products); }, )), ]), ), ); } }); }); } } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.grey[250], floatingActionButton: floatingBar(), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, appBar: buildAppBar(), drawer: Drawer( child: ListView( children: <Widget>[ FutureBuilder( future: getUser(), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.done) { return UserAccountsDrawerHeader( currentAccountPicture: new CircleAvatar( radius: 60.0, backgroundColor: Colors.transparent, backgroundImage: NetworkImage( "https://cdn2.iconfinder.com/data/icons/website-icons/512/User_Avatar-512.png"), ), accountName: Text( "Name: ${snapshot.data['displayName']}", style: TextStyle(fontSize: 15), ), accountEmail: Text( "Email: ${snapshot.data['email']}", style: TextStyle(fontSize: 15), )); } else { return CircularProgressIndicator(); } }), ListTile( leading: Icon(Icons.shopping_cart), title: Text( "Purchase History", style: TextStyle( fontStyle: FontStyle.normal, fontWeight: FontWeight.w400, fontSize: 20), ), onTap: () { Navigator.push( context, MaterialPageRoute( builder: (BuildContext context) => PurchaseHistory())); }, ), ListTile( leading: Icon(Icons.exit_to_app), title: Text( "Log out", style: TextStyle( fontStyle: FontStyle.normal, fontWeight: FontWeight.w400, fontSize: 20), ), onTap: () { Navigator.of(context).pop(); FirebaseAuth.instance.signOut().then( (value) { Navigator.of(context).pushNamedAndRemoveUntil( '/loginpage', (Route<dynamic> route) => false); }, ); }, ), ], ), ), body: SingleChildScrollView( child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ SizedBox( height: 30, ), Padding( padding: const EdgeInsets.all(8.0), child: Text( 'Food Items', style: TextStyle(fontWeight: FontWeight.w300, fontSize: 20), ), ), buildStreamBuilder(), SizedBox( height: 30, ), Padding( padding: const EdgeInsets.all(8.0), child: Text( 'Clothes', style: TextStyle(fontWeight: FontWeight.w300, fontSize: 20), ), ), buildStreamClothes() ], ), ), ); } StreamBuilder<QuerySnapshot> buildStreamBuilder() { return StreamBuilder( stream: Firestore.instance .collection("products") .where("producttype", isEqualTo: "fooditem") .snapshots(), builder: (context, snapshot) { if (snapshot.data == null) return Text( 'Scan Barcode', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), ); return Container( height: 240, child: ListView.separated( scrollDirection: Axis.horizontal, itemCount: snapshot.data.documents.length, itemBuilder: (context, index) { DocumentSnapshot products = snapshot.data.documents[index]; return ItemCard(products: products); }, separatorBuilder: (BuildContext context, int index) { return SizedBox(width: 10); })); }); } StreamBuilder<QuerySnapshot> buildStreamClothes() { return StreamBuilder( stream: Firestore.instance .collection("products") .where("producttype", isEqualTo: "clothes") .snapshots(), builder: (context, snapshot) { if (snapshot.data == null) return Text( 'Scan Barcode', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), ); return Container( height: 240, child: ListView.separated( scrollDirection: Axis.horizontal, itemCount: snapshot.data.documents.length, itemBuilder: (context, index) { DocumentSnapshot products = snapshot.data.documents[index]; return ItemCard(products: products); }, separatorBuilder: (BuildContext context, int index) { return SizedBox(width: 10); })); }); } AppBar buildAppBar() { return AppBar( centerTitle: true, elevation: 0, backgroundColor: Colors.blue, iconTheme: IconThemeData(color: Colors.black), title: Text( "Scan&Pay", style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold), ), actions: [ IconButton( icon: Icon( Icons.shopping_cart, color: Colors.black, ), onPressed: () { Navigator.of(context).pushNamed('/cartpage'); }, ) ], ); } Widget floatingBar() => Ink( decoration: ShapeDecoration( shape: StadiumBorder(), ), child: FloatingActionButton.extended( onPressed: () { scanBarcodeNormal(); }, backgroundColor: Colors.black, icon: Icon( FontAwesomeIcons.barcode, color: Colors.white, ), label: Text( "SCAN", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), ), ), ); } class ItemCard extends StatelessWidget { const ItemCard({ Key key, @required this.products, }) : super(key: key); final DocumentSnapshot products; @override Widget build(BuildContext context) { String _userId; FirebaseAuth.instance.currentUser().then((user) { _userId = user.uid; }); return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( padding: EdgeInsets.all(20.0), height: 180, width: 160, decoration: BoxDecoration( color: Color(0xFF3D82AE), borderRadius: BorderRadius.circular(16)), child: Image.network(products['img']), ), Padding( padding: const EdgeInsets.symmetric(vertical: 20.0 / 4), child: Text( products['name'], style: TextStyle( color: Color(0xFF535353), ), ), ), Row( children: [ Text( "\₹ " + products['price'], style: TextStyle(fontWeight: FontWeight.bold), ), SizedBox( width: 60, ), GestureDetector( child: Icon( CupertinoIcons.cart_fill_badge_plus, color: Colors.black, size: 30, ), onTap: () { DocumentReference documentReference = Firestore.instance .collection('userData') .document(_userId) .collection('cartData') .document(); documentReference .setData({ 'uid': _userId, 'barcode': products['barcode'], 'img': products['img'], 'name': products['name'], 'netweight': products['netweight'], 'price': products['price'], 'id': documentReference.documentID }) .then((result) {}) .catchError((e) { print(e); }); Scaffold.of(context).showSnackBar(new SnackBar( content: new Text( 'Added to Cart', style: TextStyle(color: Colors.white, fontSize: 18), textAlign: TextAlign.start, ), duration: Duration(milliseconds: 300), backgroundColor: Color(0xFF3D82AE), )); }, ), ], ) ], ); } } class ScanCard extends StatelessWidget { const ScanCard({ Key key, @required this.products, }) : super(key: key); final DocumentSnapshot products; @override Widget build(BuildContext context) { String _userId; FirebaseAuth.instance.currentUser().then((user) { _userId = user.uid; }); return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( padding: EdgeInsets.all(10.0), height: 180, width: 160, decoration: BoxDecoration( color: Color(0xFF3D82AE), borderRadius: BorderRadius.circular(16)), child: Image.network(products['img']), ), Padding( padding: const EdgeInsets.symmetric(vertical: 20.0 / 4), child: Text( products['name'], style: TextStyle( color: Color(0xFF535353), fontSize: 18, ), ), ), Column( children: [ Text( "netweight- " + products['netweight'], style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14), ), SizedBox( width: 30, ), ], ), Row( children: [ Text( "\₹ " + products['price'], style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), SizedBox( width: 60, ), Icon( Icons.add_shopping_cart, color: Colors.black, size: 27, ), ], ), SizedBox( width: 10, ), SizedBox( child: Padding( padding: const EdgeInsets.all(10), child: RaisedButton( shape: RoundedRectangleBorder( borderRadius: new BorderRadius.circular(30.0)), color: Color(0xFF3D82AE), child: Text( "Add to cart", style: TextStyle(color: Colors.white), ), onPressed: () { DocumentReference documentReference = Firestore.instance .collection('userData') .document(_userId) .collection('cartData') .document(); documentReference.setData({ 'uid': _userId, 'barcode': products['barcode'], 'img': products['img'], 'name': products['name'], 'netweight': products['netweight'], 'price': products['price'], 'id': documentReference.documentID }).then((result) { dialogTrigger(context); }).catchError((e) { print(e); }); }, ), ), ) ], ); } } Future<bool> dialogTrigger(BuildContext context) async { return showDialog( context: context, barrierDismissible: false, builder: (BuildContext context) { return AlertDialog( title: Text('Job done', style: TextStyle(fontSize: 22.0)), content: Text( 'Added Successfully', style: TextStyle(fontSize: 20.0), ), actions: <Widget>[ FlatButton( child: Text( 'Alright', style: TextStyle(fontSize: 18), ), onPressed: () { Navigator.of(context).pop(); }, ) ], ); }); }
0
mirrored_repositories/scanpay/lib
mirrored_repositories/scanpay/lib/screens/PurchaseHistory.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; class PurchaseHistory extends StatefulWidget { @override _PurchaseHistoryState createState() => _PurchaseHistoryState(); } class _PurchaseHistoryState extends State<PurchaseHistory> { FirebaseUser user; Future<void> getUserData() async { FirebaseUser userData = await FirebaseAuth.instance.currentUser(); setState(() { user = userData; print(userData.uid); }); } @override void initState() { super.initState(); getUserData(); } @override Widget build(BuildContext context) { return Scaffold( appBar: buildAppBar(), body: SafeArea( child: Column( children: [ SizedBox(height: 30,), StreamBuilder( stream: Firestore.instance .collection("userOrders") .document('${user.uid}') .collection('orders') .snapshots(), builder: (context, snapshot) { if (snapshot.data == null) return Text( ' No Items In The Orders', style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold), ); return Container( height: 510, width: 400, child: ListView.separated( itemCount: snapshot.data.documents.length, itemBuilder: (context, index) { DocumentSnapshot products = snapshot.data.documents[index]; return Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Column( children: [ SizedBox(height: 10), Container( padding: EdgeInsets.all(1.0), height: 80, width: 100, decoration: BoxDecoration( color: Color(0xFF3D82AE), borderRadius: BorderRadius.circular(16)), child: Image.network(products['img']), ), ], ), SizedBox(width: 10), Padding( padding: const EdgeInsets.symmetric( vertical: 20.0 / 4), child: Text( products['name'], style: TextStyle( color: Colors.black, fontSize: 20, ), ), ), SizedBox( width: 30, ), Row( children: [ Text( "\₹ " + products['price'], style: TextStyle( fontWeight: FontWeight.bold), ), ], ) ], ); }, separatorBuilder: (BuildContext context, int index) { return SizedBox(height: 20); })); }), ], ), )); } } AppBar buildAppBar() { return AppBar( centerTitle: true, elevation: 0, backgroundColor: Colors.blue, iconTheme: IconThemeData(color: Colors.black), title: Text( "Purchase History", style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold), ), ); }
0
mirrored_repositories/scanpay/lib
mirrored_repositories/scanpay/lib/screens/splashscreen.dart
import 'dart:async'; import 'package:flutter/material.dart'; class SplashScreen extends StatefulWidget { @override State<StatefulWidget> createState() { return SplashScreenState(); } } class SplashScreenState extends State<SplashScreen> { @override void initState() { super.initState(); loadData(); } Future<Timer> loadData() async { return new Timer(Duration(seconds: 2), onDoneLoading); } onDoneLoading() async { Navigator.of(context).pushReplacementNamed('/check'); } @override Widget build(BuildContext context) { return new Scaffold( backgroundColor: Colors.blue[100], body: new Center( child: Image.asset('assets/logo.png'), ), ); } }
0
mirrored_repositories/scanpay/lib
mirrored_repositories/scanpay/lib/screens/signup.dart
import 'dart:io'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:retail/screens/home_page.dart'; import 'package:retail/services/AuthUtil.dart'; import 'package:firebase_auth/firebase_auth.dart'; final FirebaseAuth mAuth = FirebaseAuth.instance; class Signup extends StatefulWidget { @override _SignupState createState() => _SignupState(); } class _SignupState extends State<Signup> { TextEditingController emailController = new TextEditingController(); TextEditingController passwordController = new TextEditingController(); @override Widget build(BuildContext context) { TextEditingController emailController = TextEditingController(); TextEditingController contactController = TextEditingController(); TextEditingController usernameController = TextEditingController(); TextEditingController passwordController = TextEditingController(); TextEditingController confirmPassController = TextEditingController(); final _formKey = GlobalKey<FormState>(); return Scaffold( backgroundColor: Colors.blue[50], body: Form( key: _formKey, child: Padding( padding: const EdgeInsets.all(8.0), child: SingleChildScrollView( child: Column( // mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ SizedBox(height: 75), Padding( padding: const EdgeInsets.all(8.0), child: CircleAvatar( backgroundColor: Colors.transparent, radius: 110.0, child: Image.asset('assets/logo.png'), ), ), Padding( padding: const EdgeInsets.all(8.0), child: TextFormField( controller: usernameController, keyboardType: TextInputType.text, decoration: InputDecoration( prefixIcon: Icon( Icons.person_outline, color: Color(0xFF455A64), ), labelText: "Username", labelStyle: TextStyle( color: Colors.black, ), errorStyle: TextStyle(color: Colors.black), filled: true, fillColor: Colors.white, hintText: "Username", contentPadding: EdgeInsets.symmetric( vertical: 10.0, horizontal: 20.0), border: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(32.0)), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xFF455A64), width: 1.0), borderRadius: BorderRadius.all(Radius.circular(32.0)), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xFF455A64), width: 2.0), borderRadius: BorderRadius.all(Radius.circular(32.0)), ), ), validator: (value) { if (value.isEmpty) { return "Please enter a valid username"; } return null; }, ), ), Padding( padding: const EdgeInsets.all(8.0), child: TextFormField( controller: contactController, keyboardType: TextInputType.phone, decoration: InputDecoration( prefixIcon: Icon( Icons.person_outline, color: Color(0xFF455A64), ), labelText: "Phone Number", labelStyle: TextStyle( color: Colors.black, ), errorStyle: TextStyle(color: Colors.black), filled: true, fillColor: Colors.white, hintText: "Phone Number", contentPadding: EdgeInsets.symmetric( vertical: 10.0, horizontal: 20.0), border: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(32.0)), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xFF455A64), width: 1.0), borderRadius: BorderRadius.all(Radius.circular(32.0)), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xFF455A64), width: 2.0), borderRadius: BorderRadius.all(Radius.circular(32.0)), ), ), validator: (value) { if (value.isEmpty) { return "Please enter a valid Phone Number"; } if (value.length != 10) { return "Please enter a valid Phone Number"; } return null; }, ), ), Padding( padding: const EdgeInsets.all(8.0), child: TextFormField( controller: emailController, keyboardType: TextInputType.emailAddress, decoration: InputDecoration( prefixIcon: Icon( Icons.email, color: Color(0xFF455A64), ), labelText: "Email", labelStyle: TextStyle( color: Colors.black, ), errorStyle: TextStyle(color: Colors.black), filled: true, fillColor: Colors.white, hintText: "Email", contentPadding: EdgeInsets.symmetric( vertical: 10.0, horizontal: 20.0), border: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(32.0)), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xFF455A64), width: 1.0), borderRadius: BorderRadius.all(Radius.circular(32.0)), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xFF455A64), width: 2.0), borderRadius: BorderRadius.all(Radius.circular(32.0)), ), ), validator: (value) { if (value.isNotEmpty && value.contains("@")) { var splitEmail = value.split("@"); print("split length is ${splitEmail.length}"); if (splitEmail.length == 2) { var firstHalf = splitEmail[0]; var secondHalf = splitEmail[1]; print( "first half is $firstHalf with length of ${firstHalf.length}"); print( "second half is $secondHalf with length of ${secondHalf.length}"); var secondHalfSplit = secondHalf.split("."); print( "second half split lenght is ${secondHalfSplit.length}"); print("second half 1 is [${secondHalfSplit[0]}] "); if (!secondHalf.contains(".") || secondHalf.length < 3 || secondHalfSplit.length != 2 || secondHalfSplit[0].isEmpty || secondHalfSplit[1].isEmpty) { return "Please enter a valid email"; } if (firstHalf.length < 3) { return "Please enter a valid email"; } } else { return "Please enter a valid email"; } } if (value.isEmpty || !value.contains("@") || !value.contains(".") || value.length < 6) { return 'Please enter a valid email'; } return null; }, ), ), Padding( padding: const EdgeInsets.all(8.0), child: TextFormField( controller: passwordController, keyboardType: TextInputType.text, obscureText: true, decoration: InputDecoration( prefixIcon: Icon( Icons.vpn_key, color: Color(0xFF455A64), ), labelText: "Password", labelStyle: TextStyle( color: Colors.black, ), errorStyle: TextStyle(color: Colors.black), filled: true, fillColor: Colors.white, hintText: "Password", contentPadding: EdgeInsets.symmetric( vertical: 10.0, horizontal: 20.0), border: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(32.0)), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xFF455A64), width: 1.0), borderRadius: BorderRadius.all(Radius.circular(32.0)), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xFF455A64), width: 2.0), borderRadius: BorderRadius.all(Radius.circular(32.0)), ), ), validator: (value) { if (value.isEmpty) { return 'Please enter a password'; } return null; }, ), ), Padding( padding: const EdgeInsets.all(8.0), child: TextFormField( controller: confirmPassController, obscureText: true, keyboardType: TextInputType.text, decoration: InputDecoration( prefixIcon: Icon( Icons.vpn_key, color: Color(0xFF455A64), ), labelText: "Confirm Password", labelStyle: TextStyle( color: Colors.black, ), errorStyle: TextStyle(color: Colors.black), filled: true, fillColor: Colors.white, hintText: "Confirm Password", contentPadding: EdgeInsets.symmetric( vertical: 10.0, horizontal: 20.0), border: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(32.0)), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xFF455A64), width: 1.0), borderRadius: BorderRadius.all(Radius.circular(32.0)), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xFF455A64), width: 2.0), borderRadius: BorderRadius.all(Radius.circular(32.0)), ), ), validator: (value) { if (value.isEmpty || value.length < 6) { return 'Please enter the same password'; } if (value != passwordController.text) { return 'Please enter the same password'; } return null; }, ), ), SizedBox( width: double.infinity, child: Padding( padding: const EdgeInsets.all(8.0), child: RaisedButton( shape: RoundedRectangleBorder( borderRadius: new BorderRadius.circular(30.0)), color: Colors.lightBlueAccent, child: Text( "Sign up", style: TextStyle(color: Colors.white), ), onPressed: () { if (_formKey.currentState.validate()) { AuthUtil.registerUser( emailController.text, passwordController.text, ).then((result) { Firestore.instance .collection('users') .document(result.user.uid) .setData({ 'displayName': usernameController.text, 'phoneNumber': contactController.text, 'email': emailController.text, "uid": result.user.uid }).then((success) { Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => HomePage()), ); }); }).catchError((error) { var e = error; var authError = ""; print("caught error ${e.code}"); switch (e.code) { case 'ERROR_INVALID_EMAIL': authError = 'Invalid Email'; break; case 'ERROR_USER_NOT_FOUND': authError = 'User Not Found'; break; case 'ERROR_WRONG_PASSWORD': authError = 'Wrong Password'; break; case 'ERROR_EMAIL_ALREADY_IN_USE': authError = "You have an account already, please sign in"; break; default: authError = 'Error'; break; } _showErrorDataDialog(context, authError); print('The error is $authError'); }); } else { print("check errors"); } }, ), ), ) ], ), ), ), ), ); } } Future _showErrorDataDialog(context, String error) async { var matDialog = AlertDialog( title: new Text("Error"), content: new Text(error), actions: <Widget>[ new FlatButton( child: new Text("Ok"), onPressed: () { Navigator.of(context).pop(); }, ), ], ); var cupDialog = CupertinoAlertDialog( title: new Text("Error"), content: new Text(error), actions: <Widget>[ new FlatButton( child: new Text("Ok"), onPressed: () { Navigator.of(context).pop(); }, ), ], ); Widget dialog = matDialog; if (Platform.isIOS) { dialog = cupDialog; } showDialog( context: context, builder: (BuildContext context) { return dialog; }, ); }
0
mirrored_repositories/scanpay/lib
mirrored_repositories/scanpay/lib/screens/login_page.dart
import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:retail/add_pro/add_product.dart'; import 'package:retail/screens/signup.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:retail/services/AuthUtil.dart'; class LoginPage extends StatefulWidget { static String tag = 'login-page'; @override _LoginPageState createState() => new _LoginPageState(); } class _LoginPageState extends State<LoginPage> { @override Widget build(BuildContext context) { TextEditingController emailController = new TextEditingController(); TextEditingController passwordController = new TextEditingController(); String _warning; final _formKey = GlobalKey<FormState>(); return Scaffold( backgroundColor: Colors.blue[50], body: Form( key: _formKey, child: SingleChildScrollView( child: Padding( padding: EdgeInsets.only(left: 24.0, right: 24.0), child: Column( children: <Widget>[ SizedBox(height: 160), Padding( padding: const EdgeInsets.all(8.0), child: CircleAvatar( backgroundColor: Colors.transparent, radius: 135.0, child: Image.asset('assets/logo.png'), ), ), Padding( padding: const EdgeInsets.all(8.0), child: TextFormField( controller: emailController, keyboardType: TextInputType.emailAddress, decoration: InputDecoration( prefixIcon: Icon( Icons.email, color: Color(0xFF455A64), ), labelText: "Email", labelStyle: TextStyle( color: Colors.black, ), errorStyle: TextStyle(color: Colors.blueGrey[700]), filled: true, fillColor: Colors.white, hintText: "Email", contentPadding: EdgeInsets.symmetric( vertical: 10.0, horizontal: 20.0), border: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(32.0)), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xFF455A64), width: 1.0), borderRadius: BorderRadius.all(Radius.circular(32.0)), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xFF455A64), width: 2.0), borderRadius: BorderRadius.all(Radius.circular(32.0)), ), ), validator: (value) { if (value.isNotEmpty && value.contains("@")) { var splitEmail = value.split("@"); print("split length is ${splitEmail.length}"); if (splitEmail.length == 2) { var firstHalf = splitEmail[0]; var secondHalf = splitEmail[1]; print( "first half is $firstHalf with length of ${firstHalf.length}"); print( "second half is $secondHalf with length of ${secondHalf.length}"); var secondHalfSplit = secondHalf.split("."); print( "second half split lenght is ${secondHalfSplit.length}"); print("second half 1 is [${secondHalfSplit[0]}] "); if (!secondHalf.contains(".") || secondHalf.length < 3 || secondHalfSplit.length != 2 || secondHalfSplit[0].isEmpty || secondHalfSplit[1].isEmpty) { return "Please enter a valid email"; } if (firstHalf.length < 3) { return "Please enter a valid email"; } } else { return "Please enter a valid email"; } } if (value.isEmpty || !value.contains("@") || !value.contains(".") || value.length < 6) { return 'Please enter a valid email'; } return null; }, ), ), Padding( padding: const EdgeInsets.all(8.0), child: TextFormField( controller: passwordController, keyboardType: TextInputType.text, obscureText: true, decoration: InputDecoration( prefixIcon: Icon( Icons.vpn_key, color: Color(0xFF455A64), ), labelText: "Password", labelStyle: TextStyle( color: Colors.black, ), errorStyle: TextStyle(color: Colors.blueGrey[700]), filled: true, fillColor: Colors.white, hintText: "Password", contentPadding: EdgeInsets.symmetric( vertical: 10.0, horizontal: 20.0), border: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(32.0)), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xFF455A64), width: 1.0), borderRadius: BorderRadius.all(Radius.circular(32.0)), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xFF455A64), width: 2.0), borderRadius: BorderRadius.all(Radius.circular(32.0)), ), ), validator: (value) { if (value.isEmpty || value.length < 6) { return 'Please enter a password'; } return null; }, ), ), SizedBox( width: double.infinity, child: Padding( padding: EdgeInsets.all(12), child: RaisedButton( shape: RoundedRectangleBorder( borderRadius: new BorderRadius.circular(30.0)), color: Colors.lightBlueAccent, child: Text( "Login", style: TextStyle(color: Colors.white), ), onPressed: () { if (_formKey.currentState.validate()) { AuthUtil.signInUser( emailController.text, passwordController.text) .then((AuthResult authResult) { print("authResult is ${authResult.user.email}"); Navigator.pop(context); Navigator.of(context).pushNamedAndRemoveUntil( '/homepage', (Route<dynamic> route) => false); }).catchError((error) { var e = error; var authError = ""; print("caught error ${e.code}"); switch (e.code) { case 'ERROR_INVALID_EMAIL': authError = 'Invalid Email'; break; case 'ERROR_USER_NOT_FOUND': authError = 'User Not Found'; break; case 'ERROR_WRONG_PASSWORD': authError = 'Wrong Password'; break; case 'ERROR_EMAIL_ALREADY_IN_USE': authError = "You have an account already, please sign in"; break; default: authError = 'Error'; break; } _showErrorDataDialog(context, authError); print('The error is $authError'); }); } else { print("check errors"); } }, ), ), ), FlatButton( child: Text( 'Forgot password?', style: TextStyle(color: Colors.black54), textAlign: TextAlign.left, ), onPressed: () { showDialog( context: context, builder: (BuildContext context) { return Dialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular( 20.0)), //this right here child: Container( height: 160, child: Padding( padding: const EdgeInsets.all(12.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ TextFormField( controller: emailController, keyboardType: TextInputType.emailAddress, decoration: InputDecoration( prefixIcon: Icon( Icons.email, color: Color(0xFF455A64), ), labelText: "Email", labelStyle: TextStyle( color: Colors.black, ), errorStyle: TextStyle( color: Colors.blueGrey[700]), filled: true, fillColor: Colors.white, hintText: "Email", contentPadding: EdgeInsets.symmetric( vertical: 10.0, horizontal: 20.0), border: OutlineInputBorder( borderRadius: BorderRadius.all( Radius.circular(32.0)), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( color: Color(0xFF455A64), width: 1.0), borderRadius: BorderRadius.all( Radius.circular(32.0)), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide( color: Color(0xFF455A64), width: 2.0), borderRadius: BorderRadius.all( Radius.circular(32.0)), ), ), ), SizedBox( height: 20, ), SizedBox( width: 320.0, child: RaisedButton( shape: RoundedRectangleBorder( borderRadius: new BorderRadius.circular( 30.0)), onPressed: () { try { AuthUtil.resetpassword( emailController.text); print("Password reset email sent"); _warning = "A password reset link has been sent! Check Your Email"; _showforgotpass(context, _warning); } catch (e) { print(e); setState(() { _warning = e.message; _showforgotpass( context, _warning); }); } }, child: Text( "Send", style: TextStyle(color: Colors.white), ), color: Colors.lightBlueAccent, ), ) ], ), ), ), ); }); }, ), FlatButton( child: Text( 'Sign up', style: TextStyle(color: Colors.black54), textAlign: TextAlign.right, ), onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (context) => Signup())); }, ), FlatButton( child: Text( 'Add Product', style: TextStyle(color: Colors.black54), textAlign: TextAlign.right, ), onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (context) => AddProduct())); }, ), ], ), ), ), ), ); } } Future _showErrorDataDialog(context, String error) async { var matDialog = AlertDialog( title: new Text("Error"), content: new Text(error), actions: <Widget>[ new FlatButton( child: new Text("Ok"), onPressed: () { Navigator.of(context).pop(); }, ), ], ); var cupDialog = CupertinoAlertDialog( title: new Text("Error"), content: new Text(error), actions: <Widget>[ new FlatButton( child: new Text("Ok"), onPressed: () { Navigator.of(context).pop(); }, ), ], ); Widget dialog = matDialog; if (Platform.isIOS) { dialog = cupDialog; } showDialog( context: context, builder: (BuildContext context) { return dialog; }, ); } Future _showforgotpass(context, String error) async { var matreset = AlertDialog( content: new Text(error), actions: <Widget>[ new FlatButton( child: new Text("Ok"), onPressed: () { Navigator.of(context).pop(); }, ), ], ); var cupreset = CupertinoAlertDialog( title: new Text("Error"), content: new Text(error), actions: <Widget>[ new FlatButton( child: new Text("Ok"), onPressed: () { Navigator.of(context).pop(); }, ), ], ); Widget dialog = matreset; if (Platform.isIOS) { dialog = cupreset; } showDialog( context: context, builder: (BuildContext context) { return dialog; }, ); }
0