iT邦幫忙

2023 iThome 鐵人賽

DAY 25
0
自我挑戰組

基礎學習Flutter系列 第 25

Day25-學習[Building for iOS with Flutter](記錄)

  • 分享至 

  • xImage
  •  
import 'package:flutter/cupertino.dart';
import 'package:provider/provider.dart';
import 'package:veggietracker/data/models.dart';

void main()=>runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build (BuildContext context) {
    return ChangeNotifierProvider<AppState>(
      builder: (context) => AppState(),
      child: CupertinoApp(
        debugShowCheckedModeBanner: false,
        theme: CupertinoThemeDatal(
          primaryColor: Color(OxFFFF2D55),//紅色日誌圖示
          ),
          home: MainScreen(),
        ),
     );
   }
}
class MainScreen extends StatelessMidget {
  @override
  Widget build(BuildContext context) {
    return CupertinoTabScaffold(
      tabBar: CupertinoTabBar(
        items: [
          BottomNavigationBarItem(
            title: Text('Log'),
            icon: Icon (Cupertinolcons.book),
            ), // BottomNavigationbarItem
          BottomNavigationBariten(
            title: Text('List'),
            icon: Icon(CupertinoIcons.create), 
            ), // BottomNavigationBarItem
         ],
        ), // CupertinoTabBar
        resizeToAvoidBottomInset: false,
        tabBuilder: (context, index) {
          return(index == 0 )
              ?CupertinotabView(builder:(context) => LogScreen())
              :CupertinotabView(builder:(context) => ListScreen());
        },
    ): // CupertinoTabScaffold
   }
  }

class LogScreen extends Statelesswidget {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Text('Log Screen!'),
    );
  }
}    

class Listscreen extends Statelesswidget {
  @override
  Widget build (BuildContext context) {
    return Center(
      child: Text('List Screen!'),
  }
}

class ADDtOLOGsCREEN extends Statelesswidget {
  @override
  Widget build (BuildContext context) {
    return Center(
      child: Text('Add to Log Screen!'),
    );
  }
}


class HomePage extends StatelessWidget {
  const HomePage ();

@override
Widget build(BuildContext context) {
  return CupertinoTabScaffold(
    tabBar: CupertinoTabBar(
      items: const <BottomNavigationBarItem> [
        BottomNavigationBarItem(
          icon: Icon (CupertinoIcons. home) ,
          title: Text ('Home'),
          ),
        BottomNavigationBarItem(
          icon: Icon (CupertinoIcons. conversation_bubble),
          title: Text ('Support'),
        BottomNavigationBarItem(
          icon: Icon (CupertinoIcons-profile_circled),
          title: Text('Profile')
          ),
        ],
      ),
      tabBuilder: (BuildContext context, int index) {
        assert (index >= 0 && index <= 2);
        switch (index) {
          case 0:
            return CupertinoTabView(
              builder: (BuildContext context) => buildPage('Home'), 
            );
            break;
          case 1;
            return CupertinoTabView(
              builder: (BuildContext context) => buildPage ('Support'),
            break;
          case 2:
            return CupertinoTabView(
              builder: (BuildContext context) => buildPage('Profile'),
            );
            break;
          }
          return null;
         },
       };
     }
 widget buildPage (String title) {
   return CupertinoPageScaffold(
     navigationBar: CupertinoNavigationBar (
       middle: Text(title),
       ), 
     child: Center
       child: CupertinoActivityindicator(radius:32),
       ),
      );
     }
    }
    
    class HomePage extends StatelessWidget {
  const HomePage ();

@override
Widget build(BuildContext context) {
  return CupertinoPageScaffold(
    child: Center( 
      child: SizedBox( 
        width: 300,
        child: Cupertinoslider(
          min: 0,
          max: 100,
          value: 50,
          onChanged: (newvalue) {},
        ).// Cupertinoslider
       ). // SizedBox
    ).// Center
   );// CupertinoPageScaffold
  }
 }
 
 

上一篇
Day24-學習[Building for iOS with Flutter](記錄)
下一篇
Day26-功能資料(記錄)
系列文
基礎學習Flutter30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言