git-touch-android-ios-app/lib/ios/main.dart

84 lines
2.4 KiB
Dart
Raw Normal View History

2018-04-20 18:59:26 +02:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
2018-07-05 16:08:19 +02:00
import 'home.dart';
2018-04-21 14:50:46 +02:00
import 'notification.dart';
2019-01-23 12:52:51 +01:00
import 'search.dart';
2018-04-21 14:50:46 +02:00
import 'profile.dart';
2018-04-20 18:59:26 +02:00
class IosHomePage extends StatefulWidget {
IosHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
2018-07-05 16:08:19 +02:00
_IosHomePageState createState() => _IosHomePageState();
2018-04-20 18:59:26 +02:00
}
class _IosHomePageState extends State<IosHomePage> {
@override
2018-04-21 14:50:46 +02:00
Widget build(context) {
2019-01-25 13:35:20 +01:00
return CupertinoTheme(
data: CupertinoThemeData(
// brightness: Brightness.dark,
// barBackgroundColor: Color.fromRGBO(0x24, 0x29, 0x2e, 1),
),
2018-07-05 16:08:19 +02:00
child: CupertinoTabScaffold(
tabBar: CupertinoTabBar(
2019-01-22 16:39:44 +01:00
items: [
2018-07-05 16:08:19 +02:00
BottomNavigationBarItem(
icon: Icon(Icons.rss_feed),
title: Text('News'),
2018-04-21 14:50:46 +02:00
),
2018-07-05 16:08:19 +02:00
BottomNavigationBarItem(
icon: StreamBuilder<int>(builder: (context, snapshot) {
int count = snapshot.data;
print(count);
// https://stackoverflow.com/a/45434404
if (count != null && count > 0) {
return Stack(children: <Widget>[
Icon(Icons.notifications),
Positioned(
// draw a red marble
top: 0,
right: 0,
child: Icon(Icons.brightness_1,
size: 8.0, color: Colors.redAccent),
)
]);
} else {
return Icon(Icons.notifications);
}
}),
2018-07-05 16:08:19 +02:00
title: Text('Notification'),
2018-04-21 14:50:46 +02:00
),
2018-07-05 16:08:19 +02:00
BottomNavigationBarItem(
2019-01-22 16:39:44 +01:00
icon: Icon(Icons.search),
title: Text('Search'),
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
title: Text('Me'),
2018-04-21 14:50:46 +02:00
),
],
),
2018-07-05 16:08:19 +02:00
tabBuilder: (context, index) {
2019-01-22 16:39:44 +01:00
return CupertinoTabView(builder: (context) {
switch (index) {
case 0:
return HomeScreen();
case 1:
return NotificationScreen();
case 2:
2019-01-23 12:52:51 +01:00
return SearchScreen();
2019-01-22 16:39:44 +01:00
case 3:
return ProfileScreen();
default:
}
});
2018-04-21 14:50:46 +02:00
},
),
2018-04-20 18:59:26 +02:00
);
}
}