본문 바로가기

Ui

Simple note Ui

 

simple note up

간단한. GridView 를 이용한. 메모 Ui 이다. 

SliverGridDelegateWithFixedCrossAxisCount

 

import 'package:flutter/material.dart';
import 'dart:math';
class Ui_NotePage extends StatefulWidget {
  const Ui_NotePage({super.key});

  @override
  State<Ui_NotePage> createState() => _Ui_NotePageState();
}

class _Ui_NotePageState extends State<Ui_NotePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('simple note')),
      body: GridView(
        gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
        children: grid_Children(),
      ),
    );
  }

  List<Widget> grid_Children(){
    List<Widget>  list = [];
    Notes.getListOfNotes().forEach((el)=> list.add(getNoteCard(el)));
    return list;
  }

  Widget getNoteCard(Notes el) {
    int randomColor = Random().nextInt(Notes.notesColor.length -1);
    return Container(
      padding: EdgeInsets.all(10),
      margin: EdgeInsets.all(8),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(8),
        color: Notes.notesColor[randomColor],
      ),
      child: Column(
        children: [
          Text(el.title,style: TextStyle(fontSize: 18,color: Colors.black)),
          SizedBox(height: 4,),
          Text(el.date,style: TextStyle(fontSize: 13,color: Colors.black)),
          SizedBox(height: 4,),
          Text(el.content,style: TextStyle(fontSize: 16,color: Colors.black)),
          SizedBox(height: 4,),
        ],

      ),
    );
  }

  //
}



//

class Notes {
  String title;
  String date;
  String content;

  Notes({required this.title, required this.date, required this.content});

  static List<Notes> getListOfNotes() {
    List<Notes> list = [];
    list.add(Notes(
        title: "showSoftInput()",
        date: "07/01/2021",
        content: "Flattened final assist data: 388 bytes, containing 1 windows, 3 views"));
    list.add(Notes(
        title: "app_time_stats:",
        date: "06/01/2021",
        content: "avg=141.51ms min=0.74ms max=3405.28ms count=25"));
    list.add(Notes(
        title: "OnBackInvokedCallback",
        date: "05/01/2021",
        content: "Set 'android:enableOnBackInvokedCallback"));
    list.add(Notes(
        title: "app_time_stats:",
        date: "04/01/2021",
        content: "avg=299.86ms min=11.22ms max=500.93ms count=5"));
    list.add(Notes(
        title: "SHOW_SOFT_INPUT",
        date: "03/01/2021",
        content: "Flattened final assist data: 456 bytes, containing 1 windows, 3 views"));
    list.add(Notes(
        title: "Skipping target",
        date: "02/01/2021",
        content: "kipping target: gen_dart_plugin_registrant"));
    list.add(Notes(
        title: "tagSocket(58)",
        date: "01/01/2021",
        content: "Notifying id token listeners about user"));
    return list;
  }

  static List<Color> notesColor = [
    Colors.red.shade100,
    Colors.green.shade100,
    Colors.blue.shade100,
    Colors.yellow.shade100,
    Colors.orange.shade100,
    Colors.pink.shade100,
    Colors.blueGrey.shade100,
  ];
}