Skip to content

Instantly share code, notes, and snippets.

View haashem's full-sized avatar
🏠
Working from home

Hashem haashem

🏠
Working from home
View GitHub Profile
@haashem
haashem / dropping-tiles.dart
Created October 14, 2022 14:07
dropping tiles
Column(
mainAxisSize: MainAxisSize.min,
children: sections.entries.mapIndexed(
(index, e) {
// 3
final itemAnimation = CurvedAnimation(
parent: animationController,
curve: Interval(
10 / timelineFrames +
(5 - index) * 1 / 5 * 10 / timelineFrames,
@haashem
haashem / item_tap.dart
Created October 14, 2022 08:25
item tap
void onItemTapped(int index) {
_selectedIndex = index;
switch (index) {
case 0:
context.goNamed(Routes.signInAndSecurity.name);
break;
case 1:
context.goNamed(Routes.personalInformation.name);
break;
case 2:
@haashem
haashem / app_bar.dart
Last active October 14, 2022 13:54
Appear with drop down menu
import 'package:appleid_dashboard/shared/responsive.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import '../menu/view_model.dart';
class AppBar extends StatefulWidget {
final ValueChanged<int> onItemTapped;
const AppBar({super.key, required this.onItemTapped});
@haashem
haashem / main.dart
Last active September 26, 2022 17:39
MaterialApp Router
import 'package:appleid_dashboard/router/routes.dart';
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
final colorScheme = ColorScheme.fromSeed(seedColor: Colors.blue);
@haashem
haashem / SideMenuOnPressed.dart
Last active October 13, 2022 09:48
Side Menu OnPressed
SideMenu(
selectedIndex: _selectedIndex,
onPressed: ((index) {
_selectedIndex = index;
switch (index) {
case 0:
context
.goNamed(Routes.signInAndSecurity.name);
break;
case 1:
@haashem
haashem / routes.dart
Last active October 13, 2022 09:12
AppRouter
extension MenuItemTypeFromString on MenuItemType {
static MenuItemType fromString(String value) {
if (value == Routes.signInAndSecurity.value) {
return MenuItemType.security;
} else if (value == Routes.personalInformation.value) {
return MenuItemType.information;
} else if (value == Routes.paymentMethods.value) {
return MenuItemType.payment;
} else if (value == Routes.familySharing.value) {
@haashem
haashem / route-names.dart
Last active September 26, 2022 17:35
Apple ID dashboard routes
enum Routes {
home(''),
signInAndSecurity('security'),
personalInformation('information'),
paymentMethods('payment'),
familySharing('family'),
devices('devices'),
privacy('privacy');
const Routes(this.value);
@haashem
haashem / modal.dart
Created September 26, 2022 12:55
Responsive Modal
@override
Widget build(BuildContext context) {
return AnimatedLayout(
duration: const Duration(milliseconds: 250),
layoutState: Responsive.isMobile(context) ? LayoutState.open : LayoutState.close,
fromBuilder: (context) => _NonMobileModal(
icon: icon,
title: title,
onCloseButtonPressed: onCloseButtonPressed,
child: child),
@haashem
haashem / onCardPressed.dart
Created September 26, 2022 11:09
Show dialog
void onCardPressed(SignInSecurityCardType type) {
showDialog(
context: context,
barrierColor: Colors.grey.withOpacity(0.8),
barrierDismissible: true,
builder: (context) {
switch (type) {
case SignInSecurityCardType.appleId:
break;
case SignInSecurityCardType.password:
@haashem
haashem / SignInAndSecurityPage-Child.dart
Created September 25, 2022 18:33
SignInAndSecurityPage child widget
Center(
child: Responsive(
mobile: _BelowDesktopLayout(),
tablet: _BelowDesktopLayout(),
desktop: _DesktopLayout(),
),
)